MapSequence#

class sunpy.map.MapSequence(*args, sortby='date', derotate=False, **kwargs)[source]#

Bases: object

A series of Maps in a single object.

Parameters:
  • args (list) – A list of Map instances

  • sortby ({ “date” | None}) – Method by which the MapSequence should be sorted along the z-axis. Defaults to sorting by: “date” and is the only supported sorting strategy. Passing None will disable sorting.

  • derotate (bool) – Apply a derotation to the data. Default to False.

maps#

This attribute holds the list of Map instances obtained from parameter args.

Type:

list

Notes

To coalign a mapsequence so that solar features remain on the same pixels, please see the “Coalignment of MapSequences” note below.

Examples

>>> import sunpy.map
>>> mapsequence = sunpy.map.Map('images/*.fits', sequence=True)   

MapSequences can be co-aligned using the routines in sunkit_image.coalignment.

Methods Summary

all_maps_same_shape()

Tests if all the maps have the same number pixels in the x and y directions.

all_meta()

Return all the meta objects as a list.

as_array()

If all the map shapes are the same, their image data is rendered into the appropriate numpy object.

at_least_one_map_has_mask()

Tests if at least one map has a mask.

peek([resample])

A animation plotting routine that animates each element in the MapSequence

plot([axes, resample, annotate, interval, ...])

A animation plotting routine that animates each element in the MapSequence

quicklook()

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

save(filepath[, filetype])

Saves the sequence, with one file per map.

Methods Documentation

all_maps_same_shape()[source]#

Tests if all the maps have the same number pixels in the x and y directions.

all_meta()[source]#

Return all the meta objects as a list.

as_array()[source]#

If all the map shapes are the same, their image data is rendered into the appropriate numpy object. If none of the maps have masks, then the data is returned as a (ny, nx, nt) ndarray. If all the maps have masks, then the data is returned as a (ny, nx, nt) masked array with all the masks copied from each map. If only some of the maps have masked then the data is returned as a (ny, nx, nt) masked array, with masks copied from maps as appropriately; maps that do not have a mask are supplied with a mask that is full of False entries. If all the map shapes are not the same, a ValueError is thrown.

at_least_one_map_has_mask()[source]#

Tests if at least one map has a mask.

peek(resample=None, **kwargs)[source]#

A animation plotting routine that animates each element in the MapSequence

Parameters:
  • fig (matplotlib.figure.Figure) – Figure to use to create the explorer

  • resample (list) – Draws the map at a lower resolution to increase the speed of animation. Specify a list as a fraction i.e. [0.25, 0.25] to plot at 1/4 resolution. [Note: this will only work where the map arrays are the same size]

  • annotate (bool) – Annotate the figure with scale and titles

  • interval (int) – Animation interval in ms

  • colorbar (bool) – Plot colorbar

  • plot_function (function) – A function to call to overplot extra items on the map plot. For more information see sunpy.visualization.animator.MapSequenceAnimator.

Returns:

mapsequenceanim (sunpy.visualization.animator.MapSequenceAnimator)

Examples

>>> import matplotlib.pyplot as plt
>>> from sunpy.map import Map
>>> sequence = Map(files, sequence=True)   
>>> ani = sequence.peek(colorbar=True)   
>>> plt.show()   

Plot the map at 1/2 original resolution

>>> sequence = Map(files, sequence=True)   
>>> ani = sequence.peek(resample=[0.5, 0.5], colorbar=True)   
>>> plt.show()   

Plot the map with the limb at each time step

>>> def myplot(fig, ax, sunpy_map):
...    p = sunpy_map.draw_limb()
...    return p
>>> sequence = Map(files, sequence=True)   
>>> ani = sequence.peek(plot_function=myplot)   
>>> plt.show()   

Decide you want an animation:

>>> sequence = Map(files, sequence=True)   
>>> ani = sequence.peek(resample=[0.5, 0.5], colorbar=True)   
>>> mplani = ani.get_animation()   
plot(axes=None, resample=None, annotate=True, interval=200, plot_function=None, **kwargs)[source]#

A animation plotting routine that animates each element in the MapSequence

Parameters:
  • axes (matplotlib.axes.Axes) – axes to plot the animation on, if none uses current axes

  • resample (list) – Draws the map at a lower resolution to increase the speed of animation. Specify a list as a fraction i.e. [0.25, 0.25] to plot at 1/4 resolution. [Note: this will only work where the map arrays are the same size]

  • annotate (bool) – Annotate the figure with scale and titles

  • interval (int) – Animation interval in ms

  • plot_function (function) – A function to be called as each map is plotted. For more information see sunpy.visualization.animator.MapSequenceAnimator.

  • norm (matplotlib.colors.Normalize or str) – Normalization used in scaling the plot. This will override the predefined value in plot_settings['norm'].

  • cmap (matplotlib.colors.Colormap or str) – Color map to be used in coloring the plot. This will override the predefined value in plot_settings['cmap'].

