diff --git a/lisainstrument/instrument.py b/lisainstrument/instrument.py index 45953edbf5af3066cea68e3693f7be3d1b616b0f..737d713b8a80e4932e6f391db729f3fe4bfe9915 100755 --- a/lisainstrument/instrument.py +++ b/lisainstrument/instrument.py @@ -97,7 +97,9 @@ class Instrument: # Pseudo-ranging ranging_biases=0, ranging_asds=3E-9, prn_ambiguity=None, # Electronic delays - electro_delays=(0, 0, 0)): + electro_delays=(0, 0, 0), + # Concurrency + concurrent=False): """Initialize an instrumental simulation. Args: @@ -179,12 +181,14 @@ class Instrument: prn_ambiguity: distance after which PRN code repeats itself [m] (reasonable value is 300 km), None or 0 for no ambiguities electro_delays: tuple (isi, tmi, rfi) of dictionaries for electronic delays [s] + concurrent (bool): whether to use multiprocessing """ # pylint: disable=too-many-arguments,too-many-statements,too-many-locals,too-many-branches logger.info("Initializing instrumental simulation") self.git_url = 'https://gitlab.in2p3.fr/lisa-simulation/instrument' self.version = importlib_metadata.version('lisainstrument') self.simulated = False + self.concurrent = bool(concurrent) # Check orbit dataset if orbit_dataset not in ['tcb/ltt', 'tps/ppr']: @@ -951,7 +955,7 @@ class Instrument: self.distant_carrier_offsets = \ -self.d_pprs * self.central_freq \ + (1 - self.d_pprs) * self.local_carrier_offsets.distant() \ - .transformed(lambda mosa, x: self.interpolate(x, -self.pprs[mosa]), concurrent=True) + .transformed(lambda mosa, x: self.interpolate(x, -self.pprs[mosa]), concurrent=self.concurrent) logger.debug("Propagating carrier fluctuations to distant MOSAs") carrier_fluctuations = \ @@ -959,7 +963,7 @@ class Instrument: - (self.central_freq + self.local_carrier_offsets) * self.distant_ttls / c propagated_carrier_fluctuations = \ (1 - self.d_pprs) * carrier_fluctuations.distant() \ - .transformed(lambda mosa, x: self.interpolate(x, -self.pprs[mosa]), concurrent=True) + .transformed(lambda mosa, x: self.interpolate(x, -self.pprs[mosa]), concurrent=self.concurrent) self.distant_carrier_fluctuations = \ propagated_carrier_fluctuations \ - (self.central_freq + self.local_carrier_offsets) * self.gws \ @@ -969,7 +973,7 @@ class Instrument: self.distant_usb_offsets = \ -self.d_pprs * self.central_freq \ + (1 - self.d_pprs) * self.local_usb_offsets.distant() \ - .transformed(lambda mosa, x: self.interpolate(x, -self.pprs[mosa]), concurrent=True) + .transformed(lambda mosa, x: self.interpolate(x, -self.pprs[mosa]), concurrent=self.concurrent) logger.debug("Propagating upper sideband fluctuations to distant MOSAs") usb_fluctuations = \ @@ -977,7 +981,7 @@ class Instrument: - (self.central_freq + self.local_usb_offsets) * self.distant_ttls / c propagated_usb_fluctuations = \ (1 - self.d_pprs) * usb_fluctuations.distant() \ - .transformed(lambda mosa, x: self.interpolate(x, -self.pprs[mosa]), concurrent=True) + .transformed(lambda mosa, x: self.interpolate(x, -self.pprs[mosa]), concurrent=self.concurrent) self.distant_usb_fluctuations = \ propagated_usb_fluctuations \ - (self.central_freq + self.local_usb_offsets) * self.gws \ @@ -1195,7 +1199,7 @@ class Instrument: logger.info("Inverting THE with respect to TPS") self.tps_wrt_the = self.the_wrt_tps_local \ - .transformed(lambda sc, x: self.invert_the_wrt_tps(x, sc), concurrent=True) + .transformed(lambda sc, x: self.invert_the_wrt_tps(x, sc), concurrent=self.concurrent) self.timestamped = \ lambda mosa, x: self.interpolate(x, -self.tps_wrt_the.for_each_mosa()[mosa]) @@ -1205,85 +1209,85 @@ class Instrument: logger.debug("Sampling inter-spacecraft carrier beatnote fluctuations to THE grid") self.the_isi_carrier_offsets = ( self.tps_isi_carrier_offsets / (1 + self.clock_noise_offsets) - ).transformed(self.timestamped, concurrent=True) + ).transformed(self.timestamped, concurrent=self.concurrent) logger.debug("Sampling inter-spacecraft carrier beatnote fluctuations to THE grid") self.the_isi_carrier_fluctuations = ( self.tps_isi_carrier_fluctuations / (1 + self.clock_noise_offsets) - self.tps_isi_carrier_offsets * self.clock_noise_fluctuations / (1 + self.clock_noise_offsets)**2 - ).transformed(self.timestamped, concurrent=True) + ).transformed(self.timestamped, concurrent=self.concurrent) logger.debug("Sampling inter-spacecraft upper sideband beatnote offsets to THE grid") self.the_isi_usb_offsets = ( self.tps_isi_usb_offsets / (1 + self.clock_noise_offsets) - ).transformed(self.timestamped, concurrent=True) + ).transformed(self.timestamped, concurrent=self.concurrent) logger.debug("Sampling inter-spacecraft upper sideband beatnote fluctuations to THE grid") self.the_isi_usb_fluctuations = ( self.tps_isi_usb_fluctuations / (1 + self.clock_noise_offsets) - self.tps_isi_usb_offsets * self.clock_noise_fluctuations / (1 + self.clock_noise_offsets)**2 - ).transformed(self.timestamped, concurrent=True) + ).transformed(self.timestamped, concurrent=self.concurrent) logger.debug("Sampling inter-spacecraft DWS measurements to THE grid") - self.the_isi_dws_phis = self.tps_isi_dws_phis.transformed(self.timestamped, concurrent=True) - self.the_isi_dws_etas = self.tps_isi_dws_etas.transformed(self.timestamped, concurrent=True) + self.the_isi_dws_phis = self.tps_isi_dws_phis.transformed(self.timestamped, concurrent=self.concurrent) + self.the_isi_dws_etas = self.tps_isi_dws_etas.transformed(self.timestamped, concurrent=self.concurrent) logger.info("Sampling measured pseudo-ranges to THE grid") - self.the_mprs = self.tps_mprs.transformed(self.timestamped, concurrent=True) + self.the_mprs = self.tps_mprs.transformed(self.timestamped, concurrent=self.concurrent) logger.info("Sampling test-mass beatnotes to THE grid") logger.debug("Sampling test-mass carrier beatnote offsets to THE grid") self.the_tmi_carrier_offsets = ( self.tps_tmi_carrier_offsets / (1 + self.clock_noise_offsets) - ).transformed(self.timestamped, concurrent=True) + ).transformed(self.timestamped, concurrent=self.concurrent) logger.debug("Sampling test-mass carrier beatnote fluctuations to THE grid") self.the_tmi_carrier_fluctuations = ( self.tps_tmi_carrier_fluctuations / (1 + self.clock_noise_offsets) - self.tps_tmi_carrier_offsets * self.clock_noise_fluctuations / (1 + self.clock_noise_offsets)**2 - ).transformed(self.timestamped, concurrent=True) + ).transformed(self.timestamped, concurrent=self.concurrent) logger.debug("Sampling test-mass upper sideband beatnote offsets to THE grid") self.the_tmi_usb_offsets = ( self.tps_tmi_usb_offsets / (1 + self.clock_noise_offsets) - ).transformed(self.timestamped, concurrent=True) + ).transformed(self.timestamped, concurrent=self.concurrent) logger.debug("Sampling test-mass upper sideband beatnote fluctuations to THE grid") self.the_tmi_usb_fluctuations = ( self.tps_tmi_usb_fluctuations / (1 + self.clock_noise_offsets) - self.tps_tmi_usb_offsets * self.clock_noise_fluctuations / (1 + self.clock_noise_offsets)**2 - ).transformed(self.timestamped, concurrent=True) + ).transformed(self.timestamped, concurrent=self.concurrent) logger.info("Sampling reference beatnotes to THE grid") logger.debug("Sampling reference carrier beatnote offsets to THE grid") self.the_rfi_carrier_offsets = ( self.tps_rfi_carrier_offsets / (1 + self.clock_noise_offsets) - ).transformed(self.timestamped, concurrent=True) + ).transformed(self.timestamped, concurrent=self.concurrent) logger.debug("Sampling reference carrier beatnote fluctuations to THE grid") self.the_rfi_carrier_fluctuations = ( self.tps_rfi_carrier_fluctuations / (1 + self.clock_noise_offsets) - self.tps_rfi_carrier_offsets * self.clock_noise_fluctuations / (1 + self.clock_noise_offsets)**2 - ).transformed(self.timestamped, concurrent=True) + ).transformed(self.timestamped, concurrent=self.concurrent) logger.debug("Sampling reference upper sideband beatnote offsets to THE grid") self.the_rfi_usb_offsets = ( self.tps_rfi_usb_offsets / (1 + self.clock_noise_offsets) - ).transformed(self.timestamped, concurrent=True) + ).transformed(self.timestamped, concurrent=self.concurrent) logger.debug("Sampling reference upper sideband beatnote fluctuations to THE grid") self.the_rfi_usb_fluctuations = ( self.tps_rfi_usb_fluctuations / (1 + self.clock_noise_offsets) - self.tps_rfi_usb_offsets * self.clock_noise_fluctuations / (1 + self.clock_noise_offsets)**2 - ).transformed(self.timestamped, concurrent=True) + ).transformed(self.timestamped, concurrent=self.concurrent) # Electronic delays @@ -1294,33 +1298,33 @@ class Instrument: logger.debug("Applying electronic delays to inter-spacecraft beatnotes") self.electro_isi_carrier_offsets = self.the_isi_carrier_offsets \ - .transformed(self.electro_isi, concurrent=True) + .transformed(self.electro_isi, concurrent=self.concurrent) self.electro_isi_carrier_fluctuations = self.the_isi_carrier_fluctuations \ - .transformed(self.electro_isi, concurrent=True) + .transformed(self.electro_isi, concurrent=self.concurrent) self.electro_isi_usb_offsets = self.the_isi_usb_offsets \ - .transformed(self.electro_isi, concurrent=True) + .transformed(self.electro_isi, concurrent=self.concurrent) self.electro_isi_usb_fluctuations = self.the_isi_usb_fluctuations \ - .transformed(self.electro_isi, concurrent=True) + .transformed(self.electro_isi, concurrent=self.concurrent) logger.debug("Applying electronic delays to test-mass beatnotes") self.electro_tmi_carrier_offsets = self.the_tmi_carrier_offsets \ - .transformed(self.electro_tmi, concurrent=True) + .transformed(self.electro_tmi, concurrent=self.concurrent) self.electro_tmi_carrier_fluctuations = self.the_tmi_carrier_fluctuations \ - .transformed(self.electro_tmi, concurrent=True) + .transformed(self.electro_tmi, concurrent=self.concurrent) self.electro_tmi_usb_offsets = self.the_tmi_usb_offsets \ - .transformed(self.electro_tmi, concurrent=True) + .transformed(self.electro_tmi, concurrent=self.concurrent) self.electro_tmi_usb_fluctuations = self.the_tmi_usb_fluctuations \ - .transformed(self.electro_tmi, concurrent=True) + .transformed(self.electro_tmi, concurrent=self.concurrent) logger.debug("Applying electronic delays to reference beatnotes") self.electro_rfi_carrier_offsets = self.the_rfi_carrier_offsets \ - .transformed(self.electro_rfi, concurrent=True) + .transformed(self.electro_rfi, concurrent=self.concurrent) self.electro_rfi_carrier_fluctuations = self.the_rfi_carrier_fluctuations \ - .transformed(self.electro_rfi, concurrent=True) + .transformed(self.electro_rfi, concurrent=self.concurrent) self.electro_rfi_usb_offsets = self.the_rfi_usb_offsets \ - .transformed(self.electro_rfi, concurrent=True) + .transformed(self.electro_rfi, concurrent=self.concurrent) self.electro_rfi_usb_fluctuations = self.the_rfi_usb_fluctuations \ - .transformed(self.electro_rfi, concurrent=True) + .transformed(self.electro_rfi, concurrent=self.concurrent) ## Antialiasing filtering @@ -1328,43 +1332,43 @@ class Instrument: logger.debug("Filtering inter-spacecraft beatnotes") self.filtered_isi_carrier_offsets = self.electro_isi_carrier_offsets \ - .transformed(self.aafilter, concurrent=True) + .transformed(self.aafilter, concurrent=self.concurrent) self.filtered_isi_carrier_fluctuations = self.electro_isi_carrier_fluctuations \ - .transformed(self.aafilter, concurrent=True) + .transformed(self.aafilter, concurrent=self.concurrent) self.filtered_isi_usb_offsets = self.electro_isi_usb_offsets \ - .transformed(self.aafilter, concurrent=True) + .transformed(self.aafilter, concurrent=self.concurrent) self.filtered_isi_usb_fluctuations = self.electro_isi_usb_fluctuations \ - .transformed(self.aafilter, concurrent=True) + .transformed(self.aafilter, concurrent=self.concurrent) logger.debug("Filtering inter-spacecraft DWS measurements") self.filtered_isi_dws_phis = self.the_isi_dws_phis \ - .transformed(self.aafilter, concurrent=True) + .transformed(self.aafilter, concurrent=self.concurrent) self.filtered_isi_dws_etas = self.the_isi_dws_etas \ - .transformed(self.aafilter, concurrent=True) + .transformed(self.aafilter, concurrent=self.concurrent) logger.debug("Filtering measured pseudo-ranges") self.filtered_mprs = self.the_mprs \ - .transformed(self.aafilter, concurrent=True) + .transformed(self.aafilter, concurrent=self.concurrent) logger.debug("Filtering test-mass beatnotes") self.filtered_tmi_carrier_offsets = self.electro_tmi_carrier_offsets \ - .transformed(self.aafilter, concurrent=True) + .transformed(self.aafilter, concurrent=self.concurrent) self.filtered_tmi_carrier_fluctuations = self.electro_tmi_carrier_fluctuations \ - .transformed(self.aafilter, concurrent=True) + .transformed(self.aafilter, concurrent=self.concurrent) self.filtered_tmi_usb_offsets = self.electro_tmi_usb_offsets \ - .transformed(self.aafilter, concurrent=True) + .transformed(self.aafilter, concurrent=self.concurrent) self.filtered_tmi_usb_fluctuations = self.electro_tmi_usb_fluctuations \ - .transformed(self.aafilter, concurrent=True) + .transformed(self.aafilter, concurrent=self.concurrent) logger.debug("Filtering reference beatnotes") self.filtered_rfi_carrier_offsets = self.electro_rfi_carrier_offsets \ - .transformed(self.aafilter, concurrent=True) + .transformed(self.aafilter, concurrent=self.concurrent) self.filtered_rfi_carrier_fluctuations = self.electro_rfi_carrier_fluctuations \ - .transformed(self.aafilter, concurrent=True) + .transformed(self.aafilter, concurrent=self.concurrent) self.filtered_rfi_usb_offsets = self.electro_rfi_usb_offsets \ - .transformed(self.aafilter, concurrent=True) + .transformed(self.aafilter, concurrent=self.concurrent) self.filtered_rfi_usb_fluctuations = self.electro_rfi_usb_fluctuations \ - .transformed(self.aafilter, concurrent=True) + .transformed(self.aafilter, concurrent=self.concurrent) ## Downsampling filtering @@ -1463,7 +1467,7 @@ class Instrument: self.physics_fs, self.physics_size + self.initial_telemetry_physics_size, self.clock_asds[sc]), - concurrent=True + concurrent=self.concurrent ) # Slice to only select physics period @@ -1480,7 +1484,7 @@ class Instrument: self.clock_noise_fluctuations_withinitial[sc], self.physics_size + self.initial_telemetry_physics_size), dx=self.physics_dt, initial=0), - concurrent=True + concurrent=self.concurrent ) # Slice to only select physics period @@ -1494,7 +1498,7 @@ class Instrument: logger.info("Generating modulation noise") self.modulation_noises = ForEachMOSA(lambda mosa: noises.modulation(self.physics_fs, self.physics_size, self.modulation_asds[mosa]), - concurrent=True + concurrent=self.concurrent ) ## Backlink noise @@ -1503,7 +1507,7 @@ class Instrument: self.backlink_noises = ForEachMOSA(lambda mosa: noises.backlink(self.physics_fs, self.physics_size, self.backlink_asds[mosa], self.backlink_fknees[mosa]), - concurrent=True + concurrent=self.concurrent ) ## Test-mass acceleration noise @@ -1512,7 +1516,7 @@ class Instrument: self.testmass_noises = ForEachMOSA(lambda mosa: noises.testmass(self.physics_fs, self.physics_size, self.testmass_asds[mosa], self.testmass_fknees[mosa]), - concurrent=True + concurrent=self.concurrent ) ## Ranging noise @@ -1521,7 +1525,7 @@ class Instrument: self.ranging_noises = ForEachMOSA(lambda mosa: self.ranging_biases[mosa] + noises.ranging(self.physics_fs, self.physics_size, self.ranging_asds[mosa]), - concurrent=True + concurrent=self.concurrent ) ## OMS noise @@ -1531,37 +1535,37 @@ class Instrument: self.oms_isi_carrier_noises = ForEachMOSA(lambda mosa: noises.oms(self.physics_fs, self.physics_size, self.oms_isi_carrier_asds[mosa], self.oms_fknees[mosa]), - concurrent=True + concurrent=self.concurrent ) self.oms_isi_usb_noises = ForEachMOSA(lambda mosa: noises.oms(self.physics_fs, self.physics_size, self.oms_isi_usb_asds[mosa], self.oms_fknees[mosa]), - concurrent=True + concurrent=self.concurrent ) self.oms_tmi_carrier_noises = ForEachMOSA(lambda mosa: noises.oms(self.physics_fs, self.physics_size, self.oms_tmi_carrier_asds[mosa], self.oms_fknees[mosa]), - concurrent=True + concurrent=self.concurrent ) self.oms_tmi_usb_noises = ForEachMOSA(lambda mosa: noises.oms(self.physics_fs, self.physics_size, self.oms_tmi_usb_asds[mosa], self.oms_fknees[mosa]), - concurrent=True + concurrent=self.concurrent ) self.oms_rfi_carrier_noises = ForEachMOSA(lambda mosa: noises.oms(self.physics_fs, self.physics_size, self.oms_rfi_carrier_asds[mosa], self.oms_fknees[mosa]), - concurrent=True + concurrent=self.concurrent ) self.oms_rfi_usb_noises = ForEachMOSA(lambda mosa: noises.oms(self.physics_fs, self.physics_size, self.oms_rfi_usb_asds[mosa], self.oms_fknees[mosa]), - concurrent=True + concurrent=self.concurrent ) ## DWS measurement noise @@ -1570,11 +1574,11 @@ class Instrument: self.dws_phi_noises = ForEachMOSA(lambda mosa: noises.dws(self.physics_fs, self.physics_size, self.dws_asds[mosa]), - concurrent=True + concurrent=self.concurrent ) self.dws_eta_noises = ForEachMOSA(lambda mosa: noises.dws(self.physics_fs, self.physics_size, self.dws_asds[mosa]), - concurrent=True + concurrent=self.concurrent ) ## MOC time correlation noise @@ -1584,7 +1588,7 @@ class Instrument: self.telemetry_fs, self.telemetry_size, self.moc_time_correlation_asds[sc]), - concurrent=True + concurrent=self.concurrent ) ## Angular jitters @@ -1594,17 +1598,17 @@ class Instrument: self.sc_jitter_phis = ForEachSC(lambda sc: noises.jitter(self.physics_fs, self.physics_size, self.sc_jitter_phi_asds[sc], self.sc_jitter_phi_fknees[sc]), - concurrent=True + concurrent=self.concurrent ) self.sc_jitter_etas = ForEachSC(lambda sc: noises.jitter(self.physics_fs, self.physics_size, self.sc_jitter_eta_asds[sc], self.sc_jitter_eta_fknees[sc]), - concurrent=True + concurrent=self.concurrent ) self.sc_jitter_thetas = ForEachSC(lambda sc: noises.jitter(self.physics_fs, self.physics_size, self.sc_jitter_theta_asds[sc], self.sc_jitter_theta_fknees[sc]), - concurrent=True + concurrent=self.concurrent ) logger.info("Generating MOSA angular jitters") @@ -1612,12 +1616,12 @@ class Instrument: self.mosa_jitter_phis = ForEachMOSA(lambda mosa: noises.jitter(self.physics_fs, self.physics_size, self.mosa_jitter_phi_asds[mosa], self.mosa_jitter_phi_fknees[mosa]), - concurrent=True + concurrent=self.concurrent ) self.mosa_jitter_etas = ForEachMOSA(lambda mosa: noises.jitter(self.physics_fs, self.physics_size, self.mosa_jitter_eta_asds[mosa], self.mosa_jitter_eta_fknees[mosa]), - concurrent=True + concurrent=self.concurrent ) logger.info("Computing MOSA total angular jitters") @@ -1850,7 +1854,7 @@ class Instrument: hdf5 (:obj:`h5py.Group`): an HDF5 file, or a dataset """ self._write_attr(hdf5, - 'git_url', 'version', + 'git_url', 'version', 'concurrent', 'dt', 't0', 'size', 'fs', 'duration', 'initial_telemetry_size', 'telemetry_downsampling', 'telemetry_fs', 'telemetry_size', 'telemetry_t0',