Skip to content

Commit

Permalink
Fix lat/lon plots for 3d variables
Browse files Browse the repository at this point in the history
Fix the incorrect check if variables are 3d
  • Loading branch information
justin-richling committed Jul 29, 2024
1 parent accc9e5 commit e436ae4
Showing 1 changed file with 21 additions and 8 deletions.
29 changes: 21 additions & 8 deletions scripts/plotting/global_latlon_map.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,12 +125,13 @@ def global_latlon_map(adfobj):
"MAM": [3, 4, 5],
"SON": [9, 10, 11]
}

# probably want to do this one variable at a time:
for var in var_list:
if var not in adfobj.data.ref_var_nam:
dmsg = f"No reference data found for variable `{var}`, zonal mean plotting skipped."
dmsg = f"No reference data found for variable `{var}`, global lat/lon mean plotting skipped."
adfobj.debug_log(dmsg)
print(dmsg)
continue

#Notify user of variable being plotted:
Expand All @@ -156,10 +157,19 @@ def global_latlon_map(adfobj):
vres['central_longitude'] = pf.get_central_longitude(adfobj)

# load reference data (observational or baseline)
# odata = adfobj.data.load_reference_da(var)
odata = adfobj.data.load_reference_regrid_da(adfobj.data.ref_case_label, var)
if not adfobj.compare_obs:
base_name = adfobj.data.ref_case_label
else:
base_name = adfobj.data.ref_labels[var]

# Gather reference variable data
odata = adfobj.data.load_reference_regrid_da(base_name, var)

if odata is None:
dmsg = f"No regridded test file for {base_name} for variable `{var}`, global lat/lon mean plotting skipped."
adfobj.debug_log(dmsg)
continue

o_has_dims = pf.validate_dims(odata, ["lat", "lon", "lev"]) # T iff dims are (lat,lon) -- can't plot unless we have both
if (not o_has_dims['has_lat']) or (not o_has_dims['has_lon']):
print(f"\t = skipping global map for {var} as REFERENCE does not have both lat and lon")
Expand All @@ -184,6 +194,8 @@ def global_latlon_map(adfobj):

#Skip this variable/case if the regridded climo file doesn't exist:
if mdata is None:
dmsg = f"No regridded test file for {case_name} for variable `{var}`, global lat/lon mean plotting skipped."
adfobj.debug_log(dmsg)
continue

#Determine dimensions of variable:
Expand All @@ -192,16 +204,17 @@ def global_latlon_map(adfobj):
print(f"\t = skipping global map for {var} for case {case_name} as it does not have both lat and lon")
continue
else: # i.e., has lat&lon
if pres_levs and (not has_dims['has_lev']):
print(f"\t - skipping global map for {var} as it has more than lat/lon dims, but no pressure levels were provided")
if (has_dims['has_lev']) and (not pres_levs):
print(f"\t - skipping global map for {var} as it has more than lev dimension, but no pressure levels were provided")
continue

# Check output file. If file does not exist, proceed.
# If file exists:
# if redo_plot is true: delete it now and make plot
# if redo_plot is false: add to website and move on
doplot = {}
if not pres_levs:

if not has_dims['has_lev']:
for s in seasons:
plot_name = plot_loc / f"{var}_{s}_LatLon_Mean.{plot_type}"
doplot[plot_name] = plot_file_op(adfobj, plot_name, var, case_name, s, web_category, redo_plot, "LatLon")
Expand Down Expand Up @@ -353,4 +366,4 @@ def plot_file_op(adfobj, plot_name, var, case_name, season, web_category, redo_p
return True

##############
#END OF SCRIPT
#END OF SCRIPT

0 comments on commit e436ae4

Please sign in to comment.