@@ -254,6 +254,18 @@ def wrapper(*args, **kwargs):
254254 ['Vg_sed' , 'w' ],
255255 ['pfull' , 'pstd' , 'zstd' , 'zagl' ]
256256 ],
257+ 'dustref_per_pa' : [
258+ "Dust opacity per Pascal [dustref/delp]" ,
259+ 'op/Pa' ,
260+ ['dustref' , 'delp' ],
261+ ['pfull' ]
262+ ],
263+ 'dustref_per_km' : [
264+ "Dust opacity per kilometer [dustref/delz]" ,
265+ 'op/km' ,
266+ ['dustref' , 'delz' ],
267+ ['pfull' ]
268+ ],
257269 'wdir' : [
258270 "Wind direction" ,
259271 'degree' ,
@@ -1173,6 +1185,59 @@ def compute_w_net(Vg, wvar):
11731185 return w_net
11741186
11751187
1188+
1189+ # =====================================================================
1190+ def compute_dustref_per_pa (dustref , delp ):
1191+ """
1192+ Computes visible dust opacity per Pascal from dustref and delp.
1193+ dustref is visible dust opacity per level (model layer).
1194+
1195+ opacity per Pa = opacity per layer / layer thickness in Pa::
1196+
1197+ dustref_per_pa = dustref/delp
1198+
1199+ [Courtney Batterson, 2025]
1200+
1201+ :param dustref: Visible dust opacity [op/model layer]
1202+ :type dustref: array [time, lev, lat, lon]
1203+ :param delp: Layer thickness [Pa]
1204+ :type delp: array [time, lev, lat, lon]
1205+ :return: `dustref_per_pa` Visible dust opacity [op/Pa]
1206+ :rtype: array [time, lev, lat, lon]
1207+ :raises ValueError: If the input dimensions are not compatible
1208+ :raises TypeError: If the input types are not compatible
1209+ :raises Exception: If any other error occurs
1210+ """
1211+
1212+ dustref_per_pa = dustref / delp
1213+ return dustref_per_pa
1214+
1215+ # =====================================================================
1216+ def compute_dustref_per_z (dustref , delz ):
1217+ """
1218+ Computes visible dust opacity per kilometer from dustref and delz.
1219+ dustref is visible dust opacity per level (model layer).
1220+
1221+ opacity per km = opacity per layer / layer thickness in m * 1000::
1222+
1223+ dustref_per_z = dustref/delz*1000
1224+
1225+ [Courtney Batterson, 2025]
1226+
1227+ :param dustref: Visible dust opacity [op/model layer]
1228+ :type dustref: array [time, lev, lat, lon]
1229+ :param delz: Layer thickness [m]
1230+ :type delz: array [time, lev, lat, lon]
1231+ :return: `dustref_per_z` Visible dust opacity [op/km]
1232+ :rtype: array [time, lev, lat, lon]
1233+ :raises ValueError: If the input dimensions are not compatible
1234+ :raises TypeError: If the input types are not compatible
1235+ :raises Exception: If any other error occurs
1236+ """
1237+
1238+ dustref_per_z = dustref / delz * 1000
1239+ return dustref_per_z
1240+
11761241# =====================================================================
11771242def compute_theta (p_3D , ps , T , f_type ):
11781243 """
@@ -1906,9 +1971,9 @@ def process_add_variables(file_name, add_list, master_list, debug=False):
19061971 f"file:{ Nclr } " )
19071972 for var , actual_var in already_in_file :
19081973 if var == actual_var :
1909- print (f"{ Yellow } - { var } { Nclr } " )
1974+ print (f"{ Yellow } - { var } { Nclr } " )
19101975 else :
1911- print (f"{ Yellow } - { var } (as '{ actual_var } '){ Nclr } " )
1976+ print (f"{ Yellow } - { var } (as '{ actual_var } '){ Nclr } " )
19121977 return
19131978
19141979
@@ -2101,6 +2166,16 @@ def add_with_dependencies(var):
21012166 wvar = f .variables ["w" ][:]
21022167 OUT = compute_w_net (Vg , wvar )
21032168
2169+ if var == "dustref_per_pa" :
2170+ dustref = f .variables ["dustref" ][:]
2171+ delp = f .variables ["delp" ][:]
2172+ OUT = compute_dustref_per_pa (dustref , delp )
2173+
2174+ if var == "dustref_per_z" :
2175+ dustref = f .variables ["dustref" ][:]
2176+ delz = f .variables ["delz" ][:]
2177+ OUT = compute_dustref_per_z (dustref , delz )
2178+
21042179 if var == "pfull3D" :
21052180 OUT = p_3D
21062181
0 commit comments