Skip to content
Snippets Groups Projects
Commit caac3d80 authored by Gregory Ashton's avatar Gregory Ashton
Browse files

Adds methods to set from a CSV file

parent 3f578976
No related branches found
No related tags found
1 merge request!94Add functionality to strain data
Pipeline #
...@@ -408,7 +408,7 @@ class InterferometerStrainData(object): ...@@ -408,7 +408,7 @@ class InterferometerStrainData(object):
def set_from_open_data( def set_from_open_data(
self, name, start_time, duration=4, outdir='outdir', cache=True, self, name, start_time, duration=4, outdir='outdir', cache=True,
**kwargs): **kwargs):
""" Set the strain data from a open LOSC data """ Set the strain data from open LOSC data
This sets the time_domain_strain attribute, the frequency_domain_strain This sets the time_domain_strain attribute, the frequency_domain_strain
is automatically calculated after a low-pass filter and Tukey window is automatically calculated after a low-pass filter and Tukey window
...@@ -439,6 +439,19 @@ class InterferometerStrainData(object): ...@@ -439,6 +439,19 @@ class InterferometerStrainData(object):
self.set_from_gwpy_timeseries(timeseries) self.set_from_gwpy_timeseries(timeseries)
self._check_maximum_frequency() self._check_maximum_frequency()
def set_from_csv(self, filename):
""" Set the strain data from a csv file
Parameters
----------
filename: str
The path to the file to read in
"""
timeseries = gwpy.timeseries.TimeSeries.read(filename, format='csv')
self.set_from_gwpy_timeseries(timeseries)
self._check_maximum_frequency()
def _infer_frequency_domain_dependence( def _infer_frequency_domain_dependence(
self, sampling_frequency, duration, frequency_array): self, sampling_frequency, duration, frequency_array):
""" Helper function to figure out if the frequency_array, or """ Helper function to figure out if the frequency_array, or
...@@ -745,6 +758,17 @@ class Interferometer(object): ...@@ -745,6 +758,17 @@ class Interferometer(object):
duration=duration, start_time=start_time, duration=duration, start_time=start_time,
channel_name=channel_name, buffer_time=buffer_time) channel_name=channel_name, buffer_time=buffer_time)
def set_strain_data_from_csv(self, filename):
""" Set the `Interferometer.strain_data` from a csv file
Parameters
----------
filename: str
The path to the file to read in
"""
self.strain_data.set_from_csv(filename)
def set_strain_data_from_zero_noise( def set_strain_data_from_zero_noise(
self, sampling_frequency, duration, start_time=0): self, sampling_frequency, duration, start_time=0):
""" Set the `Interferometer.strain_data` to zero noise """ Set the `Interferometer.strain_data` to zero noise
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment