Commit 0a82f169 authored by moritz's avatar moritz
Browse files

Moritz Huebner: Rewrote to match the properties and setters design pattern

parent 821042fb
......@@ -15,47 +15,47 @@ class Parameter:
@property
def prior(self):
return self.prior
return self.__prior
@property
def value(self):
return self.value
return self.__value
@property
def latex_label(self):
return self.latex_label
return self.__latex_label
@property
def is_fixed(self):
return self.is_fixed
return self.__is_fixed
@prior.setter
def prior(self, prior=None):
if prior is None:
self.set_default_prior()
else:
self.prior = prior
self.__prior = prior
@value.setter
def value(self, value=None):
if value is None:
self.set_default_values()
else:
self.value = value
self.__value = value
@latex_label.setter
def latex_label(self, latex_label=None):
if latex_label is None:
self.latex_label = self.name
self.__latex_label = self.name
else:
self.set_default_latex_label()
@is_fixed.setter
def is_fixed(self, is_fixed):
if is_fixed:
self.is_fixed = True
self.__is_fixed = True
else:
self.is_fixed = False
self.__is_fixed = False
def fix(self, value=None):
"""
......@@ -71,91 +71,91 @@ class Parameter:
def set_default_prior(self):
if self.name == 'mass_1':
self.prior = peyote.prior.PowerLaw(alpha=0, bounds=(5, 100))
self.__prior = peyote.prior.PowerLaw(alpha=0, bounds=(5, 100))
elif self.name == 'mass_2':
self.prior = peyote.prior.PowerLaw(alpha=0, bounds=(5, 100))
self.__prior = peyote.prior.PowerLaw(alpha=0, bounds=(5, 100))
elif self.name == 'mchirp':
self.prior = peyote.prior.PowerLaw(alpha=0, bounds=(5, 100))
self.__prior = peyote.prior.PowerLaw(alpha=0, bounds=(5, 100))
elif self.name == 'q':
self.prior = peyote.prior.PowerLaw(alpha=0, bounds=(0, 1))
self.__prior = peyote.prior.PowerLaw(alpha=0, bounds=(0, 1))
elif self.name == 'a1':
self.prior = peyote.prior.PowerLaw(alpha=0, bounds=(0, 1))
self.__prior = peyote.prior.PowerLaw(alpha=0, bounds=(0, 1))
elif self.name == 'a2':
self.prior = peyote.prior.PowerLaw(alpha=0, bounds=(0, 1))
self.__prior = peyote.prior.PowerLaw(alpha=0, bounds=(0, 1))
elif self.name == 'tilt1':
self.prior = peyote.prior.Sine()
self.__prior = peyote.prior.Sine()
elif self.name == 'tilt2':
self.prior = peyote.prior.Sine()
self.__prior = peyote.prior.Sine()
elif self.name == 'phi1':
self.prior = peyote.prior.PowerLaw(alpha=0, bounds=(0, 2 * np.pi))
self.__prior = peyote.prior.PowerLaw(alpha=0, bounds=(0, 2 * np.pi))
elif self.name == 'phi2':
self.prior = peyote.prior.PowerLaw(alpha=0, bounds=(0, 2 * np.pi))
self.__prior = peyote.prior.PowerLaw(alpha=0, bounds=(0, 2 * np.pi))
elif self.name == 'luminosity_distance':
self.prior = peyote.prior.PowerLaw(alpha=2, bounds=(1e2, 5e3))
self.__prior = peyote.prior.PowerLaw(alpha=2, bounds=(1e2, 5e3))
elif self.name == 'dec':
self.prior = peyote.prior.Cosine()
self.__prior = peyote.prior.Cosine()
elif self.name == 'ra':
self.prior = peyote.prior.PowerLaw(alpha=0, bounds=(0, 2 * np.pi))
self.__prior = peyote.prior.PowerLaw(alpha=0, bounds=(0, 2 * np.pi))
elif self.name == 'iota':
self.prior = peyote.prior.Sine()
self.__prior = peyote.prior.Sine()
elif self.name == 'psi':
self.prior = peyote.prior.PowerLaw(alpha=0, bounds=(0, 2 * np.pi))
self.__prior = peyote.prior.PowerLaw(alpha=0, bounds=(0, 2 * np.pi))
elif self.name == 'phase':
self.prior = peyote.prior.PowerLaw(alpha=0, bounds=(0, 2 * np.pi))
self.__prior = peyote.prior.PowerLaw(alpha=0, bounds=(0, 2 * np.pi))
else:
self.prior = None
self.__prior = None
def set_default_values(self):
# spins
if self.name == 'a1':
self.value = 0
self.__value = 0
elif self.name == 'a2':
self.value = 0
self.__value = 0
elif self.name == 'tilt1':
self.value = 0
self.__value = 0
elif self.name == 'tilt2':
self.value = 0
self.__value = 0
elif self.name == 'phi1':
self.value = 0
self.__value = 0
elif self.name == 'phi2':
self.value = 0
self.__value = 0
else:
self.value = np.nan
self.__value = np.nan
def set_default_latex_label(self):
if self.name == 'mass_1':
self.latex_label = '$m_1$'
self.__latex_label = '$m_1$'
elif self.name == 'mass_2':
self.latex_label = '$m_2$'
self.__latex_label = '$m_2$'
elif self.name == 'mchirp':
self.latex_label = '$\mathcal{M}$'
self.__latex_label = '$\mathcal{M}$'
elif self.name == 'q':
self.latex_label = 'q'
self.__latex_label = 'q'
elif self.name == 'a1':
self.latex_label = 'a_1'
self.__latex_label = 'a_1'
elif self.name == 'a2':
self.latex_label = 'a_2'
self.__latex_label = 'a_2'
elif self.name == 'tilt1':
self.latex_label = 'tilt_1'
self.__latex_label = 'tilt_1'
elif self.name == 'tilt2':
self.latex_label = 'tilt_2'
self.__latex_label = 'tilt_2'
elif self.name == 'phi1':
self.latex_label = '\phi_1'
self.__latex_label = '\phi_1'
elif self.name == 'phi2':
self.latex_label = '\phi_2'
self.__latex_label = '\phi_2'
elif self.name == 'luminosity_distance':
self.latex_label = 'd'
self.__latex_label = 'd'
elif self.name == 'dec':
self.latex_label = '\mathrm{DEC}'
self.__latex_label = '\mathrm{DEC}'
elif self.name == 'ra':
self.latex_label = '\mathrm{RA}'
self.__latex_label = '\mathrm{RA}'
elif self.name == 'iota':
self.latex_label = '\iota'
self.__latex_label = '\iota'
elif self.name == 'psi':
self.latex_label = '\psi'
self.__latex_label = '\psi'
elif self.name == 'phase':
self.latex_label = '\phi'
self.__latex_label = '\phi'
elif self.name == 'tc':
self.latex_label = 't_c'
self.__latex_label = 't_c'
else:
self.latex_label = self.name
self.__latex_label = self.name
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment