Skip to content

Commit

Permalink
Merge pull request #91 from COSIMA/include-era5-fluxes
Browse files Browse the repository at this point in the history
Include era5 fluxes
  • Loading branch information
ashjbarnes authored Jan 23, 2024
2 parents f801f19 + 70db369 commit 2904cb2
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 6 deletions.
10 changes: 5 additions & 5 deletions demos/premade_run_directories/era5_surface/data_table
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@
"ATM", "z_bot", "", "", "bilinear", 10.0
"ATM", "gust", "", "", "bilinear", 1.0e-4
"ICE", "lw_flux_dn", "", "", "bilinear", 1.0
"ICE", "sw_flux_vis_dir_dn", "", "", "bilinear", 0.0
"ICE", "sw_flux_vis_dif_dn", "", "", "bilinear", 0.0
"ICE", "sw_flux_nir_dir_dn", "", "", "bilinear", 0.0
"ICE", "sw_flux_nir_dif_dn", "", "", "bilinear", 0.0
"ICE", "lprec", "", "", "bilinear", 0.0
"ICE", "sw_flux_vis_dir_dn", "msdwswrf", "./INPUT/forcing/msdwswrf_ERA5.nc", "bilinear", 0.285
"ICE", "sw_flux_vis_dif_dn", "msdwswrf", "./INPUT/forcing/msdwswrf_ERA5.nc", "bilinear", 0.285
"ICE", "sw_flux_nir_dir_dn", "msdwlwrf", "./INPUT/forcing/msdwlwrf_ERA5.nc", "bilinear", 0.215
"ICE", "sw_flux_nir_dif_dn", "msdwlwrf", "./INPUT/forcing/msdwlwrf_ERA5.nc", "bilinear", 0.215
"ICE", "lprec", "trr", "./INPUT/forcing/trr_ERA5.nc", "bilinear", 1.0
"ICE", "fprec", "", "", "bilinear", 0.0
"ICE", "runoff", "", "", "none", 0.0
"ICE", "dhdt", "", "", "none", 80.0
Expand Down
22 changes: 21 additions & 1 deletion regional_mom6/regional_mom6.py
Original file line number Diff line number Diff line change
Expand Up @@ -1394,7 +1394,8 @@ def setup_era5(self, era5_path):
## Firstly just open all raw data
rawdata = {}
for fname, vname in zip(
["2t", "10u", "10v", "sp", "2d"], ["t2m", "u10", "v10", "sp", "d2m"]
["2t", "10u", "10v", "sp", "2d", "msdwswrf", "msdwlwrf", "lsrr", "crr"],
["t2m", "u10", "v10", "sp", "d2m", "msdwswrf", "msdwlwrf", "lsrr", "crr"],
):
## Load data from all relevant years
datasets = []
Expand Down Expand Up @@ -1454,6 +1455,25 @@ def setup_era5(self, era5_path):
unlimited_dims="time",
encoding={"q": {"dtype": "double"}},
)
elif fname == "crr":
## Calculate total rain rate from convective and total
trr = xr.Dataset(
data_vars={"trr": rawdata["crr"]["crr"] + rawdata["lsrr"]["lsrr"]}
)

trr.trr.attrs = {
"long_name": "Total Rain Rate",
"units": "kg m**-2 s**-1",
}
trr.to_netcdf(
f"{self.mom_input_dir}/forcing/trr_ERA5.nc",
unlimited_dims="time",
encoding={"trr": {"dtype": "double"}},
)

elif fname == "lsrr":
## This is handled by crr as both are added together to calculate total rain rate.
pass
else:
rawdata[fname].to_netcdf(
f"{self.mom_input_dir}/forcing/{fname}_ERA5.nc",
Expand Down

0 comments on commit 2904cb2

Please sign in to comment.