AIAMap#

class sunpy.map.sources.AIAMap(data, header, **kwargs)[source]#

Bases: GenericMap

AIA Image Map.

The Atmospheric Imaging Assembly is a set of four telescopes that employ normal-incidence, multi-layer coated optics to provide narrow-band imaging of the Sun. It provides high resolution full-disk images of the corona and transition region up to 0.5 solar radii above the solar limb with 1.5 arcsecond angular resolution and 12-second temporal resolution. It observes the Sun in the following seven extreme ultraviolet bandpasses: 94 A (Fe XVIII), 131 A (Fe VIII, XXI), 171 A (Fe IX), 193 A (Fe XII, XXIV), 211 A (Fe XIV), 304 A (He II), 335 A (Fe XVI). One telescope observes in the visible 1600 A (C IV) and the nearby continuum (1700 A).

Notes

Observer location: The standard AIA FITS header provides the spacecraft location in multiple coordinate systems, including Heliocentric Aries Ecliptic (HAE) and Heliographic Stonyhurst (HGS). SunPy uses the provided HAE coordinates due to accuracy concerns with the provided HGS coordinates, but other software packages may make different choices.

A number of the properties of this class are returned as two-value named tuples that can either be indexed by position ([0] or [1]) or be accessed by the names (.x and .y) or (.axis1 and .axis2). Things that refer to pixel axes use the .x, .y convention, where x and y refer to the FITS axes (x for columns y for rows). Spatial axes use .axis1 and .axis2 which correspond to the first and second axes in the header. axis1 corresponds to the coordinate axis for x and axis2 corresponds to y.

This class assumes that the metadata adheres to the FITS 4 standard. Where the CROTA2 metadata is provided (without PC_ij) it assumes a conversion to the standard PC_ij described in section 6.1 of . Calabretta & Greisen (2002)

Warning

If a header has CD_ij values but no PC_ij values, CDELT values are required for this class to construct the WCS. If a file with more than two dimensions is feed into the class, only the first two dimensions (NAXIS1, NAXIS2) will be loaded and the rest will be discarded.

References

Attributes Summary

bottom_left_coord

The physical coordinate at the center of the bottom left ([0, 0]) pixel.

carrington_latitude

Observer Carrington latitude.

carrington_longitude

Observer Carrington longitude.

center

Return a coordinate object for the center pixel of the array.

cmap

Return the matplotlib.colors.Colormap instance this map uses.

coordinate_frame

An astropy.coordinates.BaseCoordinateFrame instance created from the coordinate information for this Map, or None if the frame cannot be determined.

coordinate_system

Coordinate system used for x and y axes (ctype1/2).

data

The stored dataset.

date

The observation time.

date_average

Average time of the image acquisition.

date_end

Time of the end of the image acquisition.

date_start

Time of the beginning of the image acquisition.

detector

Detector name.

dimensions

The dimensions of the array (x axis first, y axis second).

dsun

Observer distance from the center of the Sun.

dtype

The numpy.dtype of the array of the map.

exposure_time

Exposure time of the image.

fits_header

A Header representation of the meta attribute.

heliographic_latitude

Observer heliographic latitude.

heliographic_longitude

Observer heliographic longitude.

instrument

Instrument name.

latex_name

LaTeX formatted description of the Map.

mask

Mask for the dataset, if any.

measurement

Measurement wavelength.

meta

name

Human-readable description of the Map.

ndim

The value of numpy.ndarray.ndim of the data array of the map.

nickname

An abbreviated human-readable description of the map-type; part of the Helioviewer data model.

observatory

Returns the observatory.

observer_coordinate

The Heliographic Stonyhurst Coordinate of the observer.

processing_level

Returns the FITS processing level if present.

psf

Image representation of the PSF for the dataset.

quantity

Unitful representation of the map data.

reference_coordinate

Reference point WCS axes in data units (i.e. crval1, crval2).

reference_date

The reference date for the coordinate system.

reference_pixel

Pixel of reference coordinate.

rotation_matrix

Matrix describing the transformation needed to align the reference pixel with the coordinate axes.

rsun_meters

Assumed radius of observed emission from the Sun center.

rsun_obs

Angular radius of the observation from Sun center.

scale

Image scale along the x and y axes in units/pixel (i.e. cdelt1, cdelt2).

spatial_units

Image coordinate units along the x and y axes (i.e. cunit1, cunit2).

timeunit

The Unit of the exposure time of this observation.

top_right_coord

The physical coordinate at the center of the the top right ([-1, -1]) pixel.

uncertainty

Uncertainty in the dataset, if any.

unit

Unit of the map data.

wavelength

