@@ -220,6 +220,17 @@ def readWACCM(waccmMusicaDict, latitude, longitude,
220220 return (musicaDict )
221221
222222
223+ # Add molecular Nitrogen, Oxygen, and Argon to dictionary.
224+ # varValues = already read from WACCM, contains (name, concentration, units)
225+ # return varValues with N2, O2, and Ar added
226+ def addStandardGases (varValues ):
227+ varValues ["N2" ] = ("N2" , 0.78084 , "mol/mol" ) # standard fraction by volume
228+ varValues ["O2" ] = ("O2" , 0.20946 , "mol/mol" )
229+ varValues ["Ar" ] = ("Ar" , 0.00934 , "mol/mol" )
230+
231+ return (varValues )
232+
233+
223234# set up indexes for the tuple
224235musicaIndex = 0
225236valueIndex = 1
@@ -268,7 +279,7 @@ def writeInitCSV(initValues, filename):
268279 else :
269280 fp .write ("," )
270281
271- fp .write (key )
282+ fp .write ("{} [{}]" . format ( key , value [ unitIndex ]) )
272283 fp .write ("\n " )
273284
274285 # write the variable values
@@ -404,9 +415,19 @@ def main():
404415 if ("longitude" in myArgs ):
405416 lon = safeFloat (myArgs .get ("longitude" ))
406417
418+ # get the requested (diagnostic) output
419+ outputCSV = False
420+ outputJSON = False
421+ if ("output" in myArgs ):
422+ # parameter is like: output=CSV,JSON
423+ outputFormats = myArgs .get ("output" ).split ("," )
424+ outputFormats = [lowFormat .lower () for lowFormat in outputFormats ]
425+ outputCSV = "csv" in outputFormats
426+ outputJSON = "json" in outputFormats
427+
428+ # locate the WACCM output file
407429 when = datetime .datetime .strptime (
408430 f"{ dateStr } { timeStr } " , "%Y%m%d %H:%M" )
409-
410431 waccmFilename = f"f.e22.beta02.FWSD.f09_f09_mg17.cesm2_2_beta02.forecast.001.cam.h3.{ when .year :4d} -{ when .month :02d} -{ when .day :02} -00000.nc"
411432
412433 # read and glean chemical species from WACCM and MUSICA
@@ -425,16 +446,19 @@ def main():
425446 lat , lon , when , waccmDir , waccmFilename )
426447 logger .info (f"Original WACCM varValues = { varValues } " )
427448
449+ # add molecular Nitrogen, Oxygen, and Argon
450+ varValues = addStandardGases (varValues )
451+
428452 # Perform any conversions needed, or derive variables.
429453 varValues = convertWaccm (varValues )
430454 logger .info (f"Converted WACCM varValues = { varValues } " )
431455
432- if (False ):
456+ if (outputCSV ):
433457 # Write CSV file for MusicBox initial conditions.
434458 csvName = os .path .join (musicaDir , "initial_conditions.csv" )
435459 writeInitCSV (varValues , csvName )
436460
437- if (False ):
461+ if (outputJSON ):
438462 # Write JSON file for MusicBox initial conditions.
439463 jsonName = os .path .join (musicaDir , "initial_config.json" )
440464 writeInitJSON (varValues , jsonName )
0 commit comments