question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

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:closed
  • Created 7 years ago
  • Comments:10 (10 by maintainers)

github_iconTop GitHub Comments

1reaction
MSeifert04commented, Nov 29, 2016

How do I make it work again?

Convince @nden and @astrofrog that #5455 should be merged. 😄

0reactions
MSeifert04commented, Nov 29, 2016

I think #5455 should be merged (not necessarily as-is) just to remain backwards-compatible, so better to discuss this in #5461?

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found