MapSequence#
- class sunpy.map.MapSequence[source]#
Bases:
objectA series of Maps in a single object.
- Parameters:
Notes
To coalign a mapsequence so that solar features remain on the same pixels, please see the “Coalignment of MapSequences” note below.
Note
The individual components of a
MapSequencecan be coaligned using the functions insunkit_image.coalignmentor using thereproject_tomethod.Examples
>>> import sunpy.map >>> mapsequence = sunpy.map.Map('images/*.fits', sequence=True)
Creates a new Map instance
Attributes Summary
True if the data array of each map has the same shape.
Data array of shape
(N_y, N_x, N_t)where(N_y,N_x)is the shape of each individual map andN_tis the number of maps.Combined mask with same shape as
datafor all maps in the sequence.Metadata objects of each map as a list.
Methods Summary
peek(**kwargs)A animation plotting routine that animates each element in the MapSequence
plot([axes, annotate, interval, ...])A animation plotting routine that animates each element in the MapSequence
Display a quicklook summary of the MapSequence instance using the default web browser.
save(filepath[, filetype])Saves the sequence as one map for FITS file.
Attributes Documentation
- all_same_shape#
True if the data array of each map has the same shape.
- data#
Data array of shape
(N_y, N_x, N_t)where(N_y,N_x)is the shape of each individual map andN_tis the number of maps.Note
If all maps do not have the same shape, a
ValueErroris raised.
- mask#
Combined mask with same shape as
datafor all maps in the sequence.If no map in the sequence has a mask, this returns None. If at least one map in the sequence has a mask, the layers corresponding to those maps without a mask will be all
False.
- meta#
Metadata objects of each map as a list.
Methods Documentation
- peek(**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
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 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(colorbar=True) >>> mplani = ani.get_animation()
- plot(
- axes=None,
- annotate=True,
- interval=200,
- plot_function=None,
- clip_interval=None,
- **kwargs,
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
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.clip_interval (two-element
Quantity, optional) – If provided, the data will be clipped to the percentile interval bounded by the two numbers.norm (
matplotlib.colors.Normalizeorstr) – Normalization used in scaling the plot. This will override the predefined value inplot_settings['norm'].cmap (
matplotlib.colors.Colormaporstr) – Color map to be used in coloring the plot. This will override the predefined value inplot_settings['cmap'].
- Returns:
matplotlib.animation.FuncAnimation– A FuncAnimation instance.
See also
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()
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 0x7c1392d35550> MapSequence of 3 elements, with maps from EITMap, AIAMap, HMIMap
- save(filepath, filetype='auto', **kwargs)[source]#
Saves the sequence as one map for FITS file.
- Parameters:
filepath (
str) – Template string specifying the file to which each map is saved. 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
save.
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')