Instrument.write() fails (master branch)
Synopsis
write() fails at writing timer deviations from TCB.
Minimal example:
from lisainstrument import Instrument
instrument = Instrument(size=10000)
instrument.simulate()
instrument.write()
Error message is:
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
<ipython-input-4-16ff99f96a6c> in <module>
----> 1 instrument.write()
~/temp/instrument/lisainstrument/instrument.py in write(self, output, mode, keep_all)
1795
1796 logger.debug("Write timer deviations from TCB to '%s'", output)
-> 1797 self.tcb_timer_deviations.write(hdf5, 'tcb_timer_deviations')
1798
1799 logger.info("Closing measurement file '%s'", output)
~/temp/instrument/lisainstrument/containers.py in write(self, hdf5, dataset)
78 hdf5.create_dataset(dataset, (size,), dtype=dtype)
79 for index in self.indices():
---> 80 hdf5[dataset][index] = self[index]
81
82 def __getitem__(self, key):
h5py/_objects.pyx in h5py._objects.with_phil.wrapper()
h5py/_objects.pyx in h5py._objects.with_phil.wrapper()
~/.conda/envs/LISA/lib/python3.9/site-packages/h5py/_hl/dataset.py in __setitem__(self, args, val)
916
917 # Perform the write, with broadcasting
--> 918 mspace = h5s.create_simple(selection.expand_shape(mshape))
919 for fspace in selection.broadcast(mshape):
920 self.id.write(mspace, fspace, val, mtype, dxpl=self._dxpl)
~/.conda/envs/LISA/lib/python3.9/site-packages/h5py/_hl/selections.py in expand_shape(self, source_shape)
262 eshape.append(t)
263 else:
--> 264 raise TypeError("Can't broadcast %s -> %s" % (source_shape, self.array_shape)) # array shape
265
266 if any([n > 1 for n in remaining_src_dims]):
TypeError: Can't broadcast (0,) -> (1,)
Log file is attached simulate.log
Possible cause:
tcb_timer_deviations
contains empty arrays, despite the fact that
instrument.tcb_timer_deviations?
yields
Type: ForEachSC
String form: {'1': array([], dtype=float64), '2': array([], dtype=float64), '3': array([], dtype=float64)}
Length: 0
File: ~/temp/instrument/lisainstrument/containers.py
Docstring: Represents a dictionary of values for each spacecraft.
Init docstring:
Initialize an object with a value or a function of the mosa index.
Args:
values: a value, a dictionary of values, or a function (mosa -> value)
This is likely due to the initialisation of self.telemetry_t
as an empty(!) array iif self.telemetry_size
is 0 (zero) in __init__
self.telemetry_t = \
self.telemetry_t0 + np.arange(self.telemetry_size, dtype=np.float64) * self.telemetry_dt
Possible solution
Capture telemetry_size==0
and assign self.telemetry_t=0
in that case.
** Temporary fix **
After running simulate()
- Set
telemetry_t
manually to zero, iftelemetry_size==0
- In an unrelated problem, also
tcb_sync_noises
is a dictionary with empty arrays. This is due to a bug (?) in the implementation ofnoises.white
that does not capturesize==0
and thus yields empty arrays. So also here, set tcb_sync_noises to 0 (zero).
if instrument.telemetry_size==0:
instrument.tcb_sync_noises=0
instrument.telemetry_t=0
instrument.tcb_timer_deviations = instrument.clock_offsets + \
instrument.clock_freqoffsets * instrument.telemetry_t + \
instrument.clock_freqlindrifts * instrument.telemetry_t**2 / 2 + \
instrument.clock_freqquaddrifts * instrument.telemetry_t**3 / 3 + \
instrument.tps_proper_time_deviations + \
instrument.tcb_sync_noises
Edited by Jean-Baptiste Bayle