make_fitswcs_header#

sunpy.map.header_helper.make_fitswcs_header(data, coordinate, reference_pixel: Unit('pix') = None, scale: Unit('arcsec / pix') = None, rotation_angle: Unit('deg') = None, rotation_matrix=None, instrument=None, telescope=None, observatory=None, detector=None, wavelength: Unit('Angstrom') = None, exposure: Unit('s') = None, projection_code='TAN', unit=None)[source]#

Function to create a FITS-WCS header from a coordinate object (SkyCoord) that is required to create a GenericMap.

Parameters:
  • data (ndarray, Quantity, or tuple) – Array data of Map for which a header is required, or the shape of the data array (in numpy order, i.e. (y_size, x_size)).

  • coordinate (SkyCoord or BaseCoordinateFrame) – The coordinate of the reference pixel.

  • reference_pixel (Quantity, optional) – Reference pixel along each axis. These are expected to be Cartestian ordered, i.e the first index is the x axis, second index is the y axis. Defaults to the center of data array, (data.shape[1] - 1)/2., (data.shape[0] - 1)/2.), this argument is zero indexed (Python convention) not 1 indexed (FITS convention).

  • scale (Quantity of size 2, optional) – Pixel scaling along x and y axis (i.e. the spatial scale of the pixels (dx, dy)). These are expected to be Cartestian ordered, i.e [dx, dy]. Defaults to ([1., 1.] arcsec/pixel).

  • rotation_angle (Quantity, optional) – Coordinate system rotation angle, will be converted to a rotation matrix and stored in the PCi_j matrix. Can not be specified with rotation_matrix. Defaults to no rotation.

  • rotation_matrix (ndarray of dimensions 2x2, optional) – Matrix describing the rotation required to align solar North with the top of the image in FITS PCi_j convention. Can not be specified with rotation_angle.

  • instrument (str, optional) – Name of the instrument of the observation.

  • telescope (str, optional) – Name of the telescope of the observation.

  • observatory (str, optional) – Name of the observatory of the observation.

  • detector (str, optional) – Name of the detector of the observation.

  • wavelength (Quantity, optional) – Wavelength of the observation as an astropy quantity, e.g. 171*u.angstrom. From this keyword, the meta keywords wavelnth and waveunit will be populated.

  • exposure (Quantity, optional) – Exposure time of the observation

  • projection_code (str, optional) – The FITS standard projection code for the new header.

  • unit (Unit, optional) – Units of the array data of the Map. This will populate the the 'bunit' meta keyword. If data is a Quantity, the unit specified here will take precedence over the unit information attached to data.

Returns:

MetaDict – The header information required for making a sunpy.map.GenericMap.

Notes

The observer coordinate is taken from the observer property of the reference_pixel argument.

Examples

>>> import sunpy.map
>>> from sunpy.coordinates import frames
>>> from astropy.coordinates import SkyCoord
>>> import astropy.units as u
>>> import numpy as np
>>> data = np.random.rand(1024, 1024)
>>> my_coord = SkyCoord(0*u.arcsec, 0*u.arcsec, obstime="2017-08-01",
...                     observer = 'earth', frame=frames.Helioprojective)
>>> my_header = sunpy.map.make_fitswcs_header(data, my_coord)
>>> my_map = sunpy.map.Map(data, my_header)