From 91a113e25bc4f654f77886757d44e3ba91dbb48f Mon Sep 17 00:00:00 2001 From: Roy Smart Date: Mon, 29 Jan 2024 10:28:16 -0700 Subject: [PATCH] Added `iris.planning.num_repeats()` function. --- iris/__init__.py | 4 +++- iris/planning.py | 23 +++++++++++++++++++++++ 2 files changed, 26 insertions(+), 1 deletion(-) create mode 100644 iris/planning.py diff --git a/iris/__init__.py b/iris/__init__.py index ef0c456..85a91bf 100644 --- a/iris/__init__.py +++ b/iris/__init__.py @@ -1,3 +1,5 @@ """ Python package for analyzing observations from the Interface Region Imaging Spectrograph -""" \ No newline at end of file +""" + +from . import planning diff --git a/iris/planning.py b/iris/planning.py new file mode 100644 index 0000000..fea6e0b --- /dev/null +++ b/iris/planning.py @@ -0,0 +1,23 @@ +import astropy.units as u +import astropy.time + +__all__ = [ + "num_repeats", +] + + +def num_repeats( + time_start: str | astropy.time.Time, + time_stop: str | astropy.time.Time, + time_raster: u.Quantity, + time_slew: u.Quantity = 10 * u.min, +): + if not isinstance(time_start, astropy.time.Time): + time_start = astropy.time.Time(time_start) + if not isinstance(time_stop, astropy.time.Time): + time_stop = astropy.time.Time(time_stop) + + result = (time_stop - time_start - time_slew) / time_raster + result = result.to(u.dimensionless_unscaled) + + return result