Skip to content

Commit

Permalink
Added a "secret" oldchi parameter to the Core/Star.py module and the …
Browse files Browse the repository at this point in the history
…Photometry and Spectroscopy classes in order to recover the old calculation of chi value. This is intended to be for comparison of the old vs new calculations.
  • Loading branch information
bretonr committed Oct 14, 2015
1 parent bcdf9c5 commit eabbfb5
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 9 deletions.
9 changes: 6 additions & 3 deletions Core/Star.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,13 @@ class Star(Star_base):
y: Along the orbital plane along the orbital motion.
z: Along the orbital angular momentum.
"""
def __init__(self, ndiv, atmo_grid=None, read=False):
def __init__(self, ndiv, atmo_grid=None, read=False, oldchi=False):
Star_base.__init__(self, ndiv, atmo_grid=atmo_grid)
if read:
self._Read_geodesic()
else:
self._New_Initialization()
self.oldchi = oldchi

def _New_Initialization(self):
"""Initialization(self)
Expand Down Expand Up @@ -242,10 +243,12 @@ def _Surface(self, debug=False):
## coschi is the cosine angle between the rx and the surface element. shape = n_faces
## A value of 1 means that the companion's surface element is directly facing the pulsar, 0 is at the limb and -1 on the back.
## The following is the old way, which is derived from the spherical approximation, i.e. that the normal to the surface is approximately the same as the radial position
#self.coschi = -(self.rc-self.cosx)/self.rx
if self.oldchi:
self.coschi = -(self.rc-self.cosx)/self.rx
## The better calculation should use the gradient as the normal vector, and the direction to the pulsar as positive x.
## This implies that the angle coschi is simply the x component of the gradient.
self.coschi = self.gradx.copy()
else:
self.coschi = self.gradx.copy()

## surface area. shape = n_faces
self.area = self.rc**2 * self.pre_area
Expand Down
8 changes: 4 additions & 4 deletions Photometry/Photometry.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ class Photometry(object):
calculate the predicted flux of the model at every data point (i.e.
for a given orbital phase).
"""
def __init__(self, atmo_fln, data_fln, ndiv, read=True):
def __init__(self, atmo_fln, data_fln, ndiv, read=True, oldchi=False):
"""__init__(atmo_fln, data_fln, ndiv, read=True)
This class allows to fit the flux from the primary star
of a binary system, assuming it is heated by the secondary
Expand Down Expand Up @@ -165,7 +165,7 @@ def __init__(self, atmo_fln, data_fln, ndiv, read=True):
# We keep in mind the number of datasets
self.ndataset = len(self.atmo_grid)
# We initialize some important class attributes.
self._Init_lightcurve(ndiv, read=read)
self._Init_lightcurve(ndiv, read=read, oldchi=oldchi)
self._Setup()

def Calc_chi2(self, par, do_offset=True, nsamples=None, influx=False, full_output=False, verbose=False):
Expand Down Expand Up @@ -504,14 +504,14 @@ def Get_Keff(self, par, nphases=20, atmo_grid=0, make_surface=False, verbose=Fal
Keff = tmp[1]
return Keff

def _Init_lightcurve(self, ndiv, read=False):
def _Init_lightcurve(self, ndiv, read=False, oldchi=False):
"""_Init_lightcurve(ndiv, read=False)
Call the appropriate Lightcurve class and initialize
the stellar array.
>>> self._Init_lightcurve(ndiv)
"""
self.star = Core.Star(ndiv, read=read)
self.star = Core.Star(ndiv, read=read, oldchi=oldchi)
return

def Make_surface(self, par, verbose=False):
Expand Down
4 changes: 2 additions & 2 deletions Spectroscopy/Spectroscopy.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class Spectroscopy(object):
calculate the predicted flux of the model at every data point (i.e.
for a given orbital phase).
"""
def __init__(self, atmo_grid, data_fln, ndiv, porb, x2sini, phase_offset=-0.25, seeing=-1, read=True):
def __init__(self, atmo_grid, data_fln, ndiv, porb, x2sini, phase_offset=-0.25, seeing=-1, read=True, oldchi=False):
"""
This class allows to fit the flux from the primary star
of a binary system, assuming it is heated by the secondary
Expand Down Expand Up @@ -90,7 +90,7 @@ def __init__(self, atmo_grid, data_fln, ndiv, porb, x2sini, phase_offset=-0.25,
self.ndataset = len(self.data['phase'])
# We initialize some important class attributes.
print( 'Initializing the lightcurve attribute' )
self.star = Core.Star(ndiv, atmo_grid=self.atmo_grid, read=read)
self.star = Core.Star(ndiv, atmo_grid=self.atmo_grid, read=read, oldchi=oldchi)
print( 'Performing some more initialization' )
self.Initialize(seeing=seeing)
print( 'Done. Play and have fun...' )
Expand Down

0 comments on commit eabbfb5

Please sign in to comment.