Wavelength of the observation.

waveunit

The Unit of the wavelength of this observation.

wcs

The WCS property of the map.

Methods Summary

contour(level, **kwargs)

Returns coordinates of the contours for a given level value.

draw_contours(levels[, axes, fill])

Draw contours of the data.

draw_grid([axes, grid_spacing, annotate, system])

Draws a coordinate overlay on the plot in the Heliographic Stonyhurst coordinate system.

draw_limb([axes, resolution])

Draws the solar limb as seen by the map's observer.

draw_quadrangle(bottom_left, *[, width, ...])

Draw a quadrangle defined in world coordinates on the plot using Astropy's Quadrangle.

is_datasource_for(data, header, **kwargs)

Determines if header corresponds to an AIA image

max(*args, **kwargs)

Calculate the maximum value of the data array, ignoring NaNs.

mean(*args, **kwargs)

Calculate the mean of the data array, ignoring NaNs.

min(*args, **kwargs)

Calculate the minimum value of the data array, ignoring NaNs.

peek([draw_limb, draw_grid, colorbar])

Displays a graphical overview of the data in this object for user evaluation.

pixel_to_world(x, y)

Convert a pixel coordinate to a data (world) coordinate.

plot(*[, annotate, axes, title, autoalign, ...])

Plots the map object using matplotlib, in a method equivalent to imshow() using nearest neighbor interpolation.

quicklook()

Display a quicklook summary of the Map instance using the default web browser.

reproject_to(target_wcs, *[, algorithm, ...])

Reproject the map to a different world coordinate system (WCS)

resample(dimensions[, method])

Resample to new dimension sizes.

rotate([angle, rmatrix, order, scale, ...])

Returns a new rotated and rescaled map.

save(filepath[, filetype])

Save a map to a file.

shift_reference_coord(axis1, axis2)

Returns a map shifted by a specified amount to, for example, correct for a bad map location.

std(*args, **kwargs)

Calculate the standard deviation of the data array, ignoring NaNs.

submap(bottom_left, *[, top_right, width, ...])

Returns a submap defined by a rectangle.

superpixel(dimensions[, offset, func])

Returns a new map consisting of superpixels formed by applying 'func' to the original map data.

world_to_pixel(coordinate)

Convert a world (data) coordinate to a pixel coordinate.

Attributes Documentation

bottom_left_coord#

The physical coordinate at the center of the bottom left ([0, 0]) pixel.

carrington_latitude#

Observer Carrington latitude.

carrington_longitude#

Observer Carrington longitude.

center#

Return a coordinate object for the center pixel of the array.

If the array has an even number of pixels in a given dimension, the coordinate returned lies on the edge between the two central pixels.

cmap#

Return the matplotlib.colors.Colormap instance this map uses.

coordinate_frame#

An astropy.coordinates.BaseCoordinateFrame instance created from the coordinate information for this Map, or None if the frame cannot be determined.

Notes

The obstime for the coordinate frame uses the reference_date property, which may be different from the date property.

coordinate_system#

Coordinate system used for x and y axes (ctype1/2).

If not present, defaults to (HPLN-TAN, HPLT-TAN), and emits a warning.

data#

The stored dataset.

Type:

ndarray-like

date#

The observation time.

This time is the “canonical” way to refer to an observation, which is commonly the start of the observation, but can be a different time. In comparison, the GenericMap.date_start property is unambigiously the start of the observation.

The observation time is determined using this order of preference:

  1. The DATE-OBS or DATE_OBS FITS keywords

  2. GenericMap.date_start

  3. GenericMap.date_average

  4. GenericMap.date_end

  5. The current time

See also

reference_date

The reference date for the the coordinate system

date_start

The start time of the observation.

date_end

The end time of the observation.

date_average

The average time of the observation.

date_average#

Average time of the image acquisition.

Taken from the DATE-AVG FITS keyword if present, otherwise halfway between date_start and date_end if both pieces of metadata are present.

date_end#

Time of the end of the image acquisition.

Taken from the DATE-END FITS keyword.

date_start#

Time of the beginning of the image acquisition.

Taken from the DATE-BEG FITS keyword.

detector#
dimensions#

The dimensions of the array (x axis first, y axis second).

dsun#

Observer distance from the center of the Sun.

dtype#

The numpy.dtype of the array of the map.

exposure_time#

Exposure time of the image.

This is taken from the ‘XPOSURE’ keyword or the ‘EXPTIME’ FITS keyword, in that order.

fits_header#

A Header representation of the meta attribute.

heliographic_latitude#

Observer heliographic latitude.

heliographic_longitude#

Observer heliographic longitude.

instrument#

