Skip to content

Commit

Permalink
capture input data errors
Browse files Browse the repository at this point in the history
  • Loading branch information
chengzhuzhang committed Oct 22, 2024
1 parent c10a1a2 commit ffbdf28
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions e3sm_diags/driver/tc_analysis_driver.py
Original file line number Diff line number Diff line change
Expand Up @@ -160,10 +160,15 @@ def generate_tc_metrics_from_te_stitch_file(te_stitch_file: str) -> Dict[str, An
"""
logger.info("\nGenerating TC Metrics from TE Stitch Files")
logger.info("============================================")
if not os.path.exists(te_stitch_file):
raise FileNotFoundError(f"The file {te_stitch_file} does not exist.")

with open(te_stitch_file) as f:
lines_orig = f.readlines()

if not lines_orig:
raise ValueError(f"The file {te_stitch_file} is empty.")

line_ind = []
data_start_year = int(te_stitch_file.split(".")[-2].split("_")[-2])
data_end_year = int(te_stitch_file.split(".")[-2].split("_")[-1])
Expand Down

0 comments on commit ffbdf28

Please sign in to comment.