`fetch_spikes` fails on submap
I was updating the blog post and this happened with sunpy 3.1 but not 3.0.2
import numpy as np
import matplotlib.pyplot as plt
from sunpy.net import Fido, attrs as a
import sunpy.map
import astropy.units as u
from astropy.coordinates import SkyCoord
import astropy.time
from aiapy.calibrate import fetch_spikes
t_start = astropy.time.Time('2012-01-01T00:00:00')
search_results = Fido.search(
a.Time(t_start, t_start+11*u.s),
a.Instrument('AIA'),
a.Wavelength(171*u.angstrom),
)
files = Fido.fetch(search_results,max_conn=1)
m_171 = sunpy.map.Map(sorted(files))
m_171_cutout = m_171.submap(
SkyCoord(-600*u.arcsec, -600*u.arcsec, frame=m_171.coordinate_frame),
top_right=SkyCoord(100*u.arcsec, 100*u.arcsec, frame=m_171.coordinate_frame),
)
spike_coords, _ = fetch_spikes(m_171_cutout, as_coords=True)
It errors inside of sunpy:
----> 9 spike_coords, _ = fetch_spikes(m_171_cutout, as_coords=True)
/opt/miniconda/envs/sunpy/lib/python3.9/site-packages/aiapy/calibrate/spikes.py in fetch_spikes(smap, as_coords)
161 meta_full_frame['naxis1'] = shape_full_frame[0]
162 meta_full_frame['naxis2'] = shape_full_frame[1]
--> 163 wcs_full_frame = smap._new_instance(
164 np.zeros_like(shape_full_frame),
165 meta_full_frame,
/opt/miniconda/envs/sunpy/lib/python3.9/site-packages/sunpy/util/decorators.py in inner(instance)
372 cache[attr_name] = new_attr_val
373 # Recompute the property
--> 374 new_val = prop(instance)
375 cache[prop_key] = new_val
376
/opt/miniconda/envs/sunpy/lib/python3.9/site-packages/sunpy/map/mapbase.py in wcs(self)
570
571 # Add one to go from zero-based to one-based indexing
--> 572 w2.wcs.crpix = u.Quantity(self.reference_pixel) + 1 * u.pix
573 # Make these a quantity array to prevent the numpy setting element of
574 # array with sequence error.
/opt/miniconda/envs/sunpy/lib/python3.9/site-packages/sunpy/map/mapbase.py in reference_pixel(self)
1243 than the FITS CRPIX values.
1244 """
-> 1245 naxis1 = self.meta.get('naxis1', self.data.shape[1])
1246 naxis2 = self.meta.get('naxis2', self.data.shape[0])
1247 return PixelPair((self.meta.get('crpix1', (naxis1 + 1) / 2.) - 1) * u.pixel,
IndexError: tuple index out of range
Edited by Nabil Freij