Skip to content

Commit

Permalink
Remove unused functions.
Browse files Browse the repository at this point in the history
  • Loading branch information
DanRyanIrish committed Mar 23, 2018
1 parent cae5a0e commit 5ea7c04
Showing 1 changed file with 16 additions and 60 deletions.
76 changes: 16 additions & 60 deletions ndcube/mixins/sequence_plotting.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,8 @@ def plot(self, cubesequence, axes=None, plot_axis_indices=None,
naxis, plot_axis_indices, axes_coordinates, axes_units)
if naxis == 1:
# Make 1D line plot.
ax = self._plot_1D_sequence(cubesequence, x_axis_coordinates,
unit_x_axis, data_unit, **kwargs)
ax = self._plot_1D_sequence(cubesequence, axes_coordinates,
axes_units, data_unit, **kwargs)
else:
if len(plot_axis_indices) == 1:
# Since sequence has more than 1 dimension and number of plot axes is 1,
Expand Down Expand Up @@ -463,15 +463,20 @@ def _plot_2D_sequence(self, cubesequence, plot_axis_indices=None, axes_coordinat
fig, ax = plt.subplots(1, 1)
# Since we can't assume the x-axis will be uniform, create NonUniformImage
# axes and add it to the axes object.
im_ax = mpl.image.NonUniformImage(
ax, extent=(axes_coordinates[plot_axis_indices[0]][0], axes_coordinates[plot_axis_indices[0]][-1],
axes_coordinates[plot_axis_indices[1]][0], axes_coordinates[plot_axis_indices[1]][-1]),
**kwargs)
im_ax.set_data(axes_coordinates[plot_axis_indices[0]], axes_coordinates[plot_axis_indices[1]], data)
im_ax = mpl.image.NonUniformImage(ax,
extent=(axes_coordinates[plot_axis_indices[0]][0],
axes_coordinates[plot_axis_indices[0]][-1],
axes_coordinates[plot_axis_indices[1]][0],
axes_coordinates[plot_axis_indices[1]][-1]),
**kwargs)
im_ax.set_data(axes_coordinates[plot_axis_indices[0]],
axes_coordinates[plot_axis_indices[1]], data)
ax.add_image(im_ax)
# Set the limits, labels, etc. of the axes.
ax.set_xlim((axes_coordinates[plot_axis_indices[0]][0], axes_coordinates[plot_axis_indices[0]][-1]))
ax.set_ylim((axes_coordinates[plot_axis_indices[1]][0], axes_coordinates[plot_axis_indices[1]][-1]))
ax.set_xlim((axes_coordinates[plot_axis_indices[0]][0],
axes_coordinates[plot_axis_indices[0]][-1]))
ax.set_ylim((axes_coordinates[plot_axis_indices[1]][0],
axes_coordinates[plot_axis_indices[1]][-1]))
ax.set_xlabel(axes_labels[plot_axis_indices[0]])
ax.set_ylabel(axes_labels[plot_axis_indices[1]])

Expand Down Expand Up @@ -593,23 +598,6 @@ def _plot_3D_sequence_as_2Dimage(self, cubesequence, plot_axis_indices=None,
return ax


def _animate_ND_sequence(self, cubesequence, *args, **kwargs):
"""
Visualizes an NDCubeSequence of >2D NDCubes as 2D an animation with N-2 sliders.
"""
return ImageAnimatorNDCubeSequence(cubesequence, *args, **kwargs)

def _animate_ND_sequence_as_Nminus1Danimation(self, cubesequence, *args, **kwargs):
"""
Visualizes a common axis NDCubeSequence of >3D NDCubes as 2D animation with N-3 sliders.
Called if plot_as_cube=True.
"""
return ImageAnimatorCommonAxisNDCubeSequence(cubesequence, *args, **kwargs)


class ImageAnimatorNDCubeSequence(ImageAnimatorWCS):
"""
Animates N-dimensional data with the associated astropy WCS object.
Expand Down Expand Up @@ -1161,38 +1149,6 @@ def _determine_sequence_units(cubesequence_data, unit=None):
return sequence_units, unit


def _derive_1D_x_data(cubesequence, x_axis_values, unit_x_axis, sequence_is_1d=True):
# Derive x data from wcs is extra_coord not set.
if x_axis_values is None:
if sequence_is_1d:
# Since scalar NDCubes have no array/pixel indices, WCS translations don't work.
# Therefore x-axis values will be unitless sequence indices unless supplied by user
# or an extra coordinate is designated.
unit_x_axis = None
xdata = np.arange(int(cubesequence.dimensions[0].value))
default_xlabel = "{0} [{1}]".format(cubesequence.world_axis_physical_types[0],
unit_x_axis)
else:
if unit_x_axis is None:
unit_x_axis = np.asarray(cubesequence[0].wcs.wcs.cunit)[
np.invert(cubesequence[0].missing_axis)][0]
xdata = u.Quantity(np.concatenate([cube.axis_world_coords().to(unit_x_axis).value
for cube in cubesequence]), unit=unit_x_axis)
default_xlabel = "{0} [{1}]".format(cubesequence.cube_like_world_axis_physical_types[0],
unit_x_axis)
elif isinstance(x_axis_values, str):
# Else derive x-axis from extra coord.
if sequence_is_1d:
xdata = cubesequence.sequence_axis_extra_coords[x_axis_extra_coord]
else:
xdata = cubesequence.common_axis_extra_coords[x_axis_extra_coord]
if unit_x_axis is None and isinstance(xdata, u.Quantity):
unit_x_axis = xdata.unit
default_xlabel = "{0} [{1}]".format(x_axis_extra_coord, unit_x_axis)

return xdata, unit_x_axis, default_xlabel


def _make_1D_sequence_plot(xdata, ydata, yerror, unit_y_axis, default_xlabel, kwargs):
# Define plot settings if not set in kwargs.
xlabel = kwargs.pop("xlabel", default_xlabel)
Expand Down Expand Up @@ -1275,7 +1231,7 @@ def _prep_axes_kwargs(naxis, plot_axis_indices, axes_coordinates, axes_units):
# No need to check case where number of sequence dimensions is 1
# as plot_axis_indices is ignored in that case.
if naxis > 1:
len(plot_axis_indices) not in [1, 2]:
if len(plot_axis_indices) not in [1, 2]:
raise ValueError("plot_axis_indices can have at most length 2.")
# If convention of axes_coordinates and axes_units being length of
# plot_axis_index is being used, convert to convention where their
Expand All @@ -1294,7 +1250,7 @@ def _prep_axes_kwargs(naxis, plot_axis_indices, axes_coordinates, axes_units):
if axes_coordinates is not None:
# Now axes_coordinates have been converted to a consistent convention,
# ensure their length equals the number of sequence dimensions.
len(axes_coordinates) != naxis:
if len(axes_coordinates) != naxis:
raise ValueError("length of axes_coordinates must be {0}.".format(naxis))
# Ensure all elements in axes_coordinates are of correct types.
ax_coord_types = (u.Quantity, np.ndarray, str)
Expand Down

0 comments on commit 5ea7c04

Please sign in to comment.