WCS slicing gives TypeError (used to work)
See original GitHub issue@mcara wrote some WCS manipulation codes for me that used to work but are now broken with the latest dev version. Relevant snippets below.
# Shrink the image
data = zoom(data, zoom_factor)
# Adjust WCS
slice_factor = 1 / zoom_factor
old_wcs = wcs.WCS(hdr) # To account for distortion, add "pf" as 2nd arg
# Supress RuntimeWarning about ignoring cdelt because cd is present.
with warnings.catch_warnings():
warnings.simplefilter('ignore', RuntimeWarning)
# Update if cropping
new_wcs = old_wcs.slice((np.s_[::slice_factor], np.s_[::slice_factor]))
Traceback (most recent call last):
...
File ".../stginga/utils.py", line 349, in scale_image
(np.s_[::slice_factor], np.s_[::slice_factor]))
File ".../astropy-1.3.dev16480-py3.5-linux-x86_64.egg/astropy/wcs/wcs.py", line 2983, in slice
nitems = len(builtins.range(self._naxis[wcs_index])[iview])
TypeError: slice indices must be integers or None or have an __index__ method
How do I make it work again?
Issue Analytics
- State:
- Created 7 years ago
- Comments:10 (10 by maintainers)
Top Results From Across the Web
WCS — Astropy v5.2
Use numpy order, i.e. slice the WCS so that an identical slice applied to a numpy array will slice the array and WCS...
Read more >Record data size in the WCS object · Issue #5461 · astropy/astropy ...
Introduce a subclass of WCS which adds those and leave the original WCS to represent strictly the FITS ... WCS slicing gives TypeError...
Read more >Source code for astropy.wcs.wcs
When ``None``, only the standard image header keywords are considered (and the underlying wcspih() C function is called). To use binary table image...
Read more >how to write slice of a fits cube to a new file - Stack Overflow
Hi I am trying to extract a layer of my fits cube that as NAXIS 4 and write the data from one layer...
Read more >Source code for ndcube.utils.wcs - SunPy
This is used to convert between array axes in numpy order and pixel axes in WCS order. Works in both directions. Parameters ----------...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Convince @nden and @astrofrog that #5455 should be merged. 😄
I think #5455 should be merged (not necessarily as-is) just to remain backwards-compatible, so better to discuss this in #5461?