Error when using `aiapy.calibrate.register` after `aiapy.calibrate.update_pointing`
I've just come across an issue when using aiapy.calibrate.register
after aiapy.calibrate.update_pointing
.
The issue seems to be due the scale of the map after using update_pointing
becomes a SpatialPair of MaskedQuantity
s, rather than just Quantities
.
For example:
>>> m = sunpy.map.Map(sample_data.AIA_094_IMAGE)
>>> m_updated_pointing = update_pointing(m)
>>> m_registered = register(m_updated_pointing)
---------------------------------------------------------------------------
ValueError Traceback (most recent call last)
/var/folders/wm/gysdzbp10qv1kcm4zxb5q95xkjzv5q/T/ipykernel_18066/22064975.py in <module>
1 m = sunpy.map.Map(sample_data.AIA_094_IMAGE)
2 m_updated_pointing = update_pointing(m)
----> 3 m_registered = register(m_updated_pointing)
~/opt/miniconda3/lib/python3.9/site-packages/aiapy/calibrate/prep.py in register(smap, missing, order, use_scipy)
78 scale_factor = smap.scale[0] / scale
79 missing = smap.min() if missing is None else missing
---> 80 tempmap = smap.rotate(
81 recenter=True,
82 scale=scale_factor.value,
~/opt/miniconda3/lib/python3.9/site-packages/astropy/units/decorators.py in wrapper(*func_args, **func_kwargs)
302 # Call the original function with any equivalencies in force.
303 with add_enabled_equivalencies(self.equivalencies):
--> 304 return_ = wrapped_function(*func_args, **func_kwargs)
305
306 # Return
~/opt/miniconda3/lib/python3.9/site-packages/sunpy/map/mapbase.py in rotate(self, angle, rmatrix, order, scale, recenter, missing, use_scipy)
1655
1656 # Apply the rotation to the image data
-> 1657 new_data = affine_transform(new_data.T,
1658 np.asarray(rmatrix),
1659 order=order, scale=scale,
~/opt/miniconda3/lib/python3.9/site-packages/sunpy/image/transform.py in affine_transform(image, rmatrix, order, scale, image_center, recenter, missing, use_scipy)
92 rot_center = image_center
93
---> 94 displacement = np.dot(rmatrix, rot_center)
95 shift = image_center - displacement
96 if not use_scipy:
~/opt/miniconda3/lib/python3.9/site-packages/numpy/core/overrides.py in dot(*args, **kwargs)
~/opt/miniconda3/lib/python3.9/site-packages/astropy/utils/masked/core.py in __array_finalize__(self, obj)
555 # Got here after, e.g., a view of another masked class.
556 # Get its mask, or initialize ours.
--> 557 self._set_mask(getattr(obj, '_mask', False))
558
559 if 'info' in obj.__dict__:
~/opt/miniconda3/lib/python3.9/site-packages/astropy/utils/masked/core.py in _set_mask(self, mask, copy)
224 # This will fail (correctly) if not broadcastable.
225 self._mask = np.empty(self.shape, dtype=mask_dtype)
--> 226 self._mask[...] = ma
227 elif ma is mask:
228 # Even if not copying use a view so that shape setting
ValueError: could not broadcast input array from shape (2,2) into shape (2,)
Am I missing something? Its an easy fix which I can PR - but maybe its something on my dependency end?
- SunPy Version: 3.1.2
- Astropy Version: 5.0
- AIApy Version: 0.6.3