from astropy.coordinates import SkyCoord import astropy.units as u import matplotlib.pyplot as plt import numpy as np import sunpy.map from copy import deepcopy
# To use user modules import sys sys.path.append('../modules')
From sunpy 0.9.3,
sunpy.instr.aia.aiaprep() supports both AIAMap
& HMIMap objects.
Note: Improve aiaprep in
<python_path>/site-packages/sunpy/instr/aia.py:
at line: tempmap = aiamap.rotate(...) add
order=3 (recommend, this will keep NaNs) and set
missing=np.nan in rotate()
There is a modified function aiaprep_usr() in
usr_sunpy
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
# After `aiaprep`: # - North is aligned with the y axis. # - Each pixel is 0.6 arcsec across. # - The center of the sun is at the center of the image. # This may be a bit slow.
# DO NOT execute this cell if `sunpy.instr.aia.aiaprep()` has been called. # `rotate` function will remove old CROTA keywords. # This may be a bit slow if order = 3. if'lvl_num'notin mapbz.meta or mapbz.meta['lvl_num'] < 1.5: order = 3 scale_factor = (mapbz.scale[0] / 0.6).value print('rotate(CCW) & recenter & rescale ...') # Suppress warnings of NaNs: with np.errstate(invalid='ignore'): mapbx = mapbx.rotate(order=order, recenter=True, scale=scale_factor, missing=np.nan) mapby = mapby.rotate(order=order, recenter=True, scale=scale_factor, missing=np.nan) mapbz = mapbz.rotate(order=order, recenter=True, scale=scale_factor, missing=np.nan) print('Rotation angle = %f deg (CCW)' % -mapb.meta['crota2'])
User function plot_map() will invoke plot()
of sunpy.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
from usr_sunpy import plot_map
fig1 = plt.figure(figsize=(8, 6), dpi=100) ax1 = fig1.add_subplot(111, projection=mapbz) # This plot function will simply invoke mapbz.plot(), if keyword `coords` is not specified. plot_map(mapbz, ax=ax1, vmin=-2000., vmax=2000.)
submap(bottom_left, top_right=None)
* bottom_left (astropy.units.Quantity or SkyCoord) –
The bottom_left coordinate of the rectangle. If a SkyCoord it can
have shape (2,) and also define top_right. If specifying pixel
coordinates it must be given as an Quantity object with units of pixel.
* top_right (astropy.units.Quantity or SkyCoord) – The
top_right coordinate of the rectangle. Can only be omitted if
bottom_left has shape (2,).