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

Fix integrate_sst_to_analysis

parent 97012a1f
No related branches found
No related tags found
No related merge requests found
Pipeline #19082 passed
......@@ -10,7 +10,7 @@ WORKDIR=%HPCROOTDIR%
PROJ_FOLDER=${WORKDIR}/production_project
SST_FORCING=$( basename %simulation.initial_conditions.sea_surface_temperature_forcing% )
INTERPOLATED_SST=whatever.nc
INTERPOLATED_SST=sst_climatology.nc
DESTINATION_GRID=%simulation.dynamics_grid_filename%
EXTERNAL_PARAMETERS_FILE=%simulation.external_parameters_filename%
STARTDATE=%SDATE%
......
......@@ -99,18 +99,17 @@ function integrate_sst_to_analysis() {
cat <<END > integrate_sst_to_analysis.py
# Add sst field to analysis file.
import xarray as xr
from enstools.io import read
import os
import numpy as np
os.environ['ECCODES_GRIB_NO_INDEX'] = '1'
# Open files
with xr.open_dataset("${ANALYSIS_FILE}") as ds, xr.open_dataset("${INTERPOLATED_SST}") as sst_ds:
with read("${ANALYSIS_FILE}") as ds, read("${INTERPOLATED_SST}") as sst_ds:
date=ds.time.values
day_of_year = int((date - np.datetime64(date.astype('datetime64[Y]'))) / np.timedelta64(1, 'D'))
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.isel(time=day_of_year+1)
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