Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 20 additions & 1 deletion ndcube/tests/test_ndcube_slice_and_crop.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
from astropy.units import UnitsError
from astropy.wcs import WCS
from astropy.wcs.utils import wcs_to_celestial_frame
from astropy.wcs.wcsapi import BaseHighLevelWCS
from astropy.wcs.wcsapi import BaseHighLevelWCS, HighLevelWCSWrapper
from astropy.wcs.wcsapi.wrappers import SlicedLowLevelWCS

from ndcube import ExtraCoords, NDCube, NDMeta
Expand Down Expand Up @@ -441,6 +441,25 @@ def test_crop_by_extra_coords_values(ndcube_3d_ln_lt_l_ec_time):
helpers.assert_cubes_equal(output, expected)


def test_crop_with_extra_coords_cube_wcs(ndcube_3d_ln_lt_l_ec_time):
cube = ndcube_3d_ln_lt_l_ec_time
# ['spectral_0', 'celestial_0', 'temporal_1', 'PIXEL_1']
lower_corner = (Time("2000-01-01T15:00:00", scale="utc", format="fits"), None, None)
upper_corner = (Time("2000-01-01T20:00:00", scale="utc", format="fits"), None, None)
output = cube.crop(lower_corner, upper_corner, wcs=HighLevelWCSWrapper(cube.extra_coords.cube_wcs))
expected = cube[0]
helpers.assert_cubes_equal(output, expected)


def test_crop_by_values_with_extra_coords_cube_wcs(ndcube_3d_ln_lt_l_ec_time):
cube = ndcube_3d_ln_lt_l_ec_time
lower_corner = (3 * 60 * 60 * u.s, None, None)
upper_corner = (8 * 60 * 60 * u.s, None, None)
output = cube.crop_by_values(lower_corner, upper_corner, wcs=HighLevelWCSWrapper(cube.extra_coords.cube_wcs))
expected = cube[0]
helpers.assert_cubes_equal(output, expected)


def test_crop_by_extra_coords_all_axes_with_coord(ndcube_3d_ln_lt_l_ec_all_axes):
cube = ndcube_3d_ln_lt_l_ec_all_axes
interval0 = Time(["2000-01-01T15:00:00", "2000-01-01T20:00:00"], scale="utc", format="fits")
Expand Down