MapCube

class sunpy.map.MapCube(*args, **kwargs)[source] [edit on github]

Bases: object

A series of spatially aligned Maps.

Parameters:
  • args ({List}) – A list of Map instances
  • sortby ({"date", None}) – Method by which the MapCube should be sorted along the z-axis.
  • derotate ({None}) – Apply a derotation to the data (Not Implemented)
  • coalign a mapcube so that solar features remain on the same pixels, (To) –
  • see the "Coalignment of mapcubes" note below. (please) –
maps

{List} – This attribute holds the list of Map instances obtained from parameter args.

Examples

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

Mapcubes can be co-aligned using the routines in sunpy.image.coalignment.

Creates a new Map instance

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
plot([axes, resample, annotate, interval, …]) A animation plotting routine that animates each element in the

Methods Documentation

all_maps_same_shape()[source] [edit on github]

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

all_meta()[source] [edit on github]

Return all the meta objects as a list.

as_array()[source] [edit on github]

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] [edit on github]

Tests if at least one map has a mask.

peek(resample=None, **kwargs)[source] [edit on github]

A animation plotting routine that animates each element in the MapCube

Parameters:
  • fig (mpl.figure) – Figure to use to create the explorer
  • resample (list or False) – 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.MapCubeAnimator.
Returns:

mapcubeanim (sunpy.visualization.MapCubeAnimator) – A mapcube animator instance.

Examples

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

Plot the map at 1/2 original resolution

>>> cube = Map(files, cube=True)   
>>> ani = cube.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
>>> cube = Map(files, cube=True)   
>>> ani = cube.peek(plot_function=myplot)   
>>> plt.show()   

Decide you want an animation:

>>> cube = Map(files, cube=True)   
>>> ani = cube.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] [edit on github]

A animation plotting routine that animates each element in the MapCube

Parameters:
  • gamma (float) – Gamma value to use for the color map
  • axes (mpl axes) – axes to plot the animation on, if none uses current axes
  • resample (list or False) – 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. Any variables returned from the function will have their remove() method called at the start of the next frame so that they are removed from the plot.

Examples

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

Plot the map at 1/2 original resolution

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

Save an animation of the MapCube

>>> cube = Map(res, cube=True)   
>>> ani = cube.plot()   
>>> Writer = animation.writers['ffmpeg']   
>>> writer = Writer(fps=10, metadata=dict(artist='SunPy'), bitrate=1800)   
>>> ani.save('mapcube_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
>>> cube = Map(files, cube=True)   
>>> ani = cube.peek(plot_function=myplot)   
>>> plt.show()