diff --git a/ndcube/tests/test_ndcube_slice_and_crop.py b/ndcube/tests/test_ndcube_slice_and_crop.py index 30cc75eaf..cb4cb4c07 100644 --- a/ndcube/tests/test_ndcube_slice_and_crop.py +++ b/ndcube/tests/test_ndcube_slice_and_crop.py @@ -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 @@ -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")