Instrument name.

latex_name#

LaTeX formatted description of the Map.

mask#

Mask for the dataset, if any.

Masks should follow the numpy convention that valid data points are marked by False and invalid ones with True.

Type:

any type

measurement#

Measurement wavelength.

This is taken from the ‘WAVELNTH’ FITS keywords. If the keyword is not present, defaults to None. If ‘WAVEUNIT’ keyword isn’t present, defaults to dimensionless units.

meta = None#
name#

Human-readable description of the Map.

ndim#

The value of numpy.ndarray.ndim of the data array of the map.

nickname#

An abbreviated human-readable description of the map-type; part of the Helioviewer data model.

observatory#

Returns the observatory.

observer_coordinate#

The Heliographic Stonyhurst Coordinate of the observer.

Notes

The obstime for this coordinate uses the reference_date property, which may be different from the date property.

processing_level#

Returns the FITS processing level if present.

This is taken from the ‘LVL_NUM’ FITS keyword.

psf#
quantity#

Unitful representation of the map data.

reference_coordinate#

Reference point WCS axes in data units (i.e. crval1, crval2). This value includes a shift if one is set.

reference_date#

The reference date for the coordinate system.

DATE-OBS is derived from T_OBS by subtracting half the exposure time, so would not be a reference time.

reference_pixel#

Pixel of reference coordinate.

The pixel returned uses zero-based indexing, so will be 1 pixel less than the FITS CRPIX values.

rotation_matrix#

Matrix describing the transformation needed to align the reference pixel with the coordinate axes.

The order or precedence of FITS keywords which this is taken from is: - PC*_* - CD*_* - CROTA*

Notes

In many cases this is a simple rotation matrix, hence the property name. It general it does not have to be a pure rotation matrix, and can encode other transformations e.g., skews for non-orthgonal coordinate systems.

rsun_meters#

Assumed radius of observed emission from the Sun center.

This is taken from the RSUN_REF FITS keyword, if present. If not, and angular radius metadata is present, it is calculated from rsun_obs and dsun. If neither pieces of metadata are present, defaults to the standard photospheric radius.

rsun_obs#

Angular radius of the observation from Sun center.

This value is taken (in order of preference) from the ‘RSUN_OBS’, ‘SOLAR_R’, or ‘RADIUS’ FITS keywords. If none of these keys are present, the angular radius is calculated from rsun_meters and dsun.

scale#

Image scale along the x and y axes in units/pixel (i.e. cdelt1, cdelt2).

If the CDij matrix is defined but no CDELTi values are explicitly defined, effective CDELTi values are constructed from the CDij matrix. The effective CDELTi values are chosen so that each row of the PCij matrix has unity norm. This choice is optimal if the PCij matrix is a pure rotation matrix, but may not be as optimal if the PCij matrix includes any skew.

spatial_units#

Image coordinate units along the x and y axes (i.e. cunit1, cunit2).

timeunit#

The Unit of the exposure time of this observation.

Taken from the “TIMEUNIT” FITS keyword, and defaults to seconds (as per) the FITS standard).

top_right_coord#

The physical coordinate at the center of the the top right ([-1, -1]) pixel.

uncertainty#

Uncertainty in the dataset, if any.

Should have an attribute uncertainty_type that defines what kind of uncertainty is stored, such as 'std' for standard deviation or 'var' for variance. A metaclass defining such an interface is NDUncertainty but isn’t mandatory.

Type:

any type

unit#
wavelength#

Wavelength of the observation.

This is taken from the ‘WAVELNTH’ FITS keywords. If the keyword is not present, defaults to None. If ‘WAVEUNIT’ keyword isn’t present, defaults to dimensionless units.

waveunit#

The Unit of the wavelength of this observation.

This is taken from the ‘WAVEUNIT’ FITS keyword. If the keyword is not present, defaults to None

wcs#

The WCS property of the map.

Notes

dateobs is always populated with the “canonical” observation time as provided by the date property. This will commonly be the DATE-OBS key if it is in the metadata, but see that property for the logic otherwise.

dateavg is always populated with the reference date of the coordinate system as provided by the reference_date property. This will commonly be the DATE-AVG key if it is in the metadata, but see that property for the logic otherwise.

datebeg is conditonally populated with the start of the observation period as provided by the date_start property, which normally returns a value only if the DATE-BEG key is in the metadata.

dateend is conditonally populated with the end of the observation period as provided by the date_end property, which normally returns a value only if the DATE-END key is in the metadata.

Methods Documentation

contour(level, **kwargs)#

Returns coordinates of the contours for a given level value.

For details of the contouring algorithm see skimage.measure.find_contours.

