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

Trying to convert the analysis to netcdf.

parent f783572c
No related branches found
No related tags found
No related merge requests found
Pipeline #19158 canceled
......@@ -111,6 +111,60 @@ END
}
function integrate_sst_to_analysis() {
local DYNAMICS_GRID_FILE="$1"
local ANALYSIS_FILE="$2"
echo "Converting analysis to netcdf"
cat >remap.nml <<END
&remap_nml
in_filename = "${ANALYSIS_FILE}"
in_grid_filename = "${DYNAMICS_GRID_FILE}"
in_type = 1
out_grid_filename = "${DYNAMICS_GRID_FILE}"
out_filename = "analysis.nc"
out_type = 2
out_filetype = 4
/
END
cat <<END >extend_remap_namelist.py
import xarray as xr
with xr.open_dataset("${ANALYSIS_FILE}") as ds, open('remap.nml', 'a') as file:
for ida, da in enumerate(ds):
file.write('&input_field_nml\n')
file.write(f'inputname = "{da}"\n')
file.write(f'outputname = "{da}"\n')
file.write('/\n\n')
END
python3 extend_remap_namelist.py
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() {
local INTERPOLATED_SST="$1"
local ANALYSIS_FILE="$2"
......@@ -171,4 +225,3 @@ 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