Skip to content

Commit

Permalink
added eclipse depth calculation and fixed co-ordinate singularity bug
Browse files Browse the repository at this point in the history
  • Loading branch information
tomlouden committed May 3, 2017
1 parent 47c27eb commit 183b632
Show file tree
Hide file tree
Showing 2 changed files with 94 additions and 1 deletion.
7 changes: 6 additions & 1 deletion c_src/web.c
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,12 @@ double *calc_substellar(double phase, double *coords){
lambda0 = lambda0 + 2*M_PI;
}

phi0 = atan(coords[1]/coords[2]);
if(coords[2] == 0){
phi0 = 0;
}
else{
phi0 = atan(coords[1]/coords[2]);
}

output[0] = lambda0;
output[1] = phi0;
Expand Down
88 changes: 88 additions & 0 deletions spiderman/params.py
Original file line number Diff line number Diff line change
Expand Up @@ -412,3 +412,91 @@ def lightcurve(self,t,use_phase=False,stellar_grid=False,eclipse=True):

out = _web.lightcurve(self.n_layers,t,self.t0,self.per,self.a_abs,self.inc,self.ecc,self.w,self.a,self.rp,self.p_u1,self.p_u2,self.brightness_type,brightness_params,teffs,totals,len(totals),ec)
return np.array(out)

def eclipse_depth(self,phase=0.5,stellar_grid=False):

brightness_params = self.format_bright_params()

if self.thermal == True:
if stellar_grid == False:
star_grid = sp.stellar_grid.gen_grid(self.l1,self.l2,logg=4.5)
teffs = star_grid[0]
totals = star_grid[1]
else:
teffs = stellar_grid[0]
totals = stellar_grid[1]
else:
teffs = []
totals = []

t = 0.0 + np.array([phase])

if(self.inc == None):
self.inc = 90.0

if(self.p_u1 == None):
self.p_u1 = 0.0

if(self.p_u2 == None):
self.p_u2 = 0.0

if(self.a == None):
self.a = 4.0

if(self.w == None):
self.w = 0.0

if(self.ecc == None):
self.ecc = 0.0


if(self.a_abs == None):
self.a_abs = 1.0

out = _web.lightcurve(self.n_layers,t,0.0,1.0,self.a_abs,self.inc,0.0,0.0,self.a,self.rp,self.p_u1,self.p_u2,self.brightness_type,brightness_params,teffs,totals,len(totals),0)[0] - _web.lightcurve(self.n_layers,t,0.0,1.0,self.a_abs,self.inc,0.0,0.0,self.a,self.rp,self.p_u1,self.p_u2,self.brightness_type,brightness_params,teffs,totals,len(totals),1)[0]

return np.array(out)

def phase_brightness(self,phase,stellar_grid=False):

brightness_params = self.format_bright_params()

if self.thermal == True:
if stellar_grid == False:
star_grid = sp.stellar_grid.gen_grid(self.l1,self.l2,logg=4.5)
teffs = star_grid[0]
totals = star_grid[1]
else:
teffs = stellar_grid[0]
totals = stellar_grid[1]
else:
teffs = []
totals = []

t = 0.0 + np.array([phase])

if(self.inc == None):
self.inc = 90.0

if(self.p_u1 == None):
self.p_u1 = 0.0

if(self.p_u2 == None):
self.p_u2 = 0.0

if(self.a == None):
self.a = 4.0

if(self.w == None):
self.w = 0.0

if(self.ecc == None):
self.ecc = 0.0


if(self.a_abs == None):
self.a_abs = 1.0

out = _web.lightcurve(self.n_layers,t,0.0,1.0,self.a_abs,self.inc,0.0,0.0,self.a,self.rp,self.p_u1,self.p_u2,self.brightness_type,brightness_params,teffs,totals,len(totals),0)[0] - 1.0

return np.array(out)

0 comments on commit 183b632

Please sign in to comment.