diff --git a/configurations/augsburg_validation_summer_10.conf b/configurations/augsburg_validation_summer_10.conf index c85f1740b8f9490f89d2ce5ac6b2103f8765d1e2..9f312da93ea448fabf20398b616c285986645d35 100644 --- a/configurations/augsburg_validation_summer_10.conf +++ b/configurations/augsburg_validation_summer_10.conf @@ -9,10 +9,12 @@ nested_domain = False # dynamic driver output dynamic_driver_file = "/cfs/home/d/u/dupreeda/MBEES/PALM/palm_model_system-v21.10/JOBS/augs12/INPUT/augs12_dynamic" + # import grid parameters for dynamic driver from static driver grid_from_static = True # static driver input static_driver_file = "/cfs/home/d/u/dupreeda/MBEES/PALM/palm_model_system-v21.10/JOBS/augs12/INPUT/augs12_static" + # reference coordinate system of PALM simulation proj_palm = "EPSG:32633" # projection lon-lat @@ -21,7 +23,7 @@ proj_wgs84 = 'EPSG:4326' # vertical grid dz = 10.0 nz = 80 # z in grids -dz_stretch_level = 900.0 # in meters +dz_stretch_level = 900.0 # in meters dz_stretch_factor = 1.0 dz_max = 20.0 @@ -37,13 +39,13 @@ vinterp_terrain_smoothing = None # interpolated files interp_dir_name = '/cfs/home/d/u/dupreeda/MBEES/PALM/wrf_chem_data/interp' -# WRF-chem species need for chemical reaction -wrfchem_spec = ['no','no2','o3'] +# WRF-chem gaseous species +wrfchem_spec = ['no', 'no2','hno3', 'nh3', 'h2so4', 'ocnv','ocsv'] -# Aerosol profile - SALSA parameters +# Salsa parameters (only aerosol species) aerosol_wrfchem = True wrfchem_bin_limits = [3.9e-8, 1.56e-7, 6.25e-7, 2.5e-6, 1.0e-5] -listspec = ['SO4', 'NH', 'NO'] +listspec = ['OC', 'NH', 'NO'] nbin = [1,7] reglim = [3.9e-8, 5.0e-8, 2.5e-6] nf2a = 1.0 diff --git a/configurations/mbees_rans_test_100.conf b/configurations/mbees_rans_test_100.conf new file mode 100644 index 0000000000000000000000000000000000000000..3b352a36c289296b2c3de6a29f195467b57ee3a7 --- /dev/null +++ b/configurations/mbees_rans_test_100.conf @@ -0,0 +1,56 @@ +# Test case for developing WRF-CHEM for PALM +# see GMD: https://doi.org/10.5194/gmd-2020-175 + +# PALM case, domain, and configuration parameters +domain = 'mbees' +resolution = '100' +scenario = 'rans_test' +nested_domain = False + +# dynamic driver output +dynamic_driver_file = "/cfs/home/d/u/dupreeda/MBEES/PALM/palm_model_system-v21.10/JOBS/mbees/INPUT/mbees_dynamic" + +# import grid parameters for dynamic driver from static driver +grid_from_static = True +# static driver input +static_driver_file = "/cfs/home/d/u/dupreeda/MBEES/PALM/palm_model_system-v21.10/JOBS/mbees/INPUT/mbees_static" + +# reference coordinate system of PALM simulation +proj_palm = "EPSG:32633" +# projection lon-lat +proj_wgs84 = 'EPSG:4326' + +# vertical grid +dz = 5.0 +nz = 80 # z in grids +dz_stretch_level = 900.0 # in meters +dz_stretch_factor = 1.0 +dz_max = 5.0 + +# time origin and extent of the simulation (format YYYY-MM-DD hh:mm:ss) +origin_time = "2021-09-27 12:00:00" +simulation_hours = 11 + +# wrf_chem input dir and mask +wrf_dir_name = '/cfs/home/d/u/dupreeda/MBEES/PALM/wrf_chem_data' +wrf_file_mask = "wrfout_d01_2021-09-27_*" +wrf_hybrid_levs = True +vinterp_terrain_smoothing = None +# interpolated files +interp_dir_name = '/cfs/home/d/u/dupreeda/MBEES/PALM/wrf_chem_data/interp' + +# WRF-chem gaseous species +wrfchem_spec = ['no', 'no2','hno3', 'nh3', 'h2so4', 'ocnv','ocsv'] + +# Salsa parameters (only aerosol species) +aerosol_wrfchem = True +wrfchem_bin_limits = [3.9e-8, 1.56e-7, 6.25e-7, 2.5e-6, 1.0e-5] +listspec = ['OC', 'NO', 'NH'] +nbin = [1,7] +reglim = [3.9e-8, 5.0e-8, 2.5e-6] +nf2a = 1.0 + +# radiation +radiation_from_wrf = False +wrf_rad_file_mask = "auxhist6_*" +radiation_smoothing_distance = 10000.0 diff --git a/dynamic/__pycache__/palm_dynamic_aerosol.cpython-38.pyc b/dynamic/__pycache__/palm_dynamic_aerosol.cpython-38.pyc new file mode 100644 index 0000000000000000000000000000000000000000..7d470348cf7ff1934b653ee60144b4c01ff7eddb Binary files /dev/null and b/dynamic/__pycache__/palm_dynamic_aerosol.cpython-38.pyc differ diff --git a/dynamic/__pycache__/palm_dynamic_config.cpython-38.pyc b/dynamic/__pycache__/palm_dynamic_config.cpython-38.pyc new file mode 100644 index 0000000000000000000000000000000000000000..67f9d6c18aae677e4ffb52d164f36a5acc6af13a Binary files /dev/null and b/dynamic/__pycache__/palm_dynamic_config.cpython-38.pyc differ diff --git a/dynamic/__pycache__/palm_dynamic_output.cpython-38.pyc b/dynamic/__pycache__/palm_dynamic_output.cpython-38.pyc new file mode 100644 index 0000000000000000000000000000000000000000..c4be1995deb026f5d2628f050be78705db25fc34 Binary files /dev/null and b/dynamic/__pycache__/palm_dynamic_output.cpython-38.pyc differ diff --git a/dynamic/__pycache__/palm_wrf_utils.cpython-38.pyc b/dynamic/__pycache__/palm_wrf_utils.cpython-38.pyc new file mode 100644 index 0000000000000000000000000000000000000000..22a713ae7626a20a29c0099e105c08587b1baff9 Binary files /dev/null and b/dynamic/__pycache__/palm_wrf_utils.cpython-38.pyc differ diff --git a/dynamic/palm_dynamic.py b/dynamic/palm_dynamic.py index 326d2d752993742b5223e4fbc8dce1be84e9fcac..d4999b22e7dca9fc43078f059b34e4145ac16335 100644 --- a/dynamic/palm_dynamic.py +++ b/dynamic/palm_dynamic.py @@ -267,7 +267,7 @@ if nested_domain: print('\nAnalyse WRF files dates:') file_times = [] for wrf_file in wrf_file_list: - #print('WRF file',wrf_file) + #print('\nWRF file',wrf_file) # get real time from wrf file nc_wrf = netCDF4.Dataset(wrf_file, "r", format="NETCDF4") ta = nc_wrf.variables['Times'][:] @@ -275,6 +275,8 @@ for wrf_file in wrf_file_list: td = datetime.strptime(t, '%Y-%m-%d_%H:%M:%S') print(os.path.basename(wrf_file), ': ', td) file_times.append((td,wrf_file)) + nc_wrf.close() + file_times.sort() times = [] wrf_files = [] @@ -372,12 +374,27 @@ for wrf_file in wrf_files_proc: wrfchem_variables = wrfchem_dynamic + wrfchem_spec if aerosol_wrfchem: wrfchem_variables = wrfchem_variables + wrfchem_aerosols - wrfchem_variables.append('ALT') + wrfchem_variables.append('ALT') # inverse density for varname in wrfchem_variables: - v_wrf = f_wrf.variables[varname] - v_out = f_out.createVariable(varname, 'f4', v_wrf.dimensions) - v_out[:] = regridder.regrid(v_wrf[...,regridder.ys,regridder.xs]) + # gaseous aerosols + if varname == 'h2so4': + v_wrf = f_wrf.variables['sulf'] + v_out = f_out.createVariable(varname, 'f4', v_wrf.dimensions) + v_out[:] = regridder.regrid(v_wrf[...,regridder.ys,regridder.xs]) + elif varname == 'ocnv': + v_wrf = f_wrf.variables['gly'] + v_out = f_out.createVariable(varname, 'f4', v_wrf.dimensions) + v_out[:] = regridder.regrid(v_wrf[...,regridder.ys,regridder.xs]) + elif varname == 'ocsv': + v_wrf = f_wrf.variables['hcho'] + v_out = f_out.createVariable(varname, 'f4', v_wrf.dimensions) + v_out[:] = regridder.regrid(v_wrf[...,regridder.ys,regridder.xs]) + else: + # other dynamic & chem vars + v_wrf = f_wrf.variables[varname] + v_out = f_out.createVariable(varname, 'f4', v_wrf.dimensions) + v_out[:] = regridder.regrid(v_wrf[...,regridder.ys,regridder.xs]) # U and V have special treatment (unstaggering) v_out = f_out.createVariable('U', 'f4', ('Time', 'bottom_top', 'south_north', 'west_east')) diff --git a/dynamic/palm_dynamic_output.py b/dynamic/palm_dynamic_output.py index 54fa3495f0847da076b3288d3505ad763bfb81ea..a5cc0cbbd5d2b9935181c53b4ad2dadf065fda62 100644 --- a/dynamic/palm_dynamic_output.py +++ b/dynamic/palm_dynamic_output.py @@ -171,6 +171,8 @@ def palm_dynamic_output(wrf_files, interp_files, dynamic_driver_file, times_sec, _val_init_var = outfile.createVariable('init_atmosphere_'+ var, "f4", ("z", "yv", "x"),fill_value=fillvalue_float) elif var == 'w': _val_init_var = outfile.createVariable('init_atmosphere_'+ var, "f4", ("zw", "y", "x"),fill_value=fillvalue_float) + elif var in wrfchem_spec: + _val_init_var = outfile.createVariable('init_atmosphere_'+ var.upper(), "f4", ("z",),fill_value=fillvalue_float) else: _val_init_var = outfile.createVariable('init_atmosphere_'+ var, "f4",('z',),fill_value=fillvalue_float) # add attributes @@ -249,6 +251,9 @@ def palm_dynamic_output(wrf_files, interp_files, dynamic_driver_file, times_sec, if (var == 'soil_m' or var == 'soil_t'): init_var = infile.variables['init_'+var] _val_init_var = outfile.variables['init_'+var] + elif var in wrfchem_spec: + init_var = infile.variables['init_atmosphere_'+ var] + _val_init_var = outfile.variables['init_atmosphere_'+ var.upper()] else: init_var = infile.variables['init_atmosphere_'+ var] _val_init_var = outfile.variables['init_atmosphere_'+ var] diff --git a/dynamic/palm_wrf_utils.py b/dynamic/palm_wrf_utils.py index fb3f6569e0f7fb1231c2f62fd0ea1d7968ecfd92..1647d4610a48f5375b85690d0bb8e17ef5bfdce1 100644 --- a/dynamic/palm_wrf_utils.py +++ b/dynamic/palm_wrf_utils.py @@ -365,14 +365,16 @@ def palm_wrf_vertical_interp(infile, outfile, wrffile, z_levels, z_levels_stag, vdata = nc_outfile.createVariable('zw', "f4", ("zw")) vdata[:] = list (z_levels_stag) - # zsoil is taken from wrf - not need to define it + # zsoil is taken from wrf - do not need to define it # ======================== CHEMISTRY =================================================== # convert ppmv to ppm for PALM except PM10 & PM2_5_DRY: micrograms m-3 to kg/m3 def chem_from_wrfchem(wrfchem_spec): for spec in wrfchem_spec: chem_data_raw = nc_infile.variables[spec][0] chem_data_raw = np.r_[chem_data_raw[0:1], chem_data_raw] + if (spec == 'PM10' or spec == 'PM2_5_DRY'): + chem_data_raw = nc_infile.variables[spec][0] chem_data = interpolate_1d(z_levels, height, (chem_data_raw)*1e-9) else: chem_data = interpolate_1d(z_levels, height, chem_data_raw) @@ -386,9 +388,9 @@ def palm_wrf_vertical_interp(infile, outfile, wrffile, z_levels, z_levels_stag, var_aero = palm_dynamic_aerosol.translate_aerosol_species(listspec[0]).split(",") var_size = nc_infile.variables[var_aero[0]+'_a01'].shape[0] # by species & sub-species - for spec in listspec: + for aerosol_spec in listspec: val_specout = np.zeros((var_size)) - spec_wrf = palm_dynamic_aerosol.translate_aerosol_species(spec).split(",") + spec_wrf = palm_dynamic_aerosol.translate_aerosol_species(aerosol_spec).split(",") # by aerosol-size bin naero = 0 for aero_bin in open_bin: @@ -404,7 +406,7 @@ def palm_wrf_vertical_interp(infile, outfile, wrffile, z_levels, z_levels_stag, val_specout = val_specout + val_specint naero = naero + 1 # write interp(sum) to file - vdata = nc_outfile.createVariable('init_atmosphere_'+spec,"f4",("Time", "z","south_north","west_east")) + vdata = nc_outfile.createVariable('init_atmosphere_'+ aerosol_spec,"f4",("Time", "z","south_north","west_east")) vdata[0,:,:,:] = val_specout def aerosol_concen_wrfchem(listspec):