From 4c65f014bd5e46de01198e56dbb3f6a9242b548e Mon Sep 17 00:00:00 2001 From: Russell Manser Date: Wed, 24 Sep 2025 16:22:17 +0000 Subject: [PATCH 1/3] Remove wgrib2 call and replace with set_event.sh --- oper/utils/grib2writer.py | 23 ++++++----------------- 1 file changed, 6 insertions(+), 17 deletions(-) diff --git a/oper/utils/grib2writer.py b/oper/utils/grib2writer.py index 24b6dd2..7719d23 100644 --- a/oper/utils/grib2writer.py +++ b/oper/utils/grib2writer.py @@ -145,23 +145,12 @@ def save_grib2(self, xarray_ds, outdir): grib2_out_sfc.close() grib2_out_pres.close() - # Use wgrib2 to generate index files - for outfile in [outfile_sfc, outfile_pres]: - output_idx_file = f"{outfile}.idx" - - # Construct the wgrib2 command - wgrib2_command = ['wgrib2', '-s', outfile] - - try: - # Open the output file for writing - with open(output_idx_file, "w") as f_out: - # Execute the wgrib2 command and redirect stdout to the output file - subprocess.run(wgrib2_command, stdout=f_out, check=True) - - print(f"Index file created successfully: {output_idx_file}") - - except subprocess.CalledProcessError as e: - print(f"Error running wgrib2 command: {e}") + # Release post job to create index files and copy files to COM + if os.getenv("envir") is not None: + DATA = os.getenv("DATA") + cmd = [f"{DATA}/set_event.sh", f"{lead:03d}"] + print(f"Running shell subprocess {cmd}") + subprocess.run(cmd, check=True) if __name__ == "__main__": From d30e2abb52e2b74f21abb11ac869514fc874f9c6 Mon Sep 17 00:00:00 2001 From: RussellManser-NCO Date: Thu, 25 Sep 2025 14:10:29 -0500 Subject: [PATCH 2/3] Update oper/utils/grib2writer.py Co-authored-by: Rahul Mahajan --- oper/utils/grib2writer.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/oper/utils/grib2writer.py b/oper/utils/grib2writer.py index 7719d23..9cf703b 100644 --- a/oper/utils/grib2writer.py +++ b/oper/utils/grib2writer.py @@ -146,7 +146,7 @@ def save_grib2(self, xarray_ds, outdir): grib2_out_pres.close() # Release post job to create index files and copy files to COM - if os.getenv("envir") is not None: + if os.environ.get("SENDECF", "NO"): DATA = os.getenv("DATA") cmd = [f"{DATA}/set_event.sh", f"{lead:03d}"] print(f"Running shell subprocess {cmd}") From eebf015b5a3cf7d8eff12774d4e2f2960aa41de4 Mon Sep 17 00:00:00 2001 From: Russell Manser Date: Thu, 25 Sep 2025 20:17:49 +0000 Subject: [PATCH 3/3] Use SETEVENTSH for path to set_event.sh --- oper/utils/grib2writer.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/oper/utils/grib2writer.py b/oper/utils/grib2writer.py index 9cf703b..85038fa 100644 --- a/oper/utils/grib2writer.py +++ b/oper/utils/grib2writer.py @@ -147,8 +147,8 @@ def save_grib2(self, xarray_ds, outdir): # Release post job to create index files and copy files to COM if os.environ.get("SENDECF", "NO"): - DATA = os.getenv("DATA") - cmd = [f"{DATA}/set_event.sh", f"{lead:03d}"] + SETEVENTSH = os.environ.get("SETEVENTSH") + cmd = [SETEVENTSH, f"{lead:03d}"] print(f"Running shell subprocess {cmd}") subprocess.run(cmd, check=True)