Skip to content
Snippets Groups Projects
Commit 1048d846 authored by Oriol Tintó's avatar Oriol Tintó
Browse files

Instead of interpolating extpar, we try to add the T_SEA variable on the original grid's extpar.

parent a347e73b
No related branches found
No related tags found
No related merge requests found
Pipeline #19145 passed
......@@ -7,7 +7,8 @@ simulation:
radiation_grid_filename: icon_grid_0015_R02B05_R.nc
# external_parameters_filename: icon_extpar_0010_R02B04_G.nc
external_parameters_filename: icon_extpar_0024_R02B06_G_20200917_tiles.nc
# external_parameters_filename: icon_extpar_0024_R02B06_G_20200917_tiles.nc
external_parameters_filename: icon_extpar_0016_R02B06_G_20131206.nc
date_format: '%Y-%m-%dT%H:%M:%SZ'
namelist_paths:
# Path to the namelists
......
......@@ -48,7 +48,12 @@ interpolate_SST "${DESTINATION_GRID}" "${SST_FORCING}" "${INTERPOLATED_SST}"
# Interpolate extpar
interpolate_extpar "${DESTINATION_GRID}" "${EXTERNAL_PARAMETERS_FILE}"
#interpolate_extpar "${DESTINATION_GRID}" "${EXTERNAL_PARAMETERS_FILE}"
# Integrate sst to extpar
integrate_sst_to_extpar "${INTERPOLATED_SST}" "${EXTERNAL_PARAMETERS_FILE}"
# Integrate sst to analysis
......
......@@ -133,3 +133,40 @@ END
python integrate_sst_to_analysis.py
}
function integrate_sst_to_extpar() {
local INTERPOLATED_SST="$1"
local EXTERNAL_PARAMETERS_FILE="$2"
cat <<END >integrate_sst_to_extpar.py
# Add sst field to analysis file.
from enstools.io import read
import os
import numpy as np
os.environ['ECCODES_GRIB_NO_INDEX'] = '1'
# Open files
with read("${EXTERNAL_PARAMETERS_FILE}") as ds, read("${INTERPOLATED_SST}") as sst_ds:
da = sst_ds["T_SEA"]
year = 2000 # or any other year
dates = [(datetime(year, 1, 1) + timedelta(days=idx)).month for idx, _ in enumerate(da['time'].values)]
da['time'] = dates
# Replace analysis T_SEA with monthly mean from the sst_ds.
monthly_means = [da.sel(time=month).mean(dim="time") for month in range(1,13)]
concat_da = xr.concat(monthly_means, dim='time')
concat_da['time'] = np.arange(1, 13) # replace 'time' with month numbers
concat_da = concat_da.drop(['clon', 'clat'])
# Replace analysis T_SEA with monthly mean from the sst_ds.
ds["T_SEA"] = concat_da
ds.to_netcdf("extpar.nc")
END
python integrate_sst_to_extpar.py
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment