Skip to content

Fix frequencies

This fixes the issue where the maximum and minimum frequencies could be updated without subsequently updating the frequency mask. I have added a __freq_mask_updated flag to the StrainData object that gets flipped every time the max or min frequency is updated and forces the frequency mask to be recalculated. Things seems to be linked correctly between the properties of the Interferometer of the same name. Here is a demonstration.

Before:

>>> ifos[0].strain_data.maximum_frequency
1024.0
>>> ifos[0].strain_data.frequency_mask   
array([False, False, False, ...,  True,  True,  True])
>>> ifos[0].strain_data.frequency_array[ifos[0].strain_data.frequency_mask]
array([  20.  ,   20.25,   20.5 , ..., 1023.5 , 1023.75,
       1024.  ])
>>> ifos[0].strain_data.maximum_frequency = 1000.
>>> ifos[0].strain_data.frequency_array[ifos[0].strain_data.frequency_mask]
array([  20.  ,   20.25,   20.5 , ..., 1023.5 , 1023.75,
       1024.  ])

Changing the strain_data properties:

>>> ifos[0].strain_data.maximum_frequency
1024.0
>>> ifos[0].strain_data.frequency_array[ifos[0].strain_data.frequency_mask]  
array([  20.  ,   20.25,   20.5 , ..., 1023.5 , 1023.75,
       1024.  ])
>>> ifos[0].strain_data.maximum_frequency  = 1000.
>>> ifos[0].strain_data.frequency_array[ifos[0].strain_data.frequency_mask]
array([  20.  ,   20.25,   20.5 , ...,  999.5 ,  999.75,
       1000.  ])
>>> ifos[0].strain_data.minimum_frequency  = 50.  
>>> ifos[0].strain_data.frequency_array[ifos[0].strain_data.frequency_mask]
array([  50.  ,   50.25,   50.5 , ...,  999.5 ,  999.75,
       1000.  ])

Changing the interferometer properties:

>>> ifos[0].maximum_frequency
1024.0
>>> ifos[0].maximum_frequency = 1000.
>>> ifos[0].strain_data.maximum_frequency                                                                                                                                   
1000.0
>>> ifos[0].minimum_frequency = 50.                                                                                                                                         
>>> ifos[0].strain_data.minimum_frequency
50.0
>>> ifos[0].frequency_array 
array([0.00000e+00, 2.50000e-01, 5.00000e-01, ..., 1.02350e+03,
       1.02375e+03, 1.02400e+03])
>>> ifos[0].frequency_mask 
array([False, False, False, ..., False, False, False])
>>> ifos[0].frequency_array[ifos[0].frequency_mask]
array([  50.  ,   50.25,   50.5 , ...,  999.5 ,  999.75,
       1000.  ])

It is also safe against trying to set the maximum frequency above the sampling frequency:

>>> ifos[0].strain_data.sampling_frequency
2048.0
>>> ifos[0].strain_data.maximum_frequency
1024.0
>>> ifos[0].strain_data.maximum_frequency = 2000.
>>> ifos[0].strain_data.maximum_frequency
1024.0
>>> ifos[0].maximum_frequency
1024.0
>>> ifos[0].maximum_frequency = 2000.
>>> ifos[0].maximum_frequency
1024.0

Note that this MR does not address recalculating the frequency_mask if the sampling frequency and duration are changed.

Merge request reports

Loading