Parameters:
  • level (float, astropy.units.Quantity) – Value along which to find contours in the array. If the map unit attribute is not None, this must be a Quantity with units equivalent to the map data units.

  • kwargs – Additional keyword arguments are passed to skimage.measure.find_contours.

Returns:

contours (list of (n,2) SkyCoord) – Coordinates of each contour.

Examples

>>> import astropy.units as u
>>> import sunpy.map
>>> import sunpy.data.sample  
>>> aia = sunpy.map.Map(sunpy.data.sample.AIA_171_IMAGE)  
>>> contours = aia.contour(50000 * u.DN)  
>>> print(contours[0])  
<SkyCoord (Helioprojective: obstime=2011-06-07T06:33:02.880, rsun=696000.0 km, observer=<HeliographicStonyhurst Coordinate (obstime=2011-06-07T06:33:02.880, rsun=696000.0 km): (lon, lat, radius) in (deg, deg, m)
(-0.00406429, 0.04787238, 1.51846026e+11)>): (Tx, Ty) in arcsec
[(719.59798458, -352.60839064), (717.19243987, -353.75348121),
 (715.8820808 , -354.75140718), (714.78652558, -355.05102034),
 (712.68209174, -357.14645009), (712.68639008, -359.54923801),
 (713.14112796, -361.95311455), (714.76598031, -363.53013567),
 (717.17229147, -362.06880784), (717.27714042, -361.9631112 ),
 (718.43620686, -359.56313541), (718.8672722 , -357.1614    ),
 (719.58811599, -356.68119768), (721.29217122, -354.76448374),
 (719.59798458, -352.60839064)]>
draw_contours(levels, axes=None, *, fill=False, **contour_args)#

Draw contours of the data.

Parameters:
  • levels (Quantity) – A list of numbers indicating the contours to draw. These are given as a percentage of the maximum value of the map data, or in units equivalent to the unit attribute.

  • axes (matplotlib.axes.Axes) – The axes on which to plot the contours. Defaults to the current axes.

  • fill (bool, optional) – Determines the style of the contours: - If False (default), contours are drawn as lines using contour(). - If True, contours are drawn as filled regions using contourf().

Returns:

cs (list) – The QuadContourSet object, after it has been added to axes.

Notes

Extra keyword arguments to this function are passed through to the corresponding matplotlib method.

draw_grid(axes=None, grid_spacing: Unit("deg") = <Quantity 15. deg>, annotate=True, system='stonyhurst', **kwargs)#

Draws a coordinate overlay on the plot in the Heliographic Stonyhurst coordinate system.

To overlay other coordinate systems see the WCSAxes Documentation

Parameters:
  • axes (axes or None) – Axes to plot limb on, or None to use current axes.

  • grid_spacing (Quantity) – Spacing for longitude and latitude grid, if length two it specifies (lon, lat) spacing.

  • annotate (bool) – Passing False disables the axes labels and the ticks on the top and right axes.

  • system (str) – Coordinate system for the grid. Must be ‘stonyhurst’ or ‘carrington’.

  • kwargs – Additional keyword arguments are passed to wcsaxes_heliographic_overlay.

Returns:

overlay (CoordinatesMap) – The wcsaxes coordinate overlay instance.

Notes

Keyword arguments are passed onto the sunpy.visualization.wcsaxes_compat.wcsaxes_heliographic_overlay function.

draw_limb(axes=None, *, resolution=1000, **kwargs)#

Draws the solar limb as seen by the map’s observer.

The limb is a circle for only the simplest plots. If the coordinate frame of the limb is different from the coordinate frame of the plot axes, not only may the limb not be a true circle, a portion of the limb may be hidden from the observer. In that case, the circle is divided into visible and hidden segments, represented by solid and dotted lines, respectively.

Parameters:
  • axes (axes or None) – Axes to plot limb on or None to use current axes.

  • resolution (int) – The number of points to use to represent the limb.

Returns:

  • visible (Polygon or Circle) – The patch added to the axes for the visible part of the limb (i.e., the “near” side of the Sun).

  • hidden (Polygon or None) – The patch added to the axes for the hidden part of the limb (i.e., the “far” side of the Sun).

Notes

Keyword arguments are passed onto the patches.

If the limb is a true circle, visible will instead be Circle and hidden will be None. If there are no visible points (e.g., on a synoptic map any limb is fully) visible hidden will be None.

To avoid triggering Matplotlib auto-scaling, these patches are added as artists instead of patches. One consequence is that the plot legend is not populated automatically when the limb is specified with a text label. See Composing Custom Legends in the Matplotlib documentation for examples of creating a custom legend.

