Skip to content

Commit

Permalink
Add soft error handling for lack of cnvstat in vrfy (#509)
Browse files Browse the repository at this point in the history
* changed handling of var.yaml

* saving original var with different name

* adding error handling for cnvstat

* pep8 correction

* made diag_statistics.py executable
  • Loading branch information
AndrewEichmann-NOAA committed Jun 15, 2023
1 parent 77defba commit 9b69daf
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions ush/diag_statistics.py
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,13 @@ def get_diag_stats():
zipfilename = diagfilename + '.gz'
outfilename = 'cnvstat.' + var + '.gdas.' + pdy + cyc + '.csv'

with tarfile.open(os.path.join(comout, tarfilename), "r") as tf:
tf.extract(member=zipfilename)
try:
with tarfile.open(os.path.join(comout, tarfilename), "r") as tf:
tf.extract(member=zipfilename)
except FileNotFoundError:
print('WARNING: file', os.path.join(comout, tarfilename),
'not found, this is expected in GDASApp ctests')
return
with gzip.open(zipfilename, 'rb') as f_in:
with open(diagfilename, 'wb') as f_out:
shutil.copyfileobj(f_in, f_out)
Expand Down

0 comments on commit 9b69daf

Please sign in to comment.