Skip to content

Commit

Permalink
Newer versions of Matplotlib seem to fail to plot map scatter when al…
Browse files Browse the repository at this point in the history
…l nan (#82)

Co-authored-by: danholdaway <danholdaway@users.noreply.github.com>
  • Loading branch information
danholdaway and danholdaway authored Mar 23, 2023
1 parent a8ce9cf commit dd21e58
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 6 deletions.
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

setuptools.setup(
name='eva',
version='1.3.3',
version='1.3.4',
author='Community owned code',
description='Evaluation and Verification of an Analysis',
url='https://github.com/JCSDA-internal/eva',
Expand Down
6 changes: 6 additions & 0 deletions src/eva/diagnostics/map_scatter.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
from eva.utilities.utils import get_schema, update_object, slice_var_from_str
import emcpy.plots.map_plots
import os
import numpy as np


class MapScatter():
Expand All @@ -25,6 +26,11 @@ def __init__(self, config, logger, dataobj):
lonvar = lonvar.flatten()
latvar = latvar.flatten()
datavar = datavar.flatten()

# If everything is nan plotting will fail so just plot some large values
if np.isnan(datavar).all():
datavar[np.isnan(datavar)] = 1.0e38

# create declarative plotting MapScatter object
self.plotobj = emcpy.plots.map_plots.MapScatter(latvar, lonvar, datavar)
# get defaults from schema
Expand Down
10 changes: 8 additions & 2 deletions src/eva/plot_tools/dynamic_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,14 @@ def vminvmaxcmap(logger, option_dict, plots_dict, data_collections):

# Find minimum and maximum values
cmap = option_dict.get('sequential colormap', 'viridis')
vmax = np.nanmax(datavar_check)
vmin = np.nanmin(datavar_check)

# If everything is nan plot some large min/max (plotting code should do the same)
if np.isnan(datavar_check).all():
vmax = 1.0e38
vmin = 1.0e38
else:
vmax = np.nanmax(datavar_check)
vmin = np.nanmin(datavar_check)

# If positive and negative values are present then a diverging colormap centered on zero should
# be used.
Expand Down
6 changes: 3 additions & 3 deletions src/eva/transforms/transform_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,11 @@ def replace_cgv(logger, collection, group, variable, *argv):

# Create dictionary with templates
tmplt_dict = {}
if collection is not 'none':
if collection != 'none':
tmplt_dict['collection'] = collection
if group is not 'none':
if group != 'none':
tmplt_dict['group'] = group
if variable is not 'none':
if variable != 'none':
tmplt_dict['variable'] = variable

# Perform replace for the argument list
Expand Down

0 comments on commit dd21e58

Please sign in to comment.