-
Notifications
You must be signed in to change notification settings - Fork 0
/
discostar_spreadsheet.py
164 lines (135 loc) · 7.02 KB
/
discostar_spreadsheet.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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
#from __future__ import print_function
import numpy as np
import subprocess
import gspread
from oauth2client.service_account import ServiceAccountCredentials
direct = "./LC2" # directory for LC`s
scope = ['https://spreadsheets.google.com/feeds']
creds = ServiceAccountCredentials.from_json_keyfile_name('../discostar_parameters/client_secret.json', scope)
client = gspread.authorize(creds)
#sheet = client.open("Discostar").sheet1
sheet = client.open("Discostar").get_worksheet(5)
parameter_name = sheet.row_values(1) # 1st row in google spreadsheet -- names of the parameters
parameter_name = [x for x in parameter_name if x != ''] # deleting empty strings
p = {}
for i, x in enumerate(parameter_name):
p[x] = sheet.col_values(i+1)[1:]
p[x] = [u for u in p[x] if u != '']
p[x] = [u if x == 'DATA' else float(u) for u in p[x]]
#for x in parameter_name:
# print p[x][0]
for i, x in enumerate(p['DATA']):
z_tilt = p['z_tilt'][i]
Lx = p['Lx'][i]
y_tilt = p['y_tilt'][i]
y_tilt2 = p['y_tilt2'][i]
z_tilt2 = p['z_tilt2'][i]
T_disk = p['T_disk'][i]
h = p['h'][i]
R = p['R'][i]
picture = p['picture'][i]
inclination = p['inclination'][i]
q = p['q'][i]
mu = p['mu'][i]
beta = p['beta'][i]
u = p['u'][i]
albedo = p['albedo'][i]
lc_num = p['lc_num'][i]
star_tiles = p['star_tiles'][i]
disk_tiles = p['disk_tiles'][i]
threads = p['threads'][i]
T_star = p['T_star'][i]
lambda_A = p['lambda_A'][i]
a = p['a'][i]
PSI_pr = p['PSI_pr'][i]
kappa = p['kappa'][i]
isotrope = p['isotrope'][i]
Lx_disk = p['Lx_disk'][i]
Lx_disk_2 = p['Lx_disk_2'][i]
Lx_iso = p['Lx_iso'][i]
spot_disk = p['spot_disk'][i]
T_spot = p['T_spot'][i]
spot_beg = p['spot_beg'][i]
spot_end = p['spot_end'][i]
ns_theta = p['ns_theta'][i]
spot_rho_in = p['spot_rho_in'][i]
spot_rho_out = p['spot_rho_out'][i]
drd_phi = p['drd_phi'][i]
drd_theta = p['drd_theta'][i]
if picture == 0:
#output = 'LC.data'
output = 'LC_Lx_{Lx}_{Lx_disk}_{Lx_disk_2}_{Lx_iso}_NS_{PSI_pr}_{kappa}_{ns_theta}_h_R_{h}_{R}_tilt_{y_tilt}_{z_tilt}_{y_tilt2}_{z_tilt2}_Td_{T_disk}_spot_{spot_disk}_{T_spot}_{spot_beg}_{spot_end}_drd_{drd_phi}_{drd_theta}_i_{inclination}.data'
if (isotrope == 0 and spot_disk != 0):
output_filename = output.format(Lx=Lx, Lx_disk=Lx_disk, Lx_disk_2=Lx_disk_2, Lx_iso=Lx_iso, PSI_pr=PSI_pr, kappa=kappa, ns_theta=ns_theta, h=h, R=R, y_tilt=y_tilt, z_tilt=z_tilt, y_tilt2=y_tilt2, z_tilt2=z_tilt2, T_disk = T_disk, spot_disk=spot_disk, T_spot=T_spot, spot_beg=spot_beg, spot_end=spot_end, drd_phi=drd_phi, drd_theta=drd_theta, inclination=inclination)
elif (isotrope == 1 and spot_disk != 0):
output_filename = output.format(Lx=Lx, Lx_disk=Lx_disk, Lx_disk_2=Lx_disk_2, Lx_iso=Lx_iso, PSI_pr='', kappa='', ns_theta='', h=h, R=R, y_tilt=y_tilt, z_tilt=z_tilt, y_tilt2=y_tilt2, z_tilt2=z_tilt2, T_disk = T_disk, spot_disk=spot_disk, T_spot=T_spot, spot_beg=spot_beg, spot_end=spot_end, drd_phi=drd_phi, drd_theta=drd_theta, inclination=inclination)
elif (isotrope == 1 and spot_disk == 0):
output_filename = output.format(Lx=Lx, Lx_disk=Lx_disk, Lx_disk_2=Lx_disk_2, Lx_iso=Lx_iso, PSI_pr='', kappa='', ns_theta='', h=h, R=R, y_tilt=y_tilt, z_tilt=z_tilt, y_tilt2=y_tilt2, z_tilt2=z_tilt2, T_disk = T_disk, spot_disk=spot_disk, T_spot='', spot_beg='', spot_end='', drd_phi=drd_phi, drd_theta=drd_theta, inclination=inclination)
elif (isotrope == 0 and spot_disk == 0):
output_filename = output.format(Lx=Lx, Lx_disk=Lx_disk, Lx_disk_2=Lx_disk_2, Lx_iso=Lx_iso, PSI_pr=PSI_pr, kappa=kappa, ns_theta=ns_theta, h=h, R=R, y_tilt=y_tilt, z_tilt=z_tilt, y_tilt2=y_tilt2, z_tilt2=z_tilt2, T_disk = T_disk, spot_disk=spot_disk, T_spot='', spot_beg='', spot_end='', drd_phi=drd_phi, drd_theta=drd_theta, inclination=inclination)
elif picture == 1:
output_filename = 'VIEW.data'
arg = ('./disco' + ' ' +
str(p['q'][i]) + ' ' +
str(p['mu'][i]) + ' ' +
str(p['beta'][i]) + ' ' +
str(p['u'][i]) + ' ' +
str(p['albedo'][i]) + ' ' +
str(p['Lx'][i]) + ' ' +
str(p['h'][i]) + ' ' +
str(p['R'][i]) + ' ' +
str(p['y_tilt'][i]) + ' ' +
str(p['z_tilt'][i]) + ' ' +
str(p['picture'][i]) + ' ' +
str(p['inclination'][i]) + ' ' +
str(int(p['lc_num'][i])) + ' ' +
str(int(p['star_tiles'][i])) + ' ' +
str(int(p['disk_tiles'][i])) + ' ' +
str(int(p['threads'][i])) + ' ' +
str(p['T_disk'][i]) + ' ' +
str(p['T_star'][i]) + ' ' +
str(p['lambda_A'][i]) + ' ' +
str(p['a'][i]) + ' ' +
str(p['y_tilt2'][i]) + ' ' +
str(p['z_tilt2'][i]) + ' ' +
str(p['PSI_pr'][i]) + ' ' +
str(p['kappa'][i]) + ' ' +
str(p['isotrope'][i]) + ' ' +
str(p['Lx_disk'][i]) + ' ' +
str(p['spot_disk'][i]) + ' ' +
str(p['T_spot'][i]) + ' ' +
str(p['spot_beg'][i]) + ' ' +
str(p['spot_end'][i]) + ' ' +
str(p['ns_theta'][i]) + ' ' +
str(p['spot_rho_in'][i]) + ' ' +
str(p['spot_rho_out'][i]) + ' ' +
str(p['drd_phi'][i]) + ' ' +
str(p['drd_theta'][i]) + ' ' +
str(p['Lx_disk_2'][i]) + ' ' +
str(p['Lx_iso'][i])
)
#if picture == 0:
# print 'discostar calculates the lightcurve ...'
#elif picture == 1:
# print 'discostar draws the picture ...'
f = open('./'+direct+'/'+output_filename, "w")
subprocess.call(arg, stdout=f, shell=True)
#subprocess.call(arg, shell=True)
f.close
#print 'done'
if picture == 0:
#print 'lightcurve written to', output_filename
#print '\n'
#print '\n'
if (spot_disk != 0 and isotrope == 0):
print '"../LC2/%s" @legend "%3.0f (%3.0f %2.0f %2.0f) (%3.0f %2.0f %2.0f) h=%1.2f R=%1.2f (%1.1e %1.1e) Td=%5.0f SPOT %d",\\' % (output_filename,z_tilt,PSI_pr,kappa,ns_theta,z_tilt2,y_tilt,y_tilt2,h,R,Lx,Lx_iso,T_disk,spot_disk)
elif (spot_disk != 0 and isotrope == 1):
print '"../LC2/%s" @legend "%3.0f ISO (%3.0f %2.0f %2.0f) h=%1.2f R=%1.2f (%1.1e %1.1e) Td=%5.0f SPOT %d",\\' % (output_filename,z_tilt,z_tilt2,y_tilt,y_tilt2,h,R,Lx,Lx_iso,T_disk,spot_disk)
elif (spot_disk == 0 and isotrope == 1):
print '"../LC2/%s" @legend "%3.0f ISO (%3.0f %2.0f %2.0f) h=%1.2f R=%1.2f (%1.1e %1.1e) Td=%5.0f",\\' % (output_filename,z_tilt,z_tilt2,y_tilt,y_tilt2,h,R,Lx,Lx_iso,T_disk)
elif (spot_disk == 0 and isotrope == 0):
print '"../LC2/%s" @legend "%3.0f (%3.0f %2.0f %2.0f) (%3.0f %2.0f %2.0f) h=%1.2f R=%1.2f (%1.1e %1.1e) Td=%5.0f",\\' % (output_filename,z_tilt,PSI_pr,kappa,ns_theta,z_tilt2,y_tilt,y_tilt2,h,R,Lx,Lx_iso,T_disk)
#print '\n'
#print '\n'
#elif picture == 1:
# print 'data for picture written to', output_filename