Returns:

matplotlib.animation.FuncAnimation – A FuncAnimation instance.

See also

None

Examples

>>> import matplotlib.pyplot as plt
>>> import matplotlib.animation as animation
>>> from sunpy.map import Map
>>> sequence = Map(files, sequence=True)   
>>> ani = sequence.plot(colorbar=True)   
>>> plt.show()   

Plot the map at 1/2 original resolution

>>> sequence = Map(files, sequence=True)   
>>> ani = sequence.plot(resample=[0.5, 0.5], colorbar=True)   
>>> plt.show()   

Save an animation of the MapSequence

>>> sequence = Map(res, sequence=True)   
>>> ani = sequence.plot()   
>>> Writer = animation.writers['ffmpeg']   
>>> writer = Writer(fps=10, metadata=dict(artist='SunPy'), bitrate=1800)   
>>> ani.save('mapsequence_animation.mp4', writer=writer)   

Save an animation with the limb at each time step

>>> def myplot(fig, ax, sunpy_map):
...    p = sunpy_map.draw_limb()
...    return p
>>> sequence = Map(files, sequence=True)   
>>> ani = sequence.peek(plot_function=myplot)   
>>> plt.show()   
quicklook()[source]#

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

Click on the ← and → buttons to step through the individual maps.

Notes

The image colormap uses histogram equalization.

Interactive elements require Javascript support to be enabled in the web browser.

Examples

>>> from sunpy.map import Map
>>> import sunpy.data.sample  
>>> seq = Map(sunpy.data.sample.HMI_LOS_IMAGE,
...           sunpy.data.sample.AIA_1600_IMAGE,
...           sunpy.data.sample.EIT_195_IMAGE,
...           sequence=True)  
>>> seq.quicklook()  

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

<sunpy.map.mapsequence.MapSequence object at 0x7f2a4b17dbd0>
MapSequence of 3 elements, with maps from HMIMap, EITMap, AIAMap
Map at index 0
<sunpy.map.sources.sdo.HMIMap object at 0x7f2a4b08ecb0>
Observatory SDO
Instrument HMI FRONT2
Detector HMI
Measurement magnetogram
Wavelength 6173.0
Observation Date 2011-06-07 06:32:11
Exposure Time Unknown
Dimension [1024. 1024.] pix
Coordinate System helioprojective
Scale [2.01714 2.01714] arcsec / pix
Reference Pixel [511.5 511.5] pix
Reference Coord [-4.23431983 -0.12852412] arcsec
Image colormap uses histogram equalization
Click on the image to toggle between units
Bad pixels are shown in red: 321587 NaN
<sunpy.map.sources.sdo.AIAMap object at 0x7f2a4b17dcf0>
Observatory SDO
Instrument AIA 3
Detector AIA
Measurement 1600.0 Angstrom
Wavelength 1600.0 Angstrom
Observation Date 2011-06-07 06:33:05
Exposure Time 2.901358 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
<sunpy.map.sources.soho.EITMap object at 0x7f2a4b08f790>
Observatory SOHO
Instrument EIT
Detector EIT
Measurement 195.0 Angstrom
Wavelength 195.0 Angstrom
Observation Date 2011-06-07 20:37:52
Exposure Time 12.594 s
Dimension [1024. 1024.] pix
Coordinate System helioprojective
Scale [2.63 2.63] arcsec / pix
Reference Pixel [509.91 520.06] pix
Reference Coord [0. 0.] arcsec
Image colormap uses histogram equalization
Click on the image to toggle between units
save(filepath, filetype='auto', **kwargs)[source]#

Saves the sequence, with one file per map.

Currently SunPy can save files only in the FITS format.

Parameters:
  • filepath (str) – Location to save the file(s) to. The string must contain "{index}", which will be populated with the corresponding index number for each map. Format specifiers (e.g., "{index:03}") can be used.

  • filetype (str) – ‘auto’ or any supported file extension.

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

Examples

>>> from sunpy.map import Map
>>> import sunpy.data.sample 
>>> smap = Map(sunpy.data.sample.HMI_LOS_IMAGE,
...            sunpy.data.sample.AIA_1600_IMAGE,
...            sequence=True)  
>>> smap.save('map_{index:03}.fits')