Skip to content

Create single class that handles `duration`, `sampling_frequency`, `start_time`, `frequency_array`, `time_array`, and maybe `frequency_domain_strain`, `time_domain_strain`

We have a lot of redundant functionality regarding this currently implemented in WaveformGenerator and in InterferometerStrainData. It would be good if we instead had:

  • A single class that handles these things
  • Find a descriptive name for this class
  • Write tests for this class
  • Replace the current implementation in InterferometerStrainData with an instance of this class
  • Replace the current implementation in WaveformGenerator with an instance of this class
  • Write a bunch of boilerplate code for InterferometerStrainData to keep the API consistent
  • Write a bunch of boilerplate code for WaveformGenerator to keep the API consistent

With the last two items I mean that we should use a @property/@setter pattern. Assume the class is called TimesAndFrequencies then I'd like to have it like this:

class WaveformGenerator(object):
   def __init__(...):
      ...
      self._times_and_freqs = TimesAndFrequencies(...)
      ...

...

   @property
   def duration(self):
      return self._times_and_freqs

   @duration.setter(self, duration):
      self._times_and_freqs.duration = duration

An alternative is using a Mixin, i.e. making WaveformGenerator and InterferometerStrainData inherit from TimesAndFrequencies. This avoids us having to write all those setters and getters, but it might be a bit harder to test and become more confusing over time.

@colm.talbot @gregory.ashton what do you think?

Edited by Moritz Huebner