-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathstellar_funs.py
46 lines (34 loc) · 1.56 KB
/
stellar_funs.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
import numpy as np
from scipy.interpolate import interp1d
def main_sun_fun(time,stellar_mass,tsat_XUV,beta_XUV,fsat):
if stellar_mass == 1.0:
stellar_data = np.loadtxt('Baraffe3.txt',skiprows=31) # for reproducing sun exactly
else:
print ("This version of code is only set up for solar mass stars")
return [time*0,time*0,time*0,time*0]
stellar_array=[]
for i in range(0,len(stellar_data[:,0])):
if stellar_data[i,0] == stellar_mass:
stellar_array.append(stellar_data[i,:])
stellar_array=np.array(stellar_array)
min_time = np.min(stellar_array[:,1])
max_time = np.max(stellar_array[:,1])
if (min_time>np.min(time) ) or (max_time<np.max(time)):
print ("Problem: exceeding time range for stellar data")
time_array = stellar_array[:,1]
Total_Lum = (10**stellar_array[:,4])
ratio_out = [] # For XUV ratio
for i in range(0,len(time_array)):
if time_array[i]<tsat_XUV:
ratio= fsat
else:
ratio = fsat*(time_array[i]/tsat_XUV)**beta_XUV
ratio_out.append(ratio)
XUV_Lum = ratio_out*Total_Lum
Total_fun = interp1d(time_array,Total_Lum)
XUV_fun = interp1d(time_array,XUV_Lum)
Relative_total_Lum = Total_fun(time)
Relative_XUV_lum = XUV_fun(time)
Absolute_total_Lum = Relative_total_Lum*3.828e26
Absolute_XUV_Lum = Relative_XUV_lum*3.828e26
return [Relative_total_Lum,Relative_XUV_lum,Absolute_total_Lum,Absolute_XUV_Lum ]