From 8a31deef75ee27e8387706ffb520be8d0dc8ba6b Mon Sep 17 00:00:00 2001 From: Wolfgang Kastaun <wolfgang.kastaun@aei.mpg.de> Date: Tue, 14 Jan 2025 18:59:16 +0100 Subject: [PATCH] Add separate instrument parameter for limits on interspacecraft delays Moved those limits out of the interpolation parameter tuple. --- lisainstrument/instrument.py | 37 +++++++++++++++++++++++------------- 1 file changed, 24 insertions(+), 13 deletions(-) diff --git a/lisainstrument/instrument.py b/lisainstrument/instrument.py index 301cc83..9c96669 100755 --- a/lisainstrument/instrument.py +++ b/lisainstrument/instrument.py @@ -66,9 +66,8 @@ class Instrument: if ``orbit_dataset`` is ``'tps/ppr'``, we try to read link responses as functions of the TPS instead of link responses in the TCB (fallback behavior) interpolation: interpolation method and parameters; - use a tuple ('lagrange', order, min_delay_time, max_delay_time) with `order` the odd - Lagrange interpolation order; min_delay_time and max_delay_time are the minimum and - maximum delays that can occur in the entire simulation. + use a tuple ('lagrange', order) with `order` the Lagrange interpolation + order (must be odd); or None for no interpolation. glitches: path to glitch file, or dictionary of glitch signals per injection point lock: pre-defined laser locking configuration (e.g., 'N1-12' is configuration N1 with 12 as primary laser), or 'six' for 6 lasers locked on cavities, or a dictionary of locking @@ -132,6 +131,8 @@ class Instrument: electro_delays: tuple (isi, tmi, rfi) of dictionaries for electronic delays [s] concurrent (bool): whether to use multiprocessing chunking_size (int): size of chunks when using dask + delay_isc_min (float): minimum interspacecraft delay that can occur in the simulation + delay_isc_max (float): maximum interspacecraft delay that can occur in the simulation """ # pylint: disable=attribute-defined-outside-init @@ -227,7 +228,7 @@ class Instrument: orbits="static", orbit_dataset="tps/ppr", gws=None, - interpolation=("lagrange", 31, 6.0, 12.0), + interpolation=("lagrange", 31), # Artifacts glitches=None, # Laser locking and frequency plan @@ -284,6 +285,8 @@ class Instrument: # Concurrency concurrent=False, chunking_size=256, + delay_isc_min: float = 6.0, + delay_isc_max: float = 12.0, ) -> None: # pylint: disable=too-many-arguments,too-many-positional-arguments,too-many-statements,too-many-locals,too-many-branches logger.info("Initializing instrumental simulation") @@ -617,7 +620,7 @@ class Instrument: # Interpolation and antialiasing filter self.init_interpolation(interpolation) - self.init_delays(interpolation) + self.init_delays(interpolation, delay_isc_min, delay_isc_max) self.init_aafilter(aafilter) # Electronic delays @@ -640,7 +643,9 @@ class Instrument: """ return numpyfy_dask_multi(op, chunks=self.chunking_size) - def init_delays(self, interpolation): + def init_delays( + self, interpolation: None | tuple, delay_isc_min: float, delay_isc_max: float + ) -> None: """Initialize or design the interpolation functions for the delays We support no interpolation or Lagrange interpolation. @@ -667,18 +672,23 @@ class Instrument: Args: interpolation: see `interpolation` docstring in `__init__()` + delay_isc_min: Minimum allowed interspacecraft delay [s] + delay_isc_max: Maximum allowed interspacecraft delay [s] """ match interpolation: case None: self._delay_dynamic = lambda x, _: x self._delay_const = self._delay_dynamic - case ("lagrange", int(order), float(min_delay_time), float(max_delay_time)): + case ( + "lagrange", + int(order), + ): # ~ self.interpolation_order = order op_dyn_ = make_dynamic_shift_lagrange_dask( order, - min_delay_time * self.physics_fs, - max_delay_time * self.physics_fs, + delay_isc_min * self.physics_fs, + delay_isc_max * self.physics_fs, ShiftBC.ZEROPAD, ShiftBC.ZEROPAD, ) @@ -691,14 +701,12 @@ class Instrument: case ( "lagrange_dsp", int(order), - float(min_delay_time), - float(max_delay_time), ): # ~ self.interpolation_order = order op_dyn_ = make_dynamic_shift_dsp_dask( order, - min_delay_time * self.physics_fs, - max_delay_time * self.physics_fs, + delay_isc_min * self.physics_fs, + delay_isc_max * self.physics_fs, ShiftBC.ZEROPAD, ShiftBC.ZEROPAD, ) @@ -720,6 +728,9 @@ class Instrument: msg = f"Invalid interpolation parameters {interpolation}" raise RuntimeError(msg) + # ~ self.delay_isc_min = delay_isc_min + # ~ self.delay_isc_max = delay_isc_max + def init_interpolation(self, interpolation): """Initialize or design the interpolation function. -- GitLab