LISA Instrument issueshttps://gitlab.in2p3.fr/lisa-simulation/instrument/-/issues2023-12-08T10:54:31+01:00https://gitlab.in2p3.fr/lisa-simulation/instrument/-/issues/139Cannot call `write()` twice on the same `Instrument` instance2023-12-08T10:54:31+01:00Jean-Baptiste Baylej2b.bayle@gmail.comCannot call `write()` twice on the same `Instrument` instanceIn the current implementation, some quantities (such as resampled GW signals, or glitches) are computed when the `Instrument` instance is initialized, i.e., inside `__init__()`. They are immediately added to the cache. When `write()` is ...In the current implementation, some quantities (such as resampled GW signals, or glitches) are computed when the `Instrument` instance is initialized, i.e., inside `__init__()`. They are immediately added to the cache. When `write()` is called, these quantities are used to compute other quantities, and as soon as they are not needed anymore they are discarded (flushed from memory and written to disk, if requested) such that they don't clutter the RAM.
This means that when the user calls `write()` a second time on the same instance, we are trying to access these quantities again in the cache but they don't exist anymore, and an `AttributeError` is thrown.
We should better handle this case by either
* Making sure that all quantities are computed in `write()`, and that the cache only lives there. That would mean that these quantities are recomputed if `write()` is called multiple times -- which is safe because users might have changed some simulation parameter in the meantime. If they have not, this is a bit suboptimal.
* Forbidding users to call `write()` a second time, by checking whether `self.simulated` is true or not.
* By not flushing, in `write()`, quantities that are computed in `__init__()`. That is a bit more efficient in terms of computation, but takes up memory (that might be an issue). Also, if the user changes simulation parameters between calls to `write()`, this will lead to some nasty inconsistencies.v1.7Jean-Baptiste Baylej2b.bayle@gmail.comJean-Baptiste Baylej2b.bayle@gmail.com