Skip to content

Commit cae04aa

Browse files
CDAT Migration Phase 3: Fix LHFLX name and add catch for non-existent or empty TE stitch file (#876)
1 parent f863744 commit cae04aa

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

e3sm_diags/derivations/formulas.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,9 @@ def qflx_convert_to_lhflx_approxi(var: xr.DataArray):
175175
new_var = var * 2.5e6
176176

177177
new_var.name = "LHFLX"
178+
new_var.attrs["units"] = "W/m2"
179+
new_var.attrs["long_name"] = "Surface latent heat flux"
180+
178181
return new_var
179182

180183

e3sm_diags/driver/tc_analysis_driver.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,9 +172,15 @@ def generate_tc_metrics_from_te_stitch_file(te_stitch_file: str) -> Dict[str, An
172172
"""
173173
logger.info("\nGenerating TC Metrics from TE Stitch Files")
174174
logger.info("============================================")
175+
if not os.path.exists(te_stitch_file):
176+
raise FileNotFoundError(f"The file {te_stitch_file} does not exist.")
177+
175178
with open(te_stitch_file) as f:
176179
lines = f.readlines()
177180

181+
if not lines:
182+
raise ValueError(f"The file {te_stitch_file} is empty.")
183+
178184
# Calculate number of storms and max length
179185
num_storms, max_len = _calc_num_storms_and_max_len(lines)
180186
# Parse variables from TE stitch file

0 commit comments

Comments
 (0)