diff --git a/peyote/__init__.py b/peyote/__init__.py index 42985a99f5c2e06a3073c7657bec70a96fa60d5b..6a38b8f632314188902790423d91b8e9d0a002e1 100644 --- a/peyote/__init__.py +++ b/peyote/__init__.py @@ -1,7 +1,4 @@ from __future__ import print_function, division -import os -import numpy as np - # import local files import detector diff --git a/peyote/detector.py b/peyote/detector.py index 621906625f8170767079b4c780e3ead3be4d8646..acba61167560353eab2d904f9d49138ed7ffc9b7 100644 --- a/peyote/detector.py +++ b/peyote/detector.py @@ -1,3 +1,6 @@ +import os +import numpy as np + class Interferometer: """Class for the Interferometer """ @@ -22,33 +25,39 @@ class Interferometer: class PowerSpectralDensity: def __init__(self): + self.frequencies = [] + self.power_spectral_density = [] + self.amplitude_spectral_density = [] return None - def import_spectral_density_file(self, spectral_density_file='aLIGO_ZERO_DET_high_P_psd.txt'): + def import_power_spectral_density(self, spectral_density_file='aLIGO_ZERO_DET_high_P_psd.txt'): """ Automagically load one of the power spectral density or amplitude spectral density curves contained in the noise_curves directory """ sd_file = os.path.join(os.path.dirname(__file__), 'noise_curves', spectral_density_file) spectral_density = np.genfromtxt(sd_file) - return spectral_density + self.frequencies = spectral_density[:, 0] + self.power_spectral_density = spectral_density[:, 1] + + def import_amplitude_spectral_density(self, spectral_density_file='aLIGO_ZERO_DET_high_P_asd.txt'): + """ + Automagically load one of the p]amplitude spectral density + curves contained in the noise_curves directory + """ + sd_file = os.path.join(os.path.dirname(__file__), 'noise_curves', spectral_density_file) + spectral_density = np.genfromtxt(sd_file) + self.frequencies = spectral_density[:, 0] + self.amplitude_spectral_density = spectral_density[:, 1] - def convert_psd_to_asd(self, power_spectral_density): + def convert_psd_to_asd(self): """ Convert a power spectral density to an amplitude spectral spectral_density - Return a two-dimensional array of frequency and amplitude spectral density. """ - frequencies = self.power_spectral_density[:, 0] - psd = self.power_spectral_density[:, 1] - amplitude_spectral_density = np.sqrt(psd) - return np.c_[frequencies, amplitude_spectral_density] + self.amplitude_spectral_density = np.sqrt(self.power_spectral_density) - def convert_asd_to_psd(self, amplitude_spectral_density): + def convert_asd_to_psd(self): """ Convert an amplitude spectral density to a power spectral density. - Return two dimensional array: frequency, power spectral density """ - frequencies = self.amplitude_spectral_density[:, 0] - asd = self.amplitude_spectral_density[:, 1] - power_spectral_density = asd**2. - return np.c_[frequencies, power_spectral_density] + self.power_spectral_density = self.amplitude_spectral_density**2