From f49547978efb77ad4b22d45e0a98bd5ff94aded8 Mon Sep 17 00:00:00 2001 From: ryba183 Date: Fri, 8 May 2020 14:23:08 +0200 Subject: [PATCH 1/2] Parcel new function added --- parcel.py | 29 +++++++++++++++++++++++++---- 1 file changed, 25 insertions(+), 4 deletions(-) diff --git a/parcel.py b/parcel.py index 6b3286d..361f82b 100755 --- a/parcel.py +++ b/parcel.py @@ -152,12 +152,14 @@ def _stats(state, info): info["RH_max"] = max(info["RH_max"], state["RH"]) def _output_bins(fout, t, micro, opts, spectra): + for dim, dct in spectra.iteritems(): for bin in range(dct["nbin"]): if dct["drwt"] == 'wet': micro.diag_wet_rng( fout.variables[dim+"_r_wet"][bin], fout.variables[dim+"_r_wet"][bin] + fout.variables[dim+"_dr_wet"][bin] + ) elif dct["drwt"] == 'dry': micro.diag_dry_rng( @@ -166,6 +168,11 @@ def _output_bins(fout, t, micro, opts, spectra): ) else: raise Exception("drwt should be wet or dry") + + if dct["drwt"] == 'wet': + micro.diag_dry_mom(1) + fout.variables[dim+'_dry_m_1'][int(t), int(bin)] = np.frombuffer(micro.outbuf()) + for vm in dct["moms"]: if type(vm) == int: # calculating moments @@ -190,7 +197,7 @@ def _output_init(micro, opts, spectra): tmp = name + '_r_' + dct["drwt"] fout.createVariable(tmp, 'd', (name,)) fout.variables[tmp].unit = "m" - fout.variables[tmp].description = "particle wet radius (left bin edge)" + fout.variables[tmp].description = "particle "+dct["drwt"]+" radius (left bin edge)" tmp = name + '_dr_' + dct["drwt"] fout.createVariable(tmp, 'd', (name,)) @@ -215,9 +222,17 @@ def _output_init(micro, opts, spectra): fout.variables[name+'_'+vm].unit = 'kg of chem species dissolved in cloud droplets (kg of dry air)^-1' else: assert(type(vm)==int) + fout.createVariable(name+'_m'+str(vm), 'd', ('t',name)) - fout.variables[name+'_m'+str(vm)].unit = 'm^'+str(vm)+' (kg of dry air)^-1' + fout.variables[name+'_m'+str(vm)].unit = 'micrometer' + + fout.createVariable(name+'_dry_m_'+str(vm), 'd', ('t',name)) + fout.variables[name+'_dry_m_'+str(vm)].unit = ' m^'+str(vm)+' (kg of dry air)^-1' + fout.createVariable('number_of_rc_m0', 'd', ('t')) + fout.createVariable('number_of_rc_m1', 'd', ('t')) + fout.variables['number_of_rc_m0'].unit = 'm^'+str(vm)+' (kg of dry air)^-1' + fout.variables['number_of_rc_m1'].unit = 'micrometer' units = {"z" : "m", "t" : "s", "r_v" : "kg/kg", "th_d" : "K", "rhod" : "kg/m3", "p" : "Pa", "T" : "K", "RH" : "1" } @@ -242,6 +257,12 @@ def _save_attrs(fout, dictnr): setattr(fout, var, val) def _output(fout, opts, micro, state, rec, spectra): + micro.diag_rw_ge_rc() + micro.diag_wet_mom(0) + fout.variables['number_of_rc_m0'][int(rec)] = np.frombuffer(micro.outbuf()) + micro.diag_rw_ge_rc() + micro.diag_wet_mom(1) + fout.variables['number_of_rc_m1'][int(rec)] = np.frombuffer(micro.outbuf()) _output_bins(fout, rec, micro, opts, spectra) _output_save(fout, state, rec) @@ -488,8 +509,8 @@ def _arguments_checking(opts, spectra, aerosol): if gstdev <= 0: raise Exception("standard deviation should be > 0 for aerosol[" + name + "]") # necessary? - if gstdev == 1.: - raise Exception("standard deviation should be != 1 to avoid monodisperse distribution for aerosol[" + name + "]") + # if gstdev == 1.: + # raise Exception("standard deviation should be != 1 to avoid monodisperse distribution for aerosol[" + name + "]") for name, dct in spectra.iteritems(): # TODO: check if name is valid netCDF identifier From 894f765c9099d24f724a01ad9f41e10bb88efbc5 Mon Sep 17 00:00:00 2001 From: ryba183 Date: Sat, 9 May 2020 23:36:56 +0200 Subject: [PATCH 2/2] Critical moments --- parcel.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/parcel.py b/parcel.py index 361f82b..d07d30b 100755 --- a/parcel.py +++ b/parcel.py @@ -224,7 +224,7 @@ def _output_init(micro, opts, spectra): assert(type(vm)==int) fout.createVariable(name+'_m'+str(vm), 'd', ('t',name)) - fout.variables[name+'_m'+str(vm)].unit = 'micrometer' + fout.variables[name+'_m'+str(vm)].unit = ' m^'+str(vm)+' (kg of dry air)^-1' fout.createVariable(name+'_dry_m_'+str(vm), 'd', ('t',name)) fout.variables[name+'_dry_m_'+str(vm)].unit = ' m^'+str(vm)+' (kg of dry air)^-1'