Skip to content

Commit

Permalink
Add check for QBO if lon dimension is missing
Browse files Browse the repository at this point in the history
  • Loading branch information
justin-richling committed Jan 31, 2025
1 parent 48feec4 commit 2943328
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions scripts/plotting/qbo.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ def qbo(adfobj):
"""
#Notify user that script has started:
msg = "\n Generating qbo plots..."
msg = "\n Generating qbo plots..."
print(f"{msg}\n {'-' * (len(msg)-3)}")

#Extract relevant info from the ADF:
Expand Down Expand Up @@ -106,7 +106,7 @@ def qbo(adfobj):
bad_idxs = []
for idx, dat in enumerate(casedat):
if 'U' not in dat.variables:
warnings.warn(f"QBO: case {case_names[idx]} contains no 'U' field, skipping...")
warnings.warn(f"\t WARNING: Case {case_names[idx]} contains no 'U' field, skipping...")
bad_idxs.append(idx)
#End if
#End for
Expand All @@ -119,7 +119,13 @@ def qbo(adfobj):
#End if

#----Calculate the zonal mean
casedatzm = [ casedat[i].U.mean("lon") for i in range(0,ncases,1) ]
casedatzm = []
for i in range(0,ncases,1):
has_lon = pf.validate_dims("U", ['lon'])
if not has_lon:
print(f"\t WARNING: Variable U is missing a lat dimension for '{case_loc[i]}', cannot continue to plot.")
else:
casedatzm.append(casedat[i].U.mean("lon"))

#----Calculate the 5S-5N average
casedat_5S_5N = [ cosweightlat(casedatzm[i],-5,5) for i in range(0,ncases,1) ]
Expand Down

0 comments on commit 2943328

Please sign in to comment.