draw_quadrangle(bottom_left, *, width: Unit('deg'), Unit('pix') = None, height: Unit('deg'), Unit('pix') = None, axes=None, top_right=None, **kwargs)#

Draw a quadrangle defined in world coordinates on the plot using Astropy’s Quadrangle.

This draws a quadrangle that has corners at (bottom_left, top_right), and has sides aligned with the coordinate axes of the frame of bottom_left, which may be different from the coordinate axes of the map.

If width and height are specified, they are respectively added to the longitude and latitude of the bottom_left coordinate to calculate a top_right coordinate.

Parameters:
  • bottom_left (SkyCoord or Quantity) – The bottom-left coordinate of the rectangle. If a SkyCoord it can have shape (2,) and simultaneously define top_right. If specifying pixel coordinates it must be given as an Quantity object with pixel units (e.g., pix).

  • top_right (SkyCoord or Quantity, optional) – The top-right coordinate of the quadrangle. If top_right is specified width and height must be omitted.

  • width (astropy.units.Quantity, optional) – The width of the quadrangle. Required if top_right is omitted.

  • height (astropy.units.Quantity) – The height of the quadrangle. Required if top_right is omitted.

  • axes (matplotlib.axes.Axes) – The axes on which to plot the quadrangle. Defaults to the current axes.

Returns:

quad (Quadrangle) – The added patch.

Notes

Extra keyword arguments to this function are passed through to the Quadrangle instance.

Examples

AIA to STEREO coordinate conversion

AIA to STEREO coordinate conversion

Drawing a latitude-longitude quadrangle

Drawing a latitude-longitude quadrangle

Drawing a rotated rectangle on a map

Drawing a rotated rectangle on a map

Comparing differential-rotation models

Comparing differential-rotation models

HMI Showcase: Cutout

HMI Showcase: Cutout
classmethod is_datasource_for(data, header, **kwargs)[source]#

Determines if header corresponds to an AIA image

max(*args, **kwargs)#

Calculate the maximum value of the data array, ignoring NaNs.

mean(*args, **kwargs)#

Calculate the mean of the data array, ignoring NaNs.

min(*args, **kwargs)#

Calculate the minimum value of the data array, ignoring NaNs.

peek(draw_limb=False, draw_grid=False, colorbar=True, **matplot_args)#

Displays a graphical overview of the data in this object for user evaluation. For the creation of plots, users should instead use the plot method and Matplotlib’s pyplot framework.

Parameters:
  • draw_limb (bool) – Whether the solar limb should be plotted.

  • draw_grid (bool or Quantity) – Whether solar meridians and parallels are plotted. If Quantity then sets degree difference between parallels and meridians.

  • colorbar (bool) – Whether to display a colorbar next to the plot.

  • **matplot_args (dict) – Matplotlib Any additional imshow arguments that should be used when plotting.

pixel_to_world(x: Unit('pix'), y: Unit('pix'))#

Convert a pixel coordinate to a data (world) coordinate.

Parameters:
  • x (Quantity) – Pixel coordinate of the CTYPE1 axis. (Normally solar-x).

  • y (Quantity) – Pixel coordinate of the CTYPE2 axis. (Normally solar-y).

Returns:

coord (astropy.coordinates.SkyCoord) – A coordinate object representing the output coordinate.

plot(*, annotate=True, axes=None, title=True, autoalign=False, clip_interval: Unit('%') = None, **imshow_kwargs)#

Plots the map object using matplotlib, in a method equivalent to imshow() using nearest neighbor interpolation.

Parameters:
  • annotate (bool, optional) – If True, the data is plotted at its natural scale; with title and axis labels.

  • axes (Axes or None) – If provided the image will be plotted on the given axes. Else the current Matplotlib axes will be used.

  • title (str, bool, optional) – The plot title. If True, uses the default title for this map.

  • clip_interval (two-element Quantity, optional) – If provided, the data will be clipped to the percentile interval bounded by the two numbers.

  • autoalign (bool or str, optional) – If other than False, the plotting accounts for any difference between the WCS of the map and the WCS of the WCSAxes axes (e.g., a difference in rotation angle). If pcolormesh, this method will use pcolormesh() instead of the default imshow(). Specifying True is equivalent to specifying pcolormesh.

  • **imshow_kwargs (dict) – Any additional imshow arguments are passed to imshow().

Examples

>>> # Simple Plot with color bar
>>> aia.plot()   
>>> plt.colorbar()   
>>> # Add a limb line and grid
>>> aia.plot()   
>>> aia.draw_limb()   
>>> aia.draw_grid()   

Notes

