Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
The unit of x axis.
unit_y_axis: `astropy.units.Unit`
The unit of y axis.
axis_ranges: list of physical coordinates for array or None
If None array indices will be used for all axes.
If a list it should contain one element for each axis of the numpy array.
For the image axes a [min, max] pair should be specified which will be
passed to :func:`matplotlib.pyplot.imshow` as extent.
For the slider axes a [min, max] pair can be specified or an array the
same length as the axis which will provide all values for that slider.
If None is specified for an axis then the array indices will be used
for that axis.
"""
i = ImageAnimatorWCS(self.data, wcs=self.axes_wcs, *args, **kwargs)
return i
self.cumul_cube_lengths = np.cumsum(np.ones(len(self.sequence)))
data_concat = np.stack([cube.data for cube in seq.data])
# Add dimensions of length 1 of concatenated data array
# shape for an missing axes.
if seq[0].wcs.naxis != len(seq.dimensions) - 1:
new_shape = list(data_concat.shape)
for i in np.arange(seq[0].wcs.naxis)[seq[0].missing_axis[::-1]]:
new_shape.insert(i+1, 1)
data_concat = data_concat.reshape(new_shape)
# Add dummy axis to WCS object to represent sequence axis.
new_wcs = utils.wcs.append_sequence_axis_to_wcs(wcs)
super(ImageAnimatorNDCubeSequence, self).__init__(data_concat, wcs=new_wcs, **kwargs)
class ImageAnimatorCommonAxisNDCubeSequence(ImageAnimatorWCS):
"""
Animates N-dimensional data with the associated astropy WCS object.
The following keyboard shortcuts are defined in the viewer:
left': previous step on active slider
right': next step on active slider
top': change the active slider up one
bottom': change the active slider down one
'p': play/pause active slider
This viewer can have user defined buttons added by specifying the labels
and functions called when those buttons are clicked as keyword arguments.
Parameters
----------
unit_y_axis: `astropy.units.Unit`
The unit of y axis.
axis_ranges: `list` of physical coordinates for array or None
If None array indices will be used for all axes.
If a list it should contain one element for each axis of the numpy array.
For the image axes a [min, max] pair should be specified which will be
passed to :func:`matplotlib.pyplot.imshow` as extent.
For the slider axes a [min, max] pair can be specified or an array the
same length as the axis which will provide all values for that slider.
If None is specified for an axis then the array indices will be used
for that axis.
"""
if not image_axes:
image_axes = [-1, -2]
i = ImageAnimatorWCS(cube.data, wcs=cube.wcs, image_axes=image_axes,
unit_x_axis=unit_x_axis, unit_y_axis=unit_y_axis,
axis_ranges=axis_ranges, **kwargs)
return i
import numpy as np
from sunpy.visualization.imageanimator import ImageAnimatorWCS
from ndcube import utils
class ImageAnimatorNDCubeSequence(ImageAnimatorWCS):
"""
Animates N-dimensional data with the associated astropy WCS object.
The following keyboard shortcuts are defined in the viewer:
left': previous step on active slider
right': next step on active slider
top': change the active slider up one
bottom': change the active slider down one
'p': play/pause active slider
This viewer can have user defined buttons added by specifying the labels
and functions called when those buttons are clicked as keyword arguments.
Parameters
----------