From eed67f3c5c3d38e5e510dccf58d1bf0eaccaf18c Mon Sep 17 00:00:00 2001 From: DanRyanIrish Date: Mon, 30 Jun 2025 14:40:40 +0100 Subject: [PATCH] Add properties giving order of types in inputs to NDCube.crop and crop_by_values. --- ndcube/ndcube.py | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/ndcube/ndcube.py b/ndcube/ndcube.py index c32c637af..d5ce104d7 100644 --- a/ndcube/ndcube.py +++ b/ndcube/ndcube.py @@ -691,6 +691,26 @@ def _get_crop_by_values_item(self, *points, units=None, wcs=None, keepdims=False return utils.cube.get_crop_item_from_points(points, wcs, True, keepdims=keepdims) + @property + def crop_input_types_order(self): + """ + Returns types and order of high-level coordinate object that must be input to .crop() + + Note that any of these can be be replaced with None when input to crop() if + cropping along the axis/axes of that world type in not desired. + """ + return tuple(v[0] for v in self.wcs.world_axis_object_classes.values()) + + @property + def crop_by_values_input_units_order(self): + """ + Returns units of inputs to .crop_by_values() and their required order. + + crop_by_values() also accepts equivalent units so long as they are + in the same order as returned here. + """ + return tuple(self.wcs.world_axis_unit) + def __str__(self): return textwrap.dedent(f"""\ NDCube