1212from .optics import compute_opacity
1313from .disco import compress_thermal
1414from .deq_chem import get_quench_levels
15-
16- import os
15+ from .io_utils import write_all_profiles
1716
1817from collections import namedtuple
1918
@@ -72,7 +71,7 @@ def run_diseq_climate_workflow(bundle, nofczns, nstr, temp, pressure,
7271 rfaci ,rfacv ,tidal ,
7372 Opagrid ,
7473 CloudParameters ,
75- save_profile ,all_profiles ,all_opd ,
74+ save_all_profiles ,all_profiles ,all_opd ,
7675 verbose = True , moist = None ,
7776 save_kzz = False , self_consistent_kzz = True ):
7877 """ Can deprecate all of this since we moved to profile
@@ -163,7 +162,7 @@ def run_diseq_climate_workflow(bundle, nofczns, nstr, temp, pressure,
163162 rfaci ,rfacv ,tidal ,
164163 Opagrid ,
165164 CloudParameters ,
166- save_profile ,all_profiles ,all_opd ,
165+ save_all_profiles ,all_profiles ,all_opd ,
167166 convergence_criteria , final ,
168167 flux_net_ir_layer = None , flux_plus_ir_attop = None ,first_call_ever = False ,
169168 verbose = verbose , moist = moist ,
@@ -177,7 +176,7 @@ def run_diseq_climate_workflow(bundle, nofczns, nstr, temp, pressure,
177176 rfaci , rfacv , tidal ,
178177 Opagrid ,
179178 CloudParameters ,
180- save_profile , all_profiles , all_opd ,
179+ save_all_profiles , all_profiles , all_opd ,
181180 flux_net_ir_layer , flux_plus_ir_attop ,
182181 verbose = verbose , moist = moist ,
183182 save_kzz = save_kzz ,self_consistent_kzz = self_consistent_kzz ,diseq = True , all_kzz = all_kzz )
@@ -196,7 +195,7 @@ def run_chemeq_climate_workflow(bundle, nofczns, nstr, temp, pressure,
196195 rfaci ,rfacv ,tidal ,
197196 Opagrid ,
198197 CloudParameters ,
199- save_profile ,all_profiles ,all_opd ,
198+ save_all_profiles ,all_profiles ,all_opd ,
200199 verbose = True , moist = None ,
201200 save_kzz = True , self_consistent_kzz = True ):
202201
@@ -215,7 +214,7 @@ def run_chemeq_climate_workflow(bundle, nofczns, nstr, temp, pressure,
215214 rfaci , rfacv , tidal , #energy balance
216215 Opagrid , #delta_wno, tmin, tmax,
217216 CloudParameters ,#cloudy,cld_species,mh,fsed,beta,param_flag,mieff_dir ,opd_cld_climate,g0_cld_climate,w0_cld_climate, #scattering/cloud properties
218- save_profile ,all_profiles , all_opd ,
217+ save_all_profiles ,all_profiles , all_opd ,
219218 convergence_criteria , final ,
220219 first_call_ever = True , verbose = verbose , moist = moist ,
221220 save_kzz = save_kzz ,all_kzz = [],self_consistent_kzz = self_consistent_kzz )
@@ -238,11 +237,11 @@ def run_chemeq_climate_workflow(bundle, nofczns, nstr, temp, pressure,
238237 rfaci , rfacv , tidal , #energy balance
239238 Opagrid , #delta_wno, tmin, tmax,
240239 CloudParameters ,#cloudy,cld_species,mh,fsed,beta,param_flag,mieff_dir ,opd_cld_climate,g0_cld_climate,w0_cld_climate, #scattering/cloud properties
241- save_profile ,all_profiles , all_opd ,
240+ save_all_profiles ,all_profiles , all_opd ,
242241 convergence_criteria ,final ,
243242 flux_net_ir_layer = flux_net_ir_layer , flux_plus_ir_attop = flux_plus_ir_attop ,
244243 verbose = verbose ,moist = moist ,
245- save_kzz = True ,all_kzz = all_kzz ,self_consistent_kzz = self_consistent_kzz )
244+ save_kzz = True ,all_kzz = all_kzz ,self_consistent_kzz = self_consistent_kzz )
246245
247246 #STEP 3) find strat that will now run profile several times, each time updating the opacities and chemistry
248247 #and also refine the convective zone guess while it does this.
@@ -254,7 +253,7 @@ def run_chemeq_climate_workflow(bundle, nofczns, nstr, temp, pressure,
254253 rfaci , rfacv , tidal ,
255254 Opagrid ,
256255 CloudParameters ,
257- save_profile , all_profiles , all_opd ,
256+ save_all_profiles , all_profiles , all_opd ,
258257 flux_net_ir_layer , flux_plus_ir_attop ,
259258 verbose = verbose , moist = moist ,self_consistent_kzz = self_consistent_kzz )
260259
@@ -731,7 +730,7 @@ def t_start(nofczns,nstr,convergence_criteria,#
731730 rfaci , rfacv , tidal ,
732731 Atmosphere , OpacityWEd , OpacityNoEd ,ScatteringPhase , Disco ,Opagrid , AdiabatBundle ,
733732 F0PI ,
734- save_profile , all_profiles ,
733+ save_all_profiles , all_profiles ,
735734 fhole = None , hole_OpacityWEd = None ,hole_OpacityNoEd = None ,
736735 verbose = 1 , do_holes = None ,
737736 moist = False , egp_stepmax = False ):
@@ -777,7 +776,7 @@ def t_start(nofczns,nstr,convergence_criteria,#
777776 Any info for the adiabat calculations such as the precomputed tables from Didie
778777 F0PI : ndarray
779778 Stellar spectrum if it exists otherwise this is just 1s array
780- save_profile : bool
779+ save_all_profiles : bool
781780 bool to specify if all intermediate profiles will be saved
782781 all_profiles : ndarray
783782 All saved profiles if it is requested
@@ -1454,7 +1453,7 @@ def t_start(nofczns,nstr,convergence_criteria,#
14541453
14551454 if verbose : print ("Iteration number " , its ,", min , max temp " , min (temp ),max (temp ), ", flux balance " , flux_net [0 ]/ abs (tidal [0 ])) #f/abs(tidal[0])**2) this other output here is slightly less straightforward with the square terms for exoplanets so making this just fnet/tidal for now
14561455
1457- if save_profile == 1 :
1456+ if save_all_profiles == 1 :
14581457 all_profiles = np .append (all_profiles ,temp_old )
14591458 cldsave_count += 1
14601459 if flag_converge == 2 : # converged
@@ -2395,7 +2394,7 @@ def find_strat(bundle, nofczns,nstr,
23952394 rfaci , rfacv , tidal ,
23962395 Opagrid ,
23972396 CloudParameters ,
2398- save_profile , all_profiles , all_opd ,
2397+ save_all_profiles , all_profiles , all_opd ,
23992398 flux_net_ir_layer , flux_plus_ir_attop ,
24002399 verbose = 1 , moist = None ,
24012400 save_kzz = False ,self_consistent_kzz = True ,diseq = False , all_kzz = []):
@@ -2457,7 +2456,7 @@ def find_strat(bundle, nofczns,nstr,
24572456 rfaci ,rfacv ,tidal ,
24582457 Opagrid ,
24592458 CloudParameters ,
2460- save_profile ,all_profiles ,all_opd ,
2459+ save_all_profiles ,all_profiles ,all_opd ,
24612460 convergence_criteria , final ,
24622461 flux_net_ir_layer = flux_net_ir_layer , flux_plus_ir_attop = flux_plus_ir_attop ,
24632462 verbose = verbose ,moist = moist ,
@@ -2504,7 +2503,7 @@ def find_strat(bundle, nofczns,nstr,
25042503 rfaci ,rfacv ,tidal ,
25052504 Opagrid ,
25062505 CloudParameters ,
2507- save_profile ,all_profiles ,all_opd ,
2506+ save_all_profiles ,all_profiles ,all_opd ,
25082507 convergence_criteria , final ,
25092508 flux_net_ir_layer = flux_net_ir_layer , flux_plus_ir_attop = flux_plus_ir_attop ,
25102509 verbose = verbose ,moist = moist ,
@@ -2547,7 +2546,7 @@ def find_strat(bundle, nofczns,nstr,
25472546 rfaci ,rfacv ,tidal ,
25482547 Opagrid ,
25492548 CloudParameters ,
2550- save_profile ,all_profiles ,all_opd ,
2549+ save_all_profiles ,all_profiles ,all_opd ,
25512550 convergence_criteria , final ,
25522551 flux_net_ir_layer = flux_net_ir_layer , flux_plus_ir_attop = flux_plus_ir_attop ,
25532552 verbose = verbose , moist = moist ,
@@ -2577,7 +2576,7 @@ def find_strat(bundle, nofczns,nstr,
25772576 rfaci ,rfacv ,tidal ,
25782577 Opagrid ,
25792578 CloudParameters ,
2580- save_profile ,all_profiles ,all_opd ,
2579+ save_all_profiles ,all_profiles ,all_opd ,
25812580 convergence_criteria , final ,
25822581 flux_net_ir_layer = flux_net_ir_layer , flux_plus_ir_attop = flux_plus_ir_attop ,
25832582 verbose = verbose , moist = moist ,
@@ -2602,15 +2601,15 @@ def find_strat(bundle, nofczns,nstr,
26022601 rfaci ,rfacv ,tidal ,
26032602 Opagrid ,
26042603 CloudParameters ,
2605- save_profile ,all_profiles ,all_opd ,
2604+ save_all_profiles ,all_profiles ,all_opd ,
26062605 convergence_criteria , final ,
26072606 flux_net_ir_layer = flux_net_ir_layer , flux_plus_ir_attop = flux_plus_ir_attop ,
26082607 verbose = verbose ,moist = moist ,
26092608 save_kzz = save_kzz ,self_consistent_kzz = self_consistent_kzz ,diseq = diseq , all_kzz = all_kzz )
26102609 #(mieff_dir, it_max_strat, itmx_strat, conv_strat, convt_strat, nofczns,nstr,x_max_mult,
26112610 #temp,pressure, F0PI, t_table, p_table, grad, cp,opacityclass, grav,
26122611 #rfaci, rfacv, nlevel, tidal, tmin, tmax, dwni, bb , y2 , tp, final,
2613- #cloudy, cld_species,mh,fsed,flag_hack,save_profile , all_profiles, all_opd,
2612+ #cloudy, cld_species,mh,fsed,flag_hack,save_all_profiles , all_profiles, all_opd,
26142613 #opd_cld_climate,g0_cld_climate,w0_cld_climate,beta, param_flag,flux_net_ir_layer,
26152614 #flux_plus_ir_attop, verbose=verbose,
26162615 #fhole=fhole, fthin_cld=fthin_cld, do_holes = do_holes, moist = moist, cold_trap = cold_trap)
@@ -2630,7 +2629,7 @@ def find_strat(bundle, nofczns,nstr,
26302629
26312630
26322631def update_clouds (bundle , CloudParameters , Atmosphere , kzz ,virga_kwargs ,
2633- verbose = False ,save_profile = True ,all_opd = []):
2632+ verbose = False ,save_all_profiles = True ,all_opd = []):
26342633 """
26352634 Updates cloud parameters and returns the cloud output.
26362635 """
@@ -2669,7 +2668,7 @@ def update_clouds(bundle, CloudParameters, Atmosphere, kzz,virga_kwargs,
26692668 taudif = np .max (np .abs (diff ))
26702669 taudif_tol = 0.4 * np .max (0.5 * (opd_clmt + opd_prev_cld_step ))
26712670
2672- if save_profile == 1 :
2671+ if save_all_profiles == 1 :
26732672 all_opd = np .append (all_opd , df_cld ['opd' ].values [55 ::196 ])
26742673
26752674 if verbose :
@@ -2684,7 +2683,7 @@ def profile(bundle, nofczns, nstr, temp, pressure,
26842683 rfaci ,rfacv ,tidal ,
26852684 Opagrid ,
26862685 CloudParameters ,
2687- save_profile ,all_profiles ,all_opd ,
2686+ save_all_profiles ,all_profiles ,all_opd ,
26882687 convergence_criteria , final ,
26892688 flux_net_ir_layer = None , flux_plus_ir_attop = None ,first_call_ever = False ,
26902689 verbose = True , moist = None ,
@@ -2762,7 +2761,7 @@ def profile(bundle, nofczns, nstr, temp, pressure,
27622761 temp [j1 ]= exp (log (temp [j1 - 1 ]) + grad_x * (log (pressure [j1 ]) - log (pressure [j1 - 1 ])))
27632762
27642763 temp_old = np .copy (temp )
2765- if save_profile == 1 : all_profiles = np .append (all_profiles ,temp_old )
2764+ if save_all_profiles == 1 : all_profiles = np .append (all_profiles ,temp_old )
27662765
27672766 ### 1) ALWAYS UPDATE PT, CHEM, OPACITIES
27682767 bundle .add_pt ( temp , pressure )
@@ -2801,7 +2800,7 @@ def profile(bundle, nofczns, nstr, temp, pressure,
28012800 ### 4) IF: COMPUTE CLOUDS
28022801 if cloudy :
28032802 cld_out ,df_cld , taudif , taudif_tol , all_opd , CloudParameters = update_clouds (bundle , CloudParameters ,Atmosphere ,
2804- kz ,virga_kwargs ,save_profile = save_profile ,
2803+ kz ,virga_kwargs ,save_all_profiles = save_all_profiles ,
28052804 all_opd = all_opd ,verbose = verbose )
28062805 bundle .clouds (df = df_cld ,** hole_kwargs )
28072806
@@ -2818,7 +2817,7 @@ def profile(bundle, nofczns, nstr, temp, pressure,
28182817 # dill.dump([bundle, nofczns,nstr,convergence_criteria, rfaci, rfacv, tidal,
28192818 # Atmosphere, OpacityWEd, OpacityNoEd,ScatteringPhase, Disco,Opagrid, AdiabatBundle,
28202819 # F0PI,
2821- # save_profile , all_profiles,
2820+ # save_all_profiles , all_profiles,
28222821 # verbose, moist , egp_stepmax ],file)
28232822
28242823 ## begin bigger loop which gets opacities
@@ -2829,15 +2828,15 @@ def profile(bundle, nofczns, nstr, temp, pressure,
28292828 nofczns ,nstr ,convergence_criteria , rfaci , rfacv , tidal ,
28302829 Atmosphere , OpacityWEd , OpacityNoEd ,ScatteringPhase , Disco ,Opagrid , AdiabatBundle ,
28312830 F0PI ,
2832- save_profile , all_profiles ,
2831+ save_all_profiles , all_profiles ,
28332832 verbose = verbose , moist = moist , egp_stepmax = egp_stepmax ,
28342833 do_holes = do_holes , fhole = fhole , hole_OpacityWEd = OpacityWEd_clear ,hole_OpacityNoEd = OpacityNoEd_clear )
28352834 else :
28362835 temp , dtdp , all_profiles , flux_net_ir_layer ,flux_net_v_layer , flux_plus_ir_attop = t_start (
28372836 nofczns ,nstr ,convergence_criteria , rfaci , rfacv , tidal ,
28382837 Atmosphere , OpacityWEd , OpacityNoEd ,ScatteringPhase , Disco ,Opagrid , AdiabatBundle ,
28392838 F0PI ,
2840- save_profile , all_profiles ,
2839+ save_all_profiles , all_profiles ,
28412840 verbose = verbose , moist = moist , egp_stepmax = egp_stepmax )
28422841
28432842 ### 1) ALWAYS UPDATE PT, CHEM, OPACITIES
@@ -2880,13 +2879,13 @@ def profile(bundle, nofczns, nstr, temp, pressure,
28802879 ### 4) IF: COMPUTE CLOUDS
28812880 if cloudy :
28822881 cld_out ,df_cld , taudif , taudif_tol , all_opd , CloudParameters = update_clouds (bundle , CloudParameters ,Atmosphere ,
2883- kz ,virga_kwargs ,save_profile = save_profile ,
2882+ kz ,virga_kwargs ,save_all_profiles = save_all_profiles ,
28842883 all_opd = all_opd ,verbose = verbose )
28852884 bundle .clouds (df = df_cld ,** hole_kwargs )
28862885 else :
28872886 cld_out = np .nan
28882887
2889- if save_profile and cloudy :
2888+ if save_all_profiles and cloudy :
28902889 all_opd = np .append (all_opd ,df_cld ['opd' ].values [55 ::196 ]) #save opd at 4 micron
28912890
28922891 ### 5) IF NEEDED: COMPUTE OPACITIES
@@ -2928,6 +2927,7 @@ def profile(bundle, nofczns, nstr, temp, pressure,
29282927
29292928 if verbose : print ("Big iteration is " ,min (temp ), iii )
29302929
2930+ write_all_profiles (save_all_profiles , all_profiles )
29312931 if conv_flag == 0 :
29322932 if verbose : print ("Not converged" )
29332933 else :
0 commit comments