Skip to content

Commit

Permalink
Fix 4 problems in mon_data_space and map-scatter plots (#206)
Browse files Browse the repository at this point in the history
This PR fixes these problems:

1. `mon_data_space.py` now adds empty lat and lon values for each level
when the requested data file is not found. A value of `1` was used
heretofore, which somehow worked. It does not work with code built on
Rocky8 though, hence this change.
2. `emcpy_map_scatter.py` now removes 'level' from the plot object --
emcpy doesn't recognize level and fails if it's in the plot object's
configuration. How this ever worked is not clear to me, but it does with
this change.
3. `dynamic_config.py` now has a check on the data before it tries to
sort the data. Without this check when there was no data an exception
resulted.
4. `map_scatter.py` now includes `level` when selecting the specific
data for a plot. Without this change only plots with a single level
worked; all others had a dimension mismatch and resulting exception in
the color bar generation. This one was totally my fault -- I installed a
similar fix in `line_plot.py` months ago and asked myself if I needed to
change any other plots? Nah, don't think so. Ooops.



Close #205
  • Loading branch information
EdwardSafford-NOAA authored Aug 5, 2024
1 parent 2dc91b0 commit 008d04a
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 4 deletions.
4 changes: 3 additions & 1 deletion src/eva/data/mon_data_space.py
Original file line number Diff line number Diff line change
Expand Up @@ -800,7 +800,9 @@ def read_stn_ieee(self, file_name, coords, dims, ndims_used, dims_arr,
f.close()

else:
rtn_array = np.zeros((len(vars), 1, 1), float)
rtn_array = np.zeros((len(vars), dims[dims_arr[0]], 1), float)
lat.append(0)
lon.append(0)
dims['ydef'] = 1

rtn_lat = np.asarray(lat).reshape(-1)
Expand Down
8 changes: 7 additions & 1 deletion src/eva/plotting/batch/base/diagnostics/map_scatter.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,18 +51,24 @@ def __init__(self, config, logger, dataobj):
def data_prep(self):
""" Preparing data for configure_plot """

# Optionally get the channel|level|datatype to plot
channel = None
if 'channel' in self.config['data']:
channel = self.config['data'].get('channel')
level = None
if 'level' in self.config:
level = self.config.get('level')

lonvar_cgv = self.config['longitude']['variable'].split('::')
lonvar = self.dataobj.get_variable_data(lonvar_cgv[0], lonvar_cgv[1], lonvar_cgv[2], None)
lonvar = slice_var_from_str(self.config['longitude'], lonvar, self.logger)
latvar_cgv = self.config['latitude']['variable'].split('::')
latvar = self.dataobj.get_variable_data(latvar_cgv[0], latvar_cgv[1], latvar_cgv[2], None)
latvar = slice_var_from_str(self.config['latitude'], latvar, self.logger)

datavar_cgv = self.config['data']['variable'].split('::')
datavar = self.dataobj.get_variable_data(datavar_cgv[0], datavar_cgv[1],
datavar_cgv[2], channel)
datavar_cgv[2], channel, level)
datavar = slice_var_from_str(self.config['data'], datavar, self.logger)
self.lonvar = lonvar.flatten()
self.latvar = latvar.flatten()
Expand Down
3 changes: 2 additions & 1 deletion src/eva/plotting/batch/base/plot_tools/dynamic_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,8 @@ def vminvmaxcmap(logger, option_dict, plots_dict, data_collections):
varname_cgv[2], channel, level, datatype)

# Reorder the data array
datavar = np.sort(datavar)
if datavar.size > 1:
datavar = np.sort(datavar)

# Decide how many values to throw out on each end of the dataset
n = datavar.size
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ def configure_plot(self):
layer_schema = self.config.get('schema', os.path.join(return_eva_path(), 'plotting',
'batch', 'emcpy', 'defaults', 'map_scatter.yaml'))
new_config = get_schema(layer_schema, self.config, self.logger)
delvars = ['longitude', 'latitude', 'data', 'type', 'schema']
delvars = ['longitude', 'latitude', 'data', 'type', 'schema', 'level']
for d in delvars:
new_config.pop(d, None)
self.plotobj = update_object(self.plotobj, new_config, self.logger)
Expand Down

0 comments on commit 008d04a

Please sign in to comment.