The autoalign functionality is computationally intensive. If the plot will be interactive, the alternative approach of preprocessing the map (e.g., de-rotating it) to match the desired axes will result in better performance.

When combining autoalign functionality with Helioprojective coordinates, portions of the map that are beyond the solar disk may not appear, which may also inhibit Matplotlib’s autoscaling of the plot limits. The plot limits can be set manually. To preserve the off-disk parts of the map, using the SphericalScreen context manager may be appropriate.

quicklook()#

Display a quicklook summary of the Map instance using the default web browser.

Notes

The image colormap uses histogram equalization.

Clicking on the image to switch between pixel space and coordinate space requires Javascript support to be enabled in the web browser.

Examples

>>> from sunpy.map import Map
>>> import sunpy.data.sample  
>>> smap = Map(sunpy.data.sample.AIA_171_IMAGE)  
>>> smap.quicklook()  

(which will open the following content in the default web browser)

<sunpy.map.sources.sdo.AIAMap object at 0x7f89bfcdbd70>
Observatory SDO
Instrument AIA 3
Detector AIA
Measurement 171.0 Angstrom
Wavelength 171.0 Angstrom
Observation Date 2011-06-07 06:33:02
Exposure Time 0.234256 s
Dimension [1024. 1024.] pix
Coordinate System helioprojective
Scale [2.402792 2.402792] arcsec / pix
Reference Pixel [511.5 511.5] pix
Reference Coord [3.22309951 1.38578135] arcsec
Image colormap uses histogram equalization
Click on the image to toggle between units
reproject_to(target_wcs, *, algorithm='interpolation', return_footprint=False, **reproject_args)#

Reproject the map to a different world coordinate system (WCS)

Note

This method requires the optional package reproject to be installed.

Additional keyword arguments are passed through to the reprojection function.

Parameters:
  • target_wcs (dict or WCS) – The destination FITS WCS header or WCS instance

  • algorithm (str) – One of the supported reproject algorithms (see below)

  • return_footprint (bool) – If True, the footprint is returned in addition to the new map. Defaults to False.

Returns:

  • outmap (GenericMap) – The reprojected map

  • footprint (ndarray) – Footprint of the input arary in the output array. Values of 0 indicate no coverage or valid values in the input image, while values of 1 indicate valid values. Intermediate values indicate partial coverage. Only returned if return_footprint is True.

Notes

The reprojected map does not preserve any metadata beyond the WCS-associated metadata.

The supported reproject algorithms are:

See the respective documentation for these functions for additional keyword arguments that are allowed.

Masking HMI based on the intensity of AIA

Masking HMI based on the intensity of AIA

Aligning AIA and HMI Data with Reproject

Aligning AIA and HMI Data with Reproject

Creating Carrington Maps

Creating Carrington Maps

Reprojecting Images to Different Observers

Reprojecting Images to Different Observers

Reprojecting Using a Spherical Screen

Reprojecting Using a Spherical Screen

Reprojecting to a Map Projection with a Custom Origin

Reprojecting to a Map Projection with a Custom Origin

Creating a Composite Plot with Three Maps

Creating a Composite Plot with Three Maps

Overlay an AIA image on a LASCO C2 coronagraph

Overlay an AIA image on a LASCO C2 coronagraph

Plotting the solar equator and prime meridian

Plotting the solar equator and prime meridian

Differentially rotating a map

Differentially rotating a map
resample(dimensions: Unit('pix'), method='linear')#

Resample to new dimension sizes.

Uses the same parameters and creates the same coordinate lookup points as IDL’’s congrid routine, which apparently originally came from a VAX/VMS routine of the same name.

Parameters:
  • dimensions (Quantity) – Output pixel dimensions. The first argument corresponds to the ‘x’ axis and the second argument corresponds to the ‘y’ axis.

  • method (str) –

    Method to use for resampling interpolation.
Returns:

out (GenericMap or subclass) – Resampled map

References

Rebinning

rotate(angle: Unit('deg') = None, rmatrix=None, order=3, scale=1.0, recenter=False, missing=nan, *, method='scipy', clip=True)#

Returns a new rotated and rescaled map.

Specify either a rotation angle or a rotation matrix, but not both. If neither an angle or a rotation matrix are specified, the map will be rotated by the rotation information in the metadata, which should derotate the map so that the pixel axes are aligned with world-coordinate axes.

