-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathSimpleCtxTest.py
39 lines (33 loc) · 1.26 KB
/
SimpleCtxTest.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
from lightweaver.fal import Falc82
from lightweaver.rh_atoms import H_6_atom, H_6_CRD_atom, H_3_atom, C_atom, O_atom, OI_ord_atom, Si_atom, Al_atom, CaII_atom, Fe_atom, FeI_atom, He_9_atom, He_atom, He_large_atom, MgII_atom, N_atom, Na_atom, S_atom
import lightweaver as lw
import matplotlib.pyplot as plt
import time
import pickle
import numpy as np
from tqdm import tqdm
plt.ion()
def iterate_ctx_crd(ctx, Nscatter=10, NmaxIter=500):
for i in range(NmaxIter):
dJ = ctx.formal_sol_gamma_matrices()
if i < Nscatter:
continue
delta = ctx.stat_equil()
if dJ < 3e-3 and delta < 1e-3:
print(i)
print('----------')
return
def synth_spectrum(atmos, depthData=False):
atmos.convert_scales()
atmos.quadrature(5)
aSet = lw.RadiativeSet([H_6_atom(), C_atom(), OI_ord_atom(), Si_atom(), Al_atom(), CaII_atom(), Fe_atom(), He_9_atom(), MgII_atom(), N_atom(), Na_atom(), S_atom()])
aSet.set_active('H', 'He', 'Ca', 'O')
spect = aSet.compute_wavelength_grid()
eqPops = aSet.compute_eq_pops(atmos)
ctx = lw.Context(atmos, spect, eqPops, Nthreads=8)
if depthData:
ctx.depthData.fill = True
iterate_ctx_crd(ctx)
return ctx
atmos = Falc82()
ctx = synth_spectrum(atmos)