diff --git a/bilby/gw/detector/interferometer.py b/bilby/gw/detector/interferometer.py index 7ee47ba114242e87bd6c2d6039e3537ead3e55f4..e4af331799479b1e67db9c00da906fda0fc6adcb 100644 --- a/bilby/gw/detector/interferometer.py +++ b/bilby/gw/detector/interferometer.py @@ -9,7 +9,7 @@ from bilby.core.utils import logger from bilby.gw import utils as gwutils from bilby.gw.calibration import Recalibrate from bilby.gw.detector.geometry import InterferometerGeometry -from bilby.gw.utils import SubclassPropertyAccessor +from bilby.gw.utils import PropertyAccessor from .strain_data import InterferometerStrainData try: @@ -23,28 +23,28 @@ except ImportError: class Interferometer(object): """Class for the Interferometer """ - length = SubclassPropertyAccessor('length', 'geometry') - latitude = SubclassPropertyAccessor('latitude', 'geometry') - latitude_radians = SubclassPropertyAccessor('latitude_radians', 'geometry') - longitude = SubclassPropertyAccessor('longitude', 'geometry') - longitude_radians = SubclassPropertyAccessor('longitude_radians', 'geometry') - elevation = SubclassPropertyAccessor('elevation', 'geometry') - x = SubclassPropertyAccessor('x', 'geometry') - y = SubclassPropertyAccessor('y', 'geometry') - xarm_azimuth = SubclassPropertyAccessor('xarm_azimuth', 'geometry') - yarm_azimuth = SubclassPropertyAccessor('yarm_azimuth', 'geometry') - xarm_tilt = SubclassPropertyAccessor('xarm_tilt', 'geometry') - yarm_tilt = SubclassPropertyAccessor('yarm_tilt', 'geometry') - vertex = SubclassPropertyAccessor('vertex', 'geometry') - detector_tensor = SubclassPropertyAccessor('detector_tensor', 'geometry') - - frequency_array = SubclassPropertyAccessor('frequency_array', 'strain_data') - time_array = SubclassPropertyAccessor('time_array', 'strain_data') - minimum_frequency = SubclassPropertyAccessor('minimum_frequency', 'strain_data') - maximum_frequency = SubclassPropertyAccessor('maximum_frequency', 'strain_data') - frequency_mask = SubclassPropertyAccessor('frequency_mask', 'strain_data') - frequency_domain_strain = SubclassPropertyAccessor('frequency_domain_strain', 'strain_data') - time_domain_strain = SubclassPropertyAccessor('time_domain_strain', 'strain_data') + length = PropertyAccessor('length', 'geometry') + latitude = PropertyAccessor('latitude', 'geometry') + latitude_radians = PropertyAccessor('latitude_radians', 'geometry') + longitude = PropertyAccessor('longitude', 'geometry') + longitude_radians = PropertyAccessor('longitude_radians', 'geometry') + elevation = PropertyAccessor('elevation', 'geometry') + x = PropertyAccessor('x', 'geometry') + y = PropertyAccessor('y', 'geometry') + xarm_azimuth = PropertyAccessor('xarm_azimuth', 'geometry') + yarm_azimuth = PropertyAccessor('yarm_azimuth', 'geometry') + xarm_tilt = PropertyAccessor('xarm_tilt', 'geometry') + yarm_tilt = PropertyAccessor('yarm_tilt', 'geometry') + vertex = PropertyAccessor('vertex', 'geometry') + detector_tensor = PropertyAccessor('detector_tensor', 'geometry') + + frequency_array = PropertyAccessor('frequency_array', 'strain_data') + time_array = PropertyAccessor('time_array', 'strain_data') + minimum_frequency = PropertyAccessor('minimum_frequency', 'strain_data') + maximum_frequency = PropertyAccessor('maximum_frequency', 'strain_data') + frequency_mask = PropertyAccessor('frequency_mask', 'strain_data') + frequency_domain_strain = PropertyAccessor('frequency_domain_strain', 'strain_data') + time_domain_strain = PropertyAccessor('time_domain_strain', 'strain_data') def __init__(self, name, power_spectral_density, minimum_frequency, maximum_frequency, length, latitude, longitude, elevation, xarm_azimuth, yarm_azimuth, xarm_tilt=0., yarm_tilt=0., calibration_model=Recalibrate()): diff --git a/bilby/gw/detector/strain_data.py b/bilby/gw/detector/strain_data.py index 46d62d69e0c8bd1ed7d295ad133f99a1a2b01894..f5781cbd4f0f66e6b59bc12f0257cd34b8984264 100644 --- a/bilby/gw/detector/strain_data.py +++ b/bilby/gw/detector/strain_data.py @@ -5,7 +5,7 @@ from bilby.core import utils from bilby.core.series import CoupledTimeAndFrequencySeries from bilby.core.utils import logger from bilby.gw import utils as gwutils -from bilby.gw.utils import SubclassPropertyAccessor +from bilby.gw.utils import PropertyAccessor try: import gwpy @@ -24,11 +24,11 @@ except ImportError: class InterferometerStrainData(object): """ Strain data for an interferometer """ - duration = SubclassPropertyAccessor('duration', '_times_and_frequencies') - sampling_frequency = SubclassPropertyAccessor('sampling_frequency', '_times_and_frequencies') - start_time = SubclassPropertyAccessor('start_time', '_times_and_frequencies') - frequency_array = SubclassPropertyAccessor('frequency_array', '_times_and_frequencies') - time_array = SubclassPropertyAccessor('time_array', '_times_and_frequencies') + duration = PropertyAccessor('duration', '_times_and_frequencies') + sampling_frequency = PropertyAccessor('sampling_frequency', '_times_and_frequencies') + start_time = PropertyAccessor('start_time', '_times_and_frequencies') + frequency_array = PropertyAccessor('frequency_array', '_times_and_frequencies') + time_array = PropertyAccessor('time_array', '_times_and_frequencies') def __init__(self, minimum_frequency=0, maximum_frequency=np.inf, roll_off=0.2): diff --git a/bilby/gw/utils.py b/bilby/gw/utils.py index bf0cff4d17a85c0c8c69a5a9fb5b3d585ef253df..6a93630941ca98c6a5ccb2bfc98a1469c5b1f008 100644 --- a/bilby/gw/utils.py +++ b/bilby/gw/utils.py @@ -928,7 +928,7 @@ def plot_spline_pos(log_freqs, samples, nfreqs=100, level=0.9, color='k', label= plt.xlim(freq_points.min() - .5, freq_points.max() + 50) -class SubclassPropertyAccessor(object): +class PropertyAccessor(object): """ Generic descriptor class that allows handy access of properties without long boilerplate code. The properties of Interferometer are defined as instances @@ -956,4 +956,4 @@ class SubclassPropertyAccessor(object): return getattr(getattr(instance, self.container_instance_name), self.property_name) def __set__(self, instance, value): - setattr(getattr(instance, self.container_instance_name), self.property_name, value) \ No newline at end of file + setattr(getattr(instance, self.container_instance_name), self.property_name, value) diff --git a/bilby/gw/waveform_generator.py b/bilby/gw/waveform_generator.py index 60edf6828e3d37b5becc7666b68d340704496564..db174ae449044086910351ed2159dc497ea2dc34 100644 --- a/bilby/gw/waveform_generator.py +++ b/bilby/gw/waveform_generator.py @@ -2,16 +2,16 @@ import numpy as np from ..core import utils from ..core.series import CoupledTimeAndFrequencySeries -from .utils import SubclassPropertyAccessor +from .utils import PropertyAccessor class WaveformGenerator(object): - duration = SubclassPropertyAccessor('duration', '_times_and_frequencies') - sampling_frequency = SubclassPropertyAccessor('sampling_frequency', '_times_and_frequencies') - start_time = SubclassPropertyAccessor('start_time', '_times_and_frequencies') - frequency_array = SubclassPropertyAccessor('frequency_array', '_times_and_frequencies') - time_array = SubclassPropertyAccessor('time_array', '_times_and_frequencies') + duration = PropertyAccessor('duration', '_times_and_frequencies') + sampling_frequency = PropertyAccessor('sampling_frequency', '_times_and_frequencies') + start_time = PropertyAccessor('start_time', '_times_and_frequencies') + frequency_array = PropertyAccessor('frequency_array', '_times_and_frequencies') + time_array = PropertyAccessor('time_array', '_times_and_frequencies') def __init__(self, duration=None, sampling_frequency=None, start_time=0, frequency_domain_source_model=None, time_domain_source_model=None, parameters=None,