Parameters:
  • angle (Quantity) – The angle (degrees) to rotate counterclockwise.

  • rmatrix (array-like) – 2x2 linear transformation rotation matrix.

  • order (int) – Interpolation order to be used. The precise meaning depends on the rotation method specified by method. Default: 3

  • scale (float) – A scale factor for the image, default is no scaling

  • recenter (bool) – If True, position the reference coordinate at the center of the new map Default: False

  • missing (float) – The value to use for pixels in the output map that are beyond the extent of the input map. Default: numpy.nan

  • method ({'scipy', 'scikit-image', 'opencv'}, optional) – Rotation function to use. Defaults to 'scipy'.

  • clip (bool, optional) – If True, clips the pixel values of the output image to the range of the input image (including the value of missing, if used). Defaults to True.

Returns:

out (GenericMap or subclass) – A new Map instance containing the rotated and rescaled data of the original map.

See also

sunpy.image.transform.affine_transform

The routine this method calls for the rotation.

Notes

The rotation information in the metadata of the new map is modified appropriately from that of the original map to account for the applied rotation. It will solely be in the form of a PCi_j matrix, even if the original map used the CROTA2 keyword or a CDi_j matrix.

If the map does not already contain pixels with numpy.nan values, setting missing to an appropriate number for the data (e.g., zero) will reduce the computation time.

For each NaN pixel in the input image, one or more pixels in the output image will be set to NaN, with the size of the pixel region affected depending on the interpolation order. All currently implemented rotation methods require a convolution step to handle image NaNs. This convolution normally uses scipy.signal.convolve2d(), but if OpenCV is installed, the faster cv2.filter2D() is used instead.

See sunpy.image.transform.affine_transform() for details on each of the rotation functions.

save(filepath, filetype='auto', **kwargs)#

Save a map to a file.

Parameters:
  • filepath (str) – Location to save file to.

  • filetype (str, optional) – Any supported file extension, defaults to "auto".

  • hdu_type (ExtensionHDU instance or class, optional) – By default, a FITS file is written with the map in its primary HDU. If a type is given, a new HDU of this type will be created. If a HDU instance is given, its data and header will be updated from the map. Then that HDU instance will be written to the file. The example below uses astropy.io.fits.CompImageHDU to compress the map.

  • kwargs – Any additional keyword arguments are passed to _file_tools_write_file.

Notes

Saving with the jp2 extension will write a modified version of the given data casted to uint8 values in order to support the JPEG2000 format.

Examples

>>> from astropy.io.fits import CompImageHDU
>>> from sunpy.map import Map
>>> import sunpy.data.sample  
>>> aia_map = Map(sunpy.data.sample.AIA_171_IMAGE)  
>>> aia_map.save("aia171.fits", hdu_type=CompImageHDU)  
shift_reference_coord(axis1: Unit('deg'), axis2: Unit('deg'))#

Returns a map shifted by a specified amount to, for example, correct for a bad map location. These values are applied directly to the reference_coordinate. To check how much the reference coordinate has been modified, see sunpy.map.GenericMap.meta.modified_items['CRVAL1'] and sunpy.map.GenericMap.meta.modified_items['CRVAL2'].

Parameters:
  • axis1 (Quantity) – The shift to apply to the Longitude (solar-x) coordinate.

  • axis2 (Quantity) – The shift to apply to the Latitude (solar-y) coordinate

Returns:

out (GenericMap or subclass) – A new shifted Map.

std(*args, **kwargs)#

Calculate the standard deviation of the data array, ignoring NaNs.

submap(bottom_left, *, top_right=None, width: Unit('deg'), Unit('pix') = None, height: Unit('deg'), Unit('pix') = None)#

Returns a submap defined by a rectangle.

Any pixels which have at least part of their area inside the rectangle are returned. If the rectangle is defined in world coordinates, the smallest array which contains all four corners of the rectangle as defined in world coordinates is returned.

Parameters:
  • bottom_left (astropy.units.Quantity or SkyCoord) – The bottom-left coordinate of the rectangle. If a SkyCoord it can have shape (2,) and simultaneously define top_right. If specifying pixel coordinates it must be given as an Quantity object with units of pixels.

  • top_right (astropy.units.Quantity or SkyCoord, optional) – The top-right coordinate of the rectangle. If top_right is specified width and height must be omitted.

  • width (astropy.units.Quantity, optional) – The width of the rectangle. Required if top_right is omitted.

  • height (astropy.units.Quantity) – The height of the rectangle. Required if top_right is omitted.

Returns:

out (GenericMap or subclass) – A new map instance is returned representing to specified sub-region.

Notes

When specifying pixel coordinates, they are specified in Cartesian order not in numpy order. So, for example, the bottom_left= argument should be [left, bottom].

Examples

