Skip to content

Commit

Permalink
Merge pull request #980 from MPAS-Dev/develop
Browse files Browse the repository at this point in the history
Merge `develop` to `main`
  • Loading branch information
xylar authored Jan 20, 2024
2 parents 26c0800 + 27d0c23 commit 83c4054
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 14 deletions.
4 changes: 2 additions & 2 deletions ci/recipe/meta.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{% set name = "MPAS-Analysis" %}
{% set version = "1.9.0" %}
{% set version = "1.9.1" %}

package:
name: {{ name|lower }}
Expand Down Expand Up @@ -35,7 +35,7 @@ requirements:
- lxml
- mache >=1.11.0
- matplotlib-base >=3.6.0,!=3.7.2
- mpas_tools >=0.16.0
- mpas_tools >=0.30.0
- nco >=4.8.1
- netcdf4
- numpy
Expand Down
2 changes: 1 addition & 1 deletion dev-spec.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ mache >=1.11.0
# 3.7.2 contains a bug with tight layouts and insets
# https://github.com/matplotlib/matplotlib/pull/26291
matplotlib-base>=3.6.0,!=3.7.2
mpas_tools>=0.16.0
mpas_tools>=0.30.0
nco>=4.8.1
netcdf4
numpy
Expand Down
2 changes: 1 addition & 1 deletion mpas_analysis/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@
import matplotlib as mpl
mpl.use('Agg')

__version_info__ = (1, 9, 0)
__version_info__ = (1, 9, 1)
__version__ = '.'.join(str(vi) for vi in __version_info__)
3 changes: 3 additions & 0 deletions mpas_analysis/shared/html/pages.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,9 @@ def generate_html(config, analyses, controlConfig, customConfigFiles):
html_dir = config.get('output', 'htmlSubdirectory')
if html_dir.startswith(base_path):
url = base_url + html_dir[len(base_path):]
if not url.endswith('/'):
# lack of trailing '/' is causing issues on NERSC's portal
url = f'{url}/'
print(f'Web page: {url}')
if url is None:
print("Done.")
Expand Down
30 changes: 20 additions & 10 deletions mpas_analysis/shared/plot/climatology_map.py
Original file line number Diff line number Diff line change
Expand Up @@ -702,42 +702,52 @@ def plot_panel(ax, title, array, colormap, norm, levels, ticks, contours,
def _add_stats(modelArray, refArray, diffArray, Lats, axes):
""" compute the means, std devs. and Pearson correlation """
weights = np.cos(np.deg2rad(Lats))
modelMean = np.average(modelArray, weights=weights)

model_weights = weights
model_mask = None
if isinstance(modelArray, np.ma.MaskedArray):
# make sure we're using the MPAS land mask for all 3 sets of stats
model_mask = modelArray.mask
model_weights = np.ma.array(weights, mask=model_mask)

modelMean = np.average(modelArray, weights=model_weights)

_add_stats_text(
names=['Min', 'Mean', 'Max'],
values=[np.amin(modelArray), modelMean, np.amax(modelArray)],
ax=axes[0], loc='upper')

if refArray is not None:
ref_weights = weights
ref_mask = None
if isinstance(modelArray, np.ma.MaskedArray):
# make sure we're using the MPAS land mask for all 3 sets of stats
mask = modelArray.mask
if isinstance(refArray, np.ma.MaskedArray):
# mask invalid where either model or ref array is invalid
mask = np.logical_or(mask, refArray.mask)
refArray = np.ma.array(refArray, mask=mask)
ref_mask = np.logical_or(model_mask, refArray.mask)
ref_weights = np.ma.array(weights, mask=ref_mask)
refArray = np.ma.array(refArray, mask=ref_mask)
modelAnom = modelArray - modelMean
modelVar = np.average(modelAnom ** 2, weights=weights)
refMean = np.average(refArray, weights=weights)
modelVar = np.average(modelAnom ** 2, weights=ref_weights)
refMean = np.average(refArray, weights=ref_weights)
refAnom = refArray - refMean
refVar = np.average(refAnom**2, weights=weights)
refVar = np.average(refAnom**2, weights=ref_weights)

_add_stats_text(
names=['Min', 'Mean', 'Max'],
values=[np.amin(refArray), refMean, np.amax(refArray)],
ax=axes[1], loc='upper')

diffMean = np.average(diffArray, weights=weights)
diffVar = np.average((diffArray - diffMean)**2, weights=weights)
diffMean = np.average(diffArray, weights=ref_weights)
diffVar = np.average((diffArray - diffMean)**2, weights=ref_weights)
diffRMSE = np.sqrt(diffVar)

_add_stats_text(
names=['Min', 'Mean', 'Max'],
values=[np.amin(diffArray), diffMean, np.amax(diffArray)],
ax=axes[2], loc='upper')

covar = np.average(modelAnom*refAnom, weights=weights)
covar = np.average(modelAnom*refAnom, weights=ref_weights)

corr = covar/np.sqrt(modelVar*refVar)

Expand Down

0 comments on commit 83c4054

Please sign in to comment.