From f783572c838ee89ab5fbabe4b4dc8a5fca610411 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Oriol=20Tint=C3=B3?= <oriol.tinto@lmu.de>
Date: Tue, 27 Jun 2023 11:23:56 +0200
Subject: [PATCH] Trying to convert the analysis to netcdf.

---
 templates/event-generator/adapt_member.sh       | 3 +--
 templates/event-generator/adapt_member_utils.sh | 8 ++++----
 templates/event-generator/prepare_namelist.py   | 8 ++++----
 3 files changed, 9 insertions(+), 10 deletions(-)

diff --git a/templates/event-generator/adapt_member.sh b/templates/event-generator/adapt_member.sh
index 5e21c30..48bad02 100644
--- a/templates/event-generator/adapt_member.sh
+++ b/templates/event-generator/adapt_member.sh
@@ -53,8 +53,7 @@ interpolate_SST "${DESTINATION_GRID}" "${SST_FORCING}" "${INTERPOLATED_SST}"
 
 # Integrate sst to extpar
 integrate_sst_to_extpar "${INTERPOLATED_SST}" "${EXTERNAL_PARAMETERS_FILE}"
-#cp ${EXTERNAL_PARAMETERS_FILE} extpar.nc
 
 
 # Integrate sst to analysis
-# integrate_sst_to_analysis "${INTERPOLATED_SST}" "${ANALYSIS_FILE}"
+integrate_sst_to_analysis "${INTERPOLATED_SST}" "${ANALYSIS_FILE}"
diff --git a/templates/event-generator/adapt_member_utils.sh b/templates/event-generator/adapt_member_utils.sh
index b70f7ce..cbbe625 100644
--- a/templates/event-generator/adapt_member_utils.sh
+++ b/templates/event-generator/adapt_member_utils.sh
@@ -123,10 +123,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
 
diff --git a/templates/event-generator/prepare_namelist.py b/templates/event-generator/prepare_namelist.py
index ffeb642..0223de6 100644
--- a/templates/event-generator/prepare_namelist.py
+++ b/templates/event-generator/prepare_namelist.py
@@ -19,10 +19,10 @@ ATMOSPHERE_NAMELIST_PATH = Path("%simulation.namelist_paths.atmosphere%")
 MASTER_NAMELIST_PATH = Path("%simulation.namelist_paths.master%")
 
 # Get first-guess and analysis names:
-analysis_filename = (RUNDIR / "igaf*.m*.grb")
-analysis_filename = analysis_filename.parent.glob(analysis_filename.name).__next__()
-analysis_filename = analysis_filename.name
-# analysis_filename = "analysis.nc"
+# analysis_filename = (RUNDIR / "igaf*.m*.grb")
+# analysis_filename = analysis_filename.parent.glob(analysis_filename.name).__next__()
+# analysis_filename = analysis_filename.name
+analysis_filename = "analysis.nc"
 
 
 first_guess_filename = (RUNDIR / "igfff00030000.m*.grb").resolve()
-- 
GitLab