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

Interpolate from the proper grid.

parent 55d3d1e8
No related branches found
No related tags found
No related merge requests found
Pipeline #19180 failed
......@@ -55,18 +55,8 @@ interpolate_SST "${DESTINATION_GRID}" "${SST_FORCING}" "${INTERPOLATED_SST}"
integrate_sst_to_extpar "${INTERPOLATED_SST}" "${EXTERNAL_PARAMETERS_FILE}"
old_integrate_sst_to_analysis "${INTERPOLATED_SST}" "${ANALYSIS_FILE}"
# Integrate sst to analysis
#integrate_sst_to_analysis "${DESTINATION_GRID}" "${ANALYSIS_FILE}"
# Interpolate analysis
interpolate_analysis "icon_grid_0024_R02B06_G.nc" "${ANALYSIS_FILE}" "${DESTINATION_GRID}"
ncks -4 --fl_fmt=64bit analysis.nc analysis.nc2
mv analysis.nc2 analysis.nc
#python ${PROJ_FOLDER}/templates/event-generator/icon-remap-helper.py --src-grid ${DESTINATION_GRID} \
# --dst-grid ${DESTINATION_GRID} \
# --source ${ANALYSIS_FILE} \
# --dest . \
# --output-format nc \
# --rename "analysis.nc"
\ No newline at end of file
integrate_sst_to_analysis "${ANALYSIS_FILE}"
......@@ -110,20 +110,21 @@ END
fi
}
function integrate_sst_to_analysis() {
function interpolate_analysis() {
local DYNAMICS_GRID_FILE="$1"
local INPUT_GRID="$1"
local ANALYSIS_FILE="$2"
local OUTPUT_GRID="$3"
echo "Converting analysis to netcdf"
cat >remap.nml <<END
&remap_nml
in_filename = "${ANALYSIS_FILE}"
in_grid_filename = "${DYNAMICS_GRID_FILE}"
in_grid_filename = "${INPUT_GRID}"
in_type = 2
out_grid_filename = "${DYNAMICS_GRID_FILE}"
out_filename = "analysis.nc"
out_grid_filename = "${OUTPUT_GRID}"
out_filename = "interpolated_analysis.nc"
out_type = 2
out_filetype = 4
/
......@@ -151,28 +152,11 @@ END
ulimit -s unlimited
OMP_NUM_THREADS=1 iconremap --remap_nml remap.nml #-vvv
rm remap.nml
# # Somehow, when we interpolate we lose some attributes.
# # Here we solve this issue adding the attributes.
# cat <<END >add_attributes.py
## Add sst field to analysis file.
#from enstools.io import read
#
## Open files
#with read("tmp_extpar.nc") as ds, read("${EXTERNAL_PARAMETERS_FILE}") as original_extpar_ds:
# if "rawdata" in original_extpar_ds.attrs:
# ds.attrs["rawdata"] = original_extpar_ds.attrs["rawdata"]
# ds.to_netcdf("extpar.nc")
#END
# python3 add_attributes.py
#
# rm "tmp_extpar.nc"
}
function old_integrate_sst_to_analysis() {
function integrate_sst_to_analysis() {
local INTERPOLATED_SST="$1"
local ANALYSIS_FILE="$2"
local ANALYSIS_FILE="interpolated_analysis.nc"
cat <<END >integrate_sst_to_analysis.py
# Add sst field to analysis file.
......@@ -183,10 +167,10 @@ import numpy as np
os.environ['ECCODES_GRIB_NO_INDEX'] = '1'
# Open files
with read("${ANALYSIS_FILE}") as ds, read("${INTERPOLATED_SST}") as sst_ds:
# date=ds.time.values
# day_of_year = int((date - date.astype('datetime64[Y]')) / np.timedelta64(1, 'D'))
# Replace analysis T_SEA with info from the sst_clim file.
# ds["T_SEA"]= sst_ds["T_SEA"].isel(time=day_of_year+1)
date=ds.time.values
day_of_year = int((date - date.astype('datetime64[Y]')) / np.timedelta64(1, 'D'))
Replace analysis T_SEA with info from the sst_clim file.
ds["T_SEA"]= sst_ds["T_SEA"].isel(time=day_of_year+1)
ds.to_netcdf("analysis.nc")
END
......
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