From 315ccbae3389cc0f5c783912ad7e9e7cbb0642e0 Mon Sep 17 00:00:00 2001 From: Jess <20195932+wrongkindofdoctor@users.noreply.github.com> Date: Mon, 8 Jul 2024 12:20:27 -0400 Subject: [PATCH] update environment variables in EOF_500hpa ncl files (#603) fix file formatting change axis def to uppercase in pod settings file --- diagnostics/EOF_500hPa/EOF_500hPa.py | 57 ++++++++++---------- diagnostics/EOF_500hPa/compute_anomalies.ncl | 6 +-- diagnostics/EOF_500hPa/eof_natlantic.ncl | 6 +-- diagnostics/EOF_500hPa/eof_npacific.ncl | 6 +-- diagnostics/EOF_500hPa/settings.jsonc | 2 +- 5 files changed, 40 insertions(+), 37 deletions(-) diff --git a/diagnostics/EOF_500hPa/EOF_500hPa.py b/diagnostics/EOF_500hPa/EOF_500hPa.py index 7044b411a..73d71f792 100644 --- a/diagnostics/EOF_500hPa/EOF_500hPa.py +++ b/diagnostics/EOF_500hPa/EOF_500hPa.py @@ -1,17 +1,20 @@ # This file is part of the EOF_500hPa module of the MDTF code package (see LICENSE.txt) -#============================================================ +# ============================================================ # EOF of 500hPa Height Diagnostics # Sample code to call NCL from python -#============================================================ +# ============================================================ import os import subprocess import time -#============================================================ + +# ============================================================ # generate_ncl_plots - call a nclPlotFile via subprocess call -#============================================================ +# ============================================================ + + def generate_ncl_plots(nclPlotFile): """generate_plots_call - call a nclPlotFile via subprocess call @@ -19,52 +22,52 @@ def generate_ncl_plots(nclPlotFile): nclPlotFile (string) - full path to ncl plotting file name """ # check if the nclPlotFile exists - - # don't exit if it does not exists just print a warning. + # don't exit if it does not exist just print a warning. try: pipe = subprocess.Popen(['ncl {0}'.format(nclPlotFile)], shell=True, stdout=subprocess.PIPE) output = pipe.communicate()[0].decode() - print('NCL routine {0} \n {1}'.format(nclPlotFile,output)) + print('NCL routine {0} \n {1}'.format(nclPlotFile, output)) while pipe.poll() is None: time.sleep(0.5) except OSError as e: - print('WARNING',e.errno,e.strerror) + print('WARNING', e.errno, e.strerror) return 0 -print("Entered "+__file__) + +print("Entered " + __file__) filename1 = os.environ["ZG_FILE"] filename2a = os.environ["ZG_HYBRID_SIGMA_FILE"] filename2b = os.environ["PS_FILE"] -print("Looking for "+filename1) -if not os.path.isfile( filename1 ): - print("ERROR missing file "+filename1) +print("Looking for " + filename1) +if not os.path.isfile(filename1): + print("ERROR missing file " + filename1) os.environ['USE_HYBRID_SIGMA'] = "1" -print("Looking for "+filename2a) -if not os.path.isfile( filename2a ): - print("ERROR missing file "+filename2a) +print("Looking for " + filename2a) +if not os.path.isfile(filename2a): + print("ERROR missing file " + filename2a) os.environ['USE_HYBRID_SIGMA'] = "0" -print("Looking for "+filename2b) -if not os.path.isfile( filename2b ): - print("ERROR missing file "+filename2b) - +print("Looking for " + filename2b) +if not os.path.isfile(filename2b): + print("ERROR missing file " + filename2b) if os.path.isfile(filename1) \ - or (os.path.isfile(filename2a) and os.path.isfile(filename2b)): - print("height and surface pressure files found") + or (os.path.isfile(filename2a) and os.path.isfile(filename2b)): + print("height and surface pressure files found") print("computing EOF of geopotential height anomalies of 500 hPa") -#============================================================ -# Call NCL code here -#============================================================ + # ============================================================ + # Call NCL code here + # ============================================================ print("COMPUTING ANOMALIES") - generate_ncl_plots(os.environ["POD_HOME"]+"/compute_anomalies.ncl") + generate_ncl_plots(os.environ["POD_HOME"] + "/compute_anomalies.ncl") print(" N ATLANTIC EOF PLOT") - generate_ncl_plots(os.environ["POD_HOME"]+"/eof_natlantic.ncl") + generate_ncl_plots(os.environ["POD_HOME"] + "/eof_natlantic.ncl") print(" N PACIFIC EOF PLOT") - generate_ncl_plots(os.environ["POD_HOME"]+"/eof_npacific.ncl") + generate_ncl_plots(os.environ["POD_HOME"] + "/eof_npacific.ncl") else: - print("height and surface pressure files NOT found, skip EOF of geopotential height anomalies of 500 hPa") + print("height and surface pressure files NOT found, skip EOF of geopotential height anomalies of 500 hPa") diff --git a/diagnostics/EOF_500hPa/compute_anomalies.ncl b/diagnostics/EOF_500hPa/compute_anomalies.ncl index 777b8de4e..e4cd8f04f 100644 --- a/diagnostics/EOF_500hPa/compute_anomalies.ncl +++ b/diagnostics/EOF_500hPa/compute_anomalies.ncl @@ -7,10 +7,10 @@ begin setfileoption("nc", "Format", getenv("MDTF_NC_FORMAT")) -wk_dir = getenv("WK_DIR") +wk_dir = getenv("WORK_DIR") casename = getenv("CASENAME") -yr1 = getenv("FIRSTYR") -yr2 = getenv("LASTYR") +yr1 = getenv("startdate") +yr2 = getenv("enddate") date_off = getenv("date_int_offset") use_hybrid_sigma = (getenv("USE_HYBRID_SIGMA").eq."1") diff --git a/diagnostics/EOF_500hPa/eof_natlantic.ncl b/diagnostics/EOF_500hPa/eof_natlantic.ncl index edaf15652..3238e9ac5 100644 --- a/diagnostics/EOF_500hPa/eof_natlantic.ncl +++ b/diagnostics/EOF_500hPa/eof_natlantic.ncl @@ -9,10 +9,10 @@ load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl" setfileoption("nc", "Format", getenv("MDTF_NC_FORMAT")) begin -yr1 = getenv("FIRSTYR") -yr2 = getenv("LASTYR") +yr1 = getenv("startdate") +yr2 = getenv("enddate") rgb = getenv("RGB") -wk_dir = getenv("WK_DIR") +wk_dir = getenv("WORK_DIR") casename = getenv("CASENAME") firstyr = stringtointeger(yr1) diff --git a/diagnostics/EOF_500hPa/eof_npacific.ncl b/diagnostics/EOF_500hPa/eof_npacific.ncl index e1357567c..0ee48a9cb 100644 --- a/diagnostics/EOF_500hPa/eof_npacific.ncl +++ b/diagnostics/EOF_500hPa/eof_npacific.ncl @@ -8,10 +8,10 @@ load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl" setfileoption("nc", "Format", getenv("MDTF_NC_FORMAT")) begin -yr1 = getenv("FIRSTYR") -yr2 = getenv("LASTYR") +yr1 = getenv("startdate") +yr2 = getenv("enddate") rgb = getenv("RGB") -wk_dir = getenv("WK_DIR") +wk_dir = getenv("WORK_DIR") casename = getenv("CASENAME") firstyr = stringtointeger(yr1) diff --git a/diagnostics/EOF_500hPa/settings.jsonc b/diagnostics/EOF_500hPa/settings.jsonc index 9eebd882a..f32225234 100644 --- a/diagnostics/EOF_500hPa/settings.jsonc +++ b/diagnostics/EOF_500hPa/settings.jsonc @@ -31,7 +31,7 @@ "lon": { "standard_name": "longitude", "units": "degrees_east", - "axis": "x" + "axis": "X" }, "plev": { "standard_name": "air_pressure",