>>> import astropy.units as u
>>> from astropy.coordinates import SkyCoord
>>> import sunpy.map
>>> import sunpy.data.sample  
>>> aia = sunpy.map.Map(sunpy.data.sample.AIA_171_IMAGE)  
>>> bl = SkyCoord(-300*u.arcsec, -300*u.arcsec, frame=aia.coordinate_frame)  
>>> tr = SkyCoord(500*u.arcsec, 500*u.arcsec, frame=aia.coordinate_frame)  
>>> aia.submap(bl, top_right=tr)   
<sunpy.map.sources.sdo.AIAMap object at ...>
SunPy Map
---------
Observatory:         SDO
Instrument:          AIA 3
Detector:            AIA
Measurement:         171.0 Angstrom
Wavelength:          171.0 Angstrom
Observation Date:    2011-06-07 06:33:02
Exposure Time:       0.234256 s
Dimension:           [335. 335.] pix
Coordinate System:   helioprojective
Scale:               [2.402792 2.402792] arcsec / pix
Reference Pixel:     [126.5 125.5] pix
Reference Coord:     [3.22309951 1.38578135] arcsec
...
>>> aia.submap([0,0]*u.pixel, top_right=[5,5]*u.pixel)   
<sunpy.map.sources.sdo.AIAMap object at ...>
SunPy Map
---------
Observatory:         SDO
Instrument:          AIA 3
Detector:            AIA
Measurement:         171.0 Angstrom
Wavelength:          171.0 Angstrom
Observation Date:    2011-06-07 06:33:02
Exposure Time:       0.234256 s
Dimension:           [6. 6.] pix
Coordinate System:   helioprojective
Scale:               [2.402792 2.402792] arcsec / pix
Reference Pixel:     [511.5 511.5] pix
Reference Coord:     [3.22309951 1.38578135] arcsec
...
>>> width = 10 * u.arcsec
>>> height = 10 * u.arcsec
>>> aia.submap(bl, width=width, height=height)   
<sunpy.map.sources.sdo.AIAMap object at ...>
SunPy Map
---------
Observatory:         SDO
Instrument:          AIA 3
Detector:            AIA
Measurement:         171.0 Angstrom
Wavelength:          171.0 Angstrom
Observation Date:    2011-06-07 06:33:02
Exposure Time:       0.234256 s
Dimension:           [5. 5.] pix
Coordinate System:   helioprojective
Scale:               [2.402792 2.402792] arcsec / pix
Reference Pixel:     [125.5 125.5] pix
Reference Coord:     [3.22309951 1.38578135] arcsec
...
>>> bottom_left_vector = SkyCoord([0, 10]  * u.deg, [0, 10] * u.deg, frame='heliographic_stonyhurst')
>>> aia.submap(bottom_left_vector)   
<sunpy.map.sources.sdo.AIAMap object at ...>
SunPy Map
---------
Observatory:         SDO
Instrument:          AIA 3
Detector:            AIA
Measurement:         171.0 Angstrom
Wavelength:          171.0 Angstrom
Observation Date:    2011-06-07 06:33:02
Exposure Time:       0.234256 s
Dimension:           [70. 69.] pix
Coordinate System:   helioprojective
Scale:               [2.402792 2.402792] arcsec / pix
Reference Pixel:     [1.5 0.5] pix
Reference Coord:     [3.22309951 1.38578135] arcsec
...
superpixel(dimensions: Unit("pix"), offset: Unit("pix") = <Quantity [0., 0.] pix>, func=<function sum>)#

Returns a new map consisting of superpixels formed by applying ‘func’ to the original map data.

Parameters:
  • dimensions (tuple) – One superpixel in the new map is equal to (dimension[0], dimension[1]) pixels of the original map. The first argument corresponds to the ‘x’ axis and the second argument corresponds to the ‘y’ axis. If non-integer values are provided, they are rounded using int.

  • offset (tuple) – Offset from (0,0) in original map pixels used to calculate where the data used to make the resulting superpixel map starts. If non-integer value are provided, they are rounded using int.

  • func – Function applied to the original data. The function ‘func’ must take a numpy array as its first argument, and support the axis keyword with the meaning of a numpy axis keyword (see the description of sum for an example.) The default value of ‘func’ is sum; using this causes superpixel to sum over (dimension[0], dimension[1]) pixels of the original map.

Returns:

out (GenericMap or subclass) – A new Map which has superpixels of the required size.

world_to_pixel(coordinate)#

Convert a world (data) coordinate to a pixel coordinate.

Parameters:

coordinate (SkyCoord or BaseCoordinateFrame) – The coordinate object to convert to pixel coordinates.

Returns:

  • x (Quantity) – Pixel coordinate on the CTYPE1 axis.

  • y (Quantity) – Pixel coordinate on the CTYPE2 axis.