Realistic LES: the cabauw case
Generating input data using (LS) 2 D
Download the data
To generate input based on ERA5, the (LS) 2 D python package can be used. General instructions on (LS) 2 D can be found here: https://github.com/LS2D/LS2D and a more elaborate description is given in the reference paper (van Stratum et al., 2023). ERA5 is described in Hersbach et al., (2020) and CAMS in Inness et al (2019). This tutorial shortly describes the steps to take and where to find the relevant scripts and functions.
download_era5 function (and the download_cams function).Read_era5 class (and the Read_cams class). For the ERA5 data, this class also calculates some derived quantities such as thl.calculate_forcings function from the Read_era5 class that was called under step 2.get_les_input function from the Read_era5 class that was called under step 2 (and the get_les_input function from the Read_cams class).Example
The plot below shows vertical profiles taken and derived from ERA5 using example_era5.py. This example shows 13 UTC on 4 July 2016.
Example
The plot below shows vertical profiles of aerosols mass mixing ratios taken from CAMS using example_cams.py. This example shows 13 UTC on 4 July 2016.
Note
When using CDS and ADS the
$HOME/.cdsapircfile must contain the url and key for CDS asurlandkeyand for ADS asurl_adsandkey_ads.In
example_cams.pyandexample_era5.pyspecify your own directories.Optionally, specify your own date, time and location in the settings dictionary in
example_cams.pyandexample_era5.py.example_cams.pyandexample_era5.pystop after the download requests are submitted. Run them again once the data is downloaded to obtain the derived data.Optionally, adapt the domain height in
example_cams.pyandexample_era5.py. This must be larger than the desired domain height of the MicroHH simulation.
Creating input for MicroHH
The obtained files (ls2d_era5.nc and ls2d_cams.nc) can now be used to generate a yourcase_input.nc file.
An example script to do this is available in /cases/cabauw/cabauw_input.py
The cabauw_input.py is a very complete script that allows to set many options that are discussed in the rest of this tutorial.
It does not only produce cabauw_input.nc, it also produces cabauw.ini from cabauw.ini.base.
Hence all the switches are set automatically, based on the flags given in cabauw_input.py.
The code snippet below shows the part of cabauw_input.py where the flags are set.
"""
Case switches.
"""
TF = np.float64 # Switch between double (float64) and single (float32) precision.
use_htessel = True # False = prescribed surface H+LE fluxes from ERA5.
use_rrtmgp = True # False = prescribed surface radiation from ERA5.
use_rt = False # False = 2stream solver for shortwave down, True = raytracer.
use_homogeneous_z0 = True # False = checkerboard pattern roughness lengths.
use_homogeneous_ls = True # False = checkerboard pattern (some...) land-surface fields.
use_aerosols = False # False = no aerosols in RRTMGP.
use_tdep_aerosols = False # False = time fixed RRTMGP aerosol in domain and background.
use_tdep_gasses = False # False = time fixed ERA5 (o3) and CAMS (co2, ch4) gasses.
use_tdep_background = False # False = time fixed RRTMGP T/h2o/o3 background profiles.
sw_micro = '2mom_warm'
"""
NOTE: `use_tdep_aerosols` and `use_tdep_gasses` specify whether the aerosols and gasses
used by RRTMGP are updated inside the LES domain. If `use_tdep_background` is true, the
aerosols, gasses, and the temperature & humidity are also updated on the RRTMGP background levels.
"""
# Switch between the two default RRTMGP g-point sets.
gpt_set = '128_112' # or '256_224'
# Time period.
# NOTE: Included ERA5/CAMS data is limited to 2016-08-15 06:00 - 18:00 UTC.
start_date = datetime(year=2016, month=8, day=15, hour=6)
end_date = datetime(year=2016, month=8, day=15, hour=18)
# Simple equidistant grid.
zsize = 4000
ktot = 160
itot = 512
jtot = 512
xsize = 25600
ysize = 25600
TF)start_date, end_date)zsize, xsize, y_size)ktot, itot, jtot)use_htessel, use_homogeneous_z0, use_homogeneous_ls) as discussed below (Land surface)use_rrtmgp, use_rt, use_aerosols, use_tdep_aerosols, use_tdep_gasses, use_tdep_background) as discussed below (Radiation)Note
in cabauw_input.py, the filenames for the ERA5 and CAMS data must be specified.
currently, cabauw_input.py requires a file with the CAMS data, also if this data is not used.
Note
cabauw.ini.base and microhh_tools.py must be present in the working directory.Large scale forcings
Our Cabauw simulation includes Large-scale forcings [force] based on ERA5.
This includes the following aspects and their settings in cabauw.ini and cabauw_input.nc:
cabauw.ini: swlspres=geo, swtimedep_geo=true and fc=0.000115.cabauw_input.nc: profiles of the geostropic wind (u and v) in the timedep group.cabauw.ini: swls=1, swtimedep_ls=true, lslist=thl,qt,u,v and timedeplist_ls=thl,qt,u,v.cabauw_input.nc: profiles of thl_ls, qt_ls, u_ls and v_ls in the timedep group.cabauw.ini: swwls=local and swtimedep_wls=true.cabauw_input.nc: w_ls profile in the timedep group.cabauw.ini: swnudge=true, swtimedep_nudge=true and nudgelist=thl,qt,u,v.cabauw_input.nc: profiles of thl_nudge, qt_nudge, u_nudge and v_nudge in the timedep group + profile of the nudging factor in the init group.cabauw_input.nc file also contains the time at which the time dependent variables are given.Example
In cases where there is a mismatch between ERA5 and observations, a better match between MicroHH and observations can sometimes be obtained by manually tweaking the input profiles. An example is shown in the plot below for 4 July 2016, which shows timeseries of temperature and humidity at 10 m height and cloud cover. A better match with observations is realized by increasing the initial humidity with 10% at the surface, and a linearly decreasing percentage above until 1,000 m and by increasing the nudging timescale from 3 to 12 hr in the lowest 2 km.
Land surface
Our Cabauw simulation includes a surface model with an interactive land-surface scheme (Boundary conditions [boundary]).
This scheme is similar to HTESSEL (Balsamo et al., 2019)
The use of this scheme is specified in the cabauw.ini file by swboundary=surface_lsm and the settings in the [land_surface] group.
The cabauw_input.nc file contains a soil group with profiles (of size ktot) of the soil temperature, soil water content, soil type, root fraction and depth of the soil layers.
Note
The interactive land-surface scheme can only be used in combination with swthermo=moist and swradiation = prescribed, rrtmgp or rrtmgp_rt
Note
The file van_genuchten_parameters.nc should be in the directory in which the model is run if [boundary][swboundary] = surface_lsm.
This file can be found in /misc/van_genuchten_parameters.nc.
Example
As with the initial conditions and large scale forcing, a better match wth observations can sometimes be obtained by manually tweaking the soil moisture content. An example is shown below for 4 July 2016 with a 10% reduction in soil moisture.
Radiation
Our Cabauw case includes Radiation [radiation] calculated with RTE+RRTMGP (Pincus et al., 2019). The C++ implementation of the code can be found here: https://github.com/microhh/rte-rrtmgp-cpp
The use of the radiation scheme is specified in cabauw.ini by swradiation=rrtmgp.
Furthermore, cabauw.ini specifies the surface albedos for the direct and diffuse radiation (sfc_alb_dir, sfc_alb_dif), the surface emissivity (emis_sfc) and the radiation time interval (dt_rad).
In addition, the Cabauw case uses a variable solar zenith angle, hence swfixedsza=false and therefore the latitude and longitude need to be specified in the grid group.
cabauw_input.nc file contains a radiation group with profiles of height, temperature, pressure, H2O, and O3 at the ERA5 model levels.
These profiles are used for calculating radiation in a background column.
This is one column in which radiation is calculated to determine the incoming radiation at the top of the domain.
This is necessary as the domain top is generally far below the top of the atmosphere, hence we need to account for the attenuation of radiation.init group of cabauw_input.nc contains concentrations of H2O and O3 at the model levels, for the radiation computations within the domain.
The concentration of H2O is only used initially, afterwards the simulated concentration is used.Note
In general, concentration of a number of gasses must be provided for the radiation computations, either as a profile or as a constant. These gasses are at least H2O, O3, N2O, O2, CO2, CH4, and optionally also CO, N2, CCl4, CFC-11, CFC-12, CFC-22, HFC-143a, HFC-125, HFC-23, HFC-32, HFC-134a, CF4, NO2
Note
The _input.nc file will contain additional profiles when switching flags in cabauw_input.py to use time dependent gasses (use_tdep_gasses = True),
time dependent background profiles (use_tdep_background=true), constant aerosols (use_aerosol=true and use_tdep_aerosols=false),
and/or time dependent aerosols (use_aerosol=true and use_tdep_aerosols=false).
Apart from the _input.nc and .ini, additional files are required when using rrtmgp.
The table below gives an overview of available lookup tables that should be present in the directory in which the model is run.
File name |
Location of the file |
|---|---|
|
/rte-rrtmgp-cpp/rrtmgp-data/rrtmgp-gas-lw-g256.nc
or /rte-rrtmgp-cpp/rrtmgp-data/rrtmgp-gas-lw-g128.nc
|
|
/rte-rrtmgp-cpp/rrtmgp-data/rrtmgp-gas-sw-g224.nc
or /rte-rrtmgp-cpp/rrtmgp-data/rrtmgp-gas-sw-g112.nc
|
|
/rte-rrtmgp-cpp/rrtmgp-data/rrtmgp-clouds-lw.nc |
|
/rte-rrtmgp-cpp/rrtmgp-data/rrtmgp-clouds-sw.nc |
|
/rte-rrtmgp-cpp/data/aerosol_optics.nc |
For the lookup tables coefficients_lw.nc and coefficients_sw.nc there are two files available with different numbers of g-points.
Using less g-points is slightly less accurate, but requires less memory.
The aerosol_optics.nc file is only required when aerosols are included.
Example
The figure below shows the components of surface radiation on 15 October 2017 with and without aerosols.
Ray tracing
Instead of the commonly used 2D radiative transfer calculations, MicroHH can also be ran with a coupled ray tracer (Veerman et al., 2022) to simulate radiation in 3D. The code, as well as some basic instructions can be found on https://github.com/microhh/rte-rrtmgp-cpp.
To use ray tracing coupled to a MicroHH simulation set swradiation=rrtmgp_rt in the .ini file.
Additionally, the ray tracer uses a null-collision grid, which is a technique to divide the domain into smaller piece for efficient calculations.
For any simulation with the ray tracer, the size of this grid in the three dimensions has to be specified in the .ini file (kngrid_i, kngrid_j, kngrid_k).
In addition, the .ini file must contain the number of rays per pixel (rays_per_pixel), which must always be a power of 2.
The most common values for rays per pixel are 64, 128 or 256, with the smaller numbers being faster but slightly less accurate.
Example
The figure below shows global radiation at the surface in colors and the cloud contours in black. The figure highlights the difference between 1D and 3D radiation and the difference between 16 and 1024 rays per pixel. The cloud field is taken from a simulation with 1D radiation on 4 July 2016 16 UTC.
Note
Currently, ray tracing is only available for shortwave radiation, requires an equidistant grid structure, and runs only on GPU.
column statistics are not available when using the coupled ray tracer.
It is also possible to run the ray tracer offline.
In other words, to apply 3D radiative transfer calculations to a cloud field from a simulation with simpler radiation.
Building the stand alone ray tracer is similar to building MicroHH and generates (among others) the executable test_rte_rrtmgp_rt_gpu.
Running the standalone ray tracer requires 3D fields of absolute temperature, specific humidity, cloud water content, ice water content and the essential gasses as listed above.
In addition, a 3D grid is required, vertical profiles of density and pressure, and values for the surface albedo, surface emissivity, solar zenith angle, solar azimuth angle.
Optionally, other gasses and aerosols can be added.
To convert MicroHH output to input for the standalone ray tracer, a python script is available /python/microhh_to_raytracer_input.py.
All available command line options are listed in the code for the forward ray tracer
Note
test_rte_rrtmgp_bw_gpu/rte-rrtmgp-cpp/python/set_virtual_camera.py/rte-rrtmgp-cpp/python/image_from_xyz.py