Hello,
I am trying to differentially rotate a full disk AIA map, which I upgraded to Level 1.5 with the use of aiapy.register (only this function, without using update_pointing because I get an error otherwise)
When applying the procedure in Differentially rotating a map — SunPy 4.1.0 documentation , I get an error when I try to plot the resulting map
I used to use this code until less than one year ago. Now, I need to rotate again some images, but the very same code gives this error
My code is (I defined a function for differential rotation):
def diff_rot_new(mapname, time_diff, basemap):
#NOTE: to go back in time, time_diff MUST be negative
in_time = mapname.date
out_time = in_time + time_diff
out_frame = Helioprojective(observer='earth', obstime= out_time, rsun= mapname.meta['rsun_ref']*u.m)
out_wcs = basemap.wcs
# Reproject the map from the input frame to the output frame.
with propagate_with_solar_surface():
out_warp = mapname.reproject_to(out_wcs)
return out_warp
Then, the error I get is:
KeyError Traceback (most recent call last)
Input In [39], in <cell line: 10>()
78 ## Plotting event
79 fig=plt.figure()
—> 80 out_warp.plot(vmax= 3000, title=f’{map_el.meta[“date-obs”]}‘)
81 plt.colorbar()
82 plt.savefig(event+’/images/Event evolution/event {time}.png’.format(time=time_string),
83 format=‘png’)
File ~\Miniconda\miniconda3\lib\site-packages\astropy\units\decorators.py:304, in QuantityInput.call..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)
306 # Return
307 ra = wrapped_signature.return_annotation
File ~\Miniconda\miniconda3\lib\site-packages\sunpy\map\mapbase.py:2413, in GenericMap.plot(self, annotate, axes, title, autoalign, clip_interval, **imshow_kwargs)
2410 if autoalign is True:
2411 autoalign = ‘pcolormesh’
→ 2413 axes = self._check_axes(axes, warn_different_wcs=autoalign is False)
2415 # Normal plot
2416 plot_settings = copy.deepcopy(self.plot_settings)
File ~\Miniconda\miniconda3\lib\site-packages\sunpy\map\mapbase.py:2584, in GenericMap._check_axes(self, axes, warn_different_wcs)
2569 “”"
2570 - If axes is None, get the current Axes object.
2571 - Error if not a WCSAxes.
(…)
2581 WCSAxes.
2582 “”"
2583 if not axes:
→ 2584 axes = wcsaxes_compat.gca_wcs(self.wcs)
2586 if not wcsaxes_compat.is_wcsaxes(axes):
2587 raise TypeError("The axes need to be an instance of WCSAxes. "
2588 "To fix this pass set the projection
keyword "
2589 “to this map when creating the axes.”)
File ~\Miniconda\miniconda3\lib\site-packages\sunpy\util\decorators.py:371, in cached_property_based_on..outer..inner(instance)
369 cache[attr_name] = new_attr_val
370 # Recompute the property
→ 371 new_val = prop(instance)
372 cache[prop_key] = new_val
374 return cache[prop_key]
File ~\Miniconda\miniconda3\lib\site-packages\sunpy\map\mapbase.py:569, in GenericMap.wcs(self)
567 w2.wcs.crval = u.Quantity([self._reference_longitude, self._reference_latitude])
568 w2.wcs.ctype = self.coordinate_system
→ 569 w2.wcs.pc = self.rotation_matrix
570 w2.wcs.set_pv(self._pv_values)
571 # FITS standard doesn’t allow both PC_ij and CROTA keywords
File ~\Miniconda\miniconda3\lib\site-packages\sunpy\map\mapbase.py:1276, in GenericMap.rotation_matrix(self)
1260 r"“”
1261 Matrix describing the transformation needed to align the reference
1262 pixel with the coordinate axes.
(…)
1273 other transformations e.g., skews for non-orthgonal coordinate systems.
1274 “”"
1275 if ‘PC1_1’ in self.meta:
→ 1276 return np.array([[self.meta[‘PC1_1’], self.meta[‘PC1_2’]],
1277 [self.meta[‘PC2_1’], self.meta[‘PC2_2’]]])
1279 elif ‘CD1_1’ in self.meta:
1280 cd = np.array([[self.meta[‘CD1_1’], self.meta[‘CD1_2’]],
1281 [self.meta[‘CD2_1’], self.meta[‘CD2_2’]]])
File ~\Miniconda\miniconda3\lib\site-packages\sunpy\util\metadata.py:161, in MetaDict.getitem(self, key)
157 def getitem(self, key):
158 “”"
159 Override []
indexing.
160 “”"
→ 161 return OrderedDict.getitem(self, key.lower())
KeyError: ‘pc1_2’
Could anyone be of help? Did you have the same problem?
My sunpy version is 3.5.1