Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions docs/api.rst
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ Ocean tasks
ClimatologyMapSST
ClimatologyMapSSS
ClimatologyMapMLD
ClimatologyMapSSH
ClimatologyMapAntarcticMelt
IndexNino34
MeridionalHeatTransport
Expand Down
16 changes: 13 additions & 3 deletions mpas_analysis/config.default
Original file line number Diff line number Diff line change
Expand Up @@ -588,11 +588,21 @@ comparisonGrids = ['latlon']
## sea surface height (SSH) against reference model results and observations

# colormap for model/observations
colormapNameResult = Spectral_r
#colormapNameResult = Spectral_r
colormapNameResult = Maximenko
# color indices into colormapName for filled contours
colormapIndicesResult = [0, 20, 40, 80, 100, 120, 160, 180, 200, 240, 255]
colormapIndicesResult = numpy.array(numpy.linspace(0, 255, 38), int)
# colormap levels/values for contour boundaries
colorbarLevelsResult = [-240., -200., -160., -120., -80., -40., 0., 40., 80., 120.]
colorbarLevelsResult = numpy.arange(-240., 130., 10.)
# colormap levels/values for ticks (defaults to same as levels)
colorbarTicksResult = numpy.arange(-240., 160., 40.)

# contour line levels
contourLevelsResult = numpy.arange(-240., 130., 10.)
# contour line thickness
contourThicknessResult = 0.25
# contour color
contourColorResult = 0.25

# colormap for differences
colormapNameDifference = RdBu_r
Expand Down
4 changes: 2 additions & 2 deletions mpas_analysis/configuration/mpas_analysis_config_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@
if six.PY3:
xrange = range

npallow = dict(linspace=np.linspace, xrange=xrange, range=range,
arange=np.arange, pi=np.pi, Pi=np.pi, __builtins__=None)
npallow = dict(linspace=np.linspace, xrange=xrange, range=range, array=np.array,
arange=np.arange, pi=np.pi, Pi=np.pi, int=int, __builtins__=None)


class MpasAnalysisConfigParser(ConfigParser):
Expand Down
10 changes: 6 additions & 4 deletions mpas_analysis/ocean/climatology_map_ssh.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,8 @@ def __init__(self, config, mpasClimatologyTask,
componentName='ocean',
tags=['climatology', 'horizontalMap', fieldName])

mpasFieldName = 'timeMonthly_avg_ssh'
mpasFieldName = 'timeMonthly_avg_pressureAdjustedSSH'
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@maltrud, yes this is now with pressure-adjusted SSH.


iselValues = None

sectionName = self.taskName
Expand Down Expand Up @@ -86,7 +87,8 @@ def __init__(self, config, mpasClimatologyTask,

if refConfig is None:

refTitleLabel = 'Observations (AVISO sea-level anomaly)'
refTitleLabel = 'Observations (AVISO Dynamic ' \
'Topography, 1993-2010)'

observationsDirectory = build_config_full_path(
config, 'oceanObservations',
Expand Down Expand Up @@ -123,11 +125,11 @@ def __init__(self, config, mpasClimatologyTask,
comparisonGridName,
remapClimatologySubtask,
remapObservationsSubtask,
refConfig)
refConfig, removeMean=True)

subtask.set_plot_info(
outFileLabel=outFileLabel,
fieldNameInTitle='SSH',
fieldNameInTitle='Zero-mean SSH',
mpasFieldName=mpasFieldName,
refFieldName=refFieldName,
refTitleLabel=refTitleLabel,
Expand Down
25 changes: 7 additions & 18 deletions mpas_analysis/ocean/meridional_heat_transport.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@
import numpy as np
import os

from mpas_analysis.shared.plot.plotting import plot_vertical_section,\
setup_colormap, plot_1D
from mpas_analysis.shared.plot.plotting import plot_vertical_section, plot_1D

from mpas_analysis.shared.io.utility import build_config_full_path, \
make_directories
Expand All @@ -16,9 +15,6 @@
from mpas_analysis.shared import AnalysisTask
from mpas_analysis.shared.html import write_image_xml

from mpas_analysis.shared.climatology import \
get_unmasked_mpas_climatology_file_name


class MeridionalHeatTransport(AnalysisTask): # {{{
'''
Expand Down Expand Up @@ -174,7 +170,6 @@ def run_task(self): # {{{
'{}/meridionalHeatTransport_years{:04d}-{:04d}.nc'.format(
outputDirectory, self.startYear, self.endYear)


if os.path.exists(outFileName):
self.logger.info(' Reading results from previous analysis run...')
annualClimatology = xr.open_dataset(outFileName)
Expand Down Expand Up @@ -342,18 +337,12 @@ def run_task(self): # {{{
filePrefix = self.filePrefixes['mhtZ']
figureName = '{}/{}.png'.format(self.plotsDirectory, filePrefix)
colorbarLabel = '[PW/m]'
contourLevels = config.getExpression(self.sectionName,
'contourLevelsGlobal',
usenumpyfunc=True)
(colormapName, colorbarLevels) = setup_colormap(config,
self.sectionName,
suffix='Global')
plot_vertical_section(config, x, y, z,
colormapName, colorbarLevels,
contourLevels, colorbarLabel,
title, xLabel, yLabel, figureName,
xLim=xLimGlobal, yLim=depthLimGlobal,
invertYAxis=False, N=movingAveragePoints)
plot_vertical_section(config, x, y, z, self.sectionName,
suffix='', colorbarLabel=colorbarLabel,
title=title, xlabel=xLabel, ylabel=yLabel,
fileout=figureName, xLim=xLimGlobal,
yLim=depthLimGlobal, invertYAxis=False,
N=movingAveragePoints)

self._write_xml(filePrefix)

Expand Down
57 changes: 36 additions & 21 deletions mpas_analysis/ocean/plot_climatology_map_subtask.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
from mpas_analysis.shared import AnalysisTask

from mpas_analysis.shared.plot.plotting import plot_global_comparison, \
setup_colormap, plot_polar_projection_comparison
plot_polar_projection_comparison

from mpas_analysis.shared.html import write_image_xml

Expand Down Expand Up @@ -57,6 +57,13 @@ class PlotClimatologyMapSubtask(AnalysisTask): # {{{
The subtask for remapping the MPAS climatology for the reference
run that this subtask will plot

removeMean : bool, optional
If True, a common mask for the model and reference data sets is
computed (where both are valid) and the mean over that mask is
subtracted from both the model and reference results. This is
useful for data sets where the desire is to compare the spatial
pattern but the mean offset is not meaningful (e.g. SSH)

outFileLabel : str
The prefix on each plot and associated XML file

Expand Down Expand Up @@ -106,7 +113,7 @@ class PlotClimatologyMapSubtask(AnalysisTask): # {{{

def __init__(self, parentTask, season, comparisonGridName,
remapMpasClimatologySubtask, remapObsClimatologySubtask=None,
refConfig=None, depth=None):
refConfig=None, depth=None, removeMean=False):
# {{{
'''
Construct one analysis subtask for each plot (i.e. each season and
Expand Down Expand Up @@ -139,6 +146,13 @@ def __init__(self, parentTask, season, comparisonGridName,
Depth the data is being plotted, 'top' for the sea surface
'bot' for the sea floor

removeMean : bool, optional
If True, a common mask for the model and reference data sets is
computed (where both are valid) and the mean over that mask is
subtracted from both the model and reference results. This is
useful for data sets where the desire is to compare the spatial
pattern but the mean offset is not meaningful (e.g. SSH)

Authors
-------
Xylar Asay-Davis
Expand All @@ -151,6 +165,7 @@ def __init__(self, parentTask, season, comparisonGridName,
self.remapMpasClimatologySubtask = remapMpasClimatologySubtask
self.remapObsClimatologySubtask = remapObsClimatologySubtask
self.refConfig = refConfig
self.removeMean = removeMean
subtaskName = 'plot{}_{}'.format(season, comparisonGridName)

if depth is None:
Expand Down Expand Up @@ -369,6 +384,24 @@ def run_task(self): # {{{
remappedRefClimatology = remappedRefClimatology.sel(
depthSlice=str(depth), drop=True)

if self.removeMean:
if remappedRefClimatology is None:
remappedModelClimatology[self.mpasFieldName] = \
remappedModelClimatology[self.mpasFieldName] - \
remappedModelClimatology[self.mpasFieldName].mean()
else:
masked = remappedModelClimatology[self.mpasFieldName].where(
remappedRefClimatology[self.refFieldName].notnull())
remappedModelClimatology[self.mpasFieldName] = \
remappedModelClimatology[self.mpasFieldName] - \
masked.mean()

masked = remappedRefClimatology[self.refFieldName].where(
remappedModelClimatology[self.mpasFieldName].notnull())
remappedRefClimatology[self.refFieldName] = \
remappedRefClimatology[self.refFieldName] - \
masked.mean()

if self.comparisonGridName == 'latlon':
self._plot_latlon(remappedModelClimatology, remappedRefClimatology)
elif self.comparisonGridName == 'antarctic':
Expand All @@ -386,11 +419,6 @@ def _plot_latlon(self, remappedModelClimatology, remappedRefClimatology):

mainRunName = config.get('runs', 'mainRunName')

(colormapResult, colorbarLevelsResult) = setup_colormap(
config, configSectionName, suffix='Result')
(colormapDifference, colorbarLevelsDifference) = setup_colormap(
config, configSectionName, suffix='Difference')

modelOutput = nans_to_numpy_mask(
remappedModelClimatology[self.mpasFieldName].values)

Expand Down Expand Up @@ -419,10 +447,7 @@ def _plot_latlon(self, remappedModelClimatology, remappedRefClimatology):
modelOutput,
refOutput,
bias,
colormapResult,
colorbarLevelsResult,
colormapDifference,
colorbarLevelsDifference,
configSectionName,
fileout=outFileName,
title=title,
modelTitle='{}'.format(mainRunName),
Expand Down Expand Up @@ -483,15 +508,6 @@ def _plot_antarctic(self, remappedModelClimatology,
self.fieldNameInTitle, season, self.startYear,
self.endYear)

if config.has_option(configSectionName, 'colormapIndicesResult'):
colorMapType = 'indexed'
elif config.has_option(configSectionName, 'normTypeResult'):
colorMapType = 'norm'
else:
raise ValueError('config section {} contains neither the info'
'for an indexed color map nor for computing a '
'norm'.format(configSectionName))

plot_polar_projection_comparison(
config,
x,
Expand All @@ -502,7 +518,6 @@ def _plot_antarctic(self, remappedModelClimatology,
bias,
fileout=outFileName,
colorMapSectionName=configSectionName,
colorMapType=colorMapType,
title=title,
modelTitle='{}'.format(mainRunName),
refTitle=self.refTitleLabel,
Expand Down
20 changes: 6 additions & 14 deletions mpas_analysis/ocean/plot_hovmoller_subtask.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@

from mpas_analysis.shared import AnalysisTask

from mpas_analysis.shared.plot.plotting import plot_vertical_section, \
setup_colormap
from mpas_analysis.shared.plot.plotting import plot_vertical_section

from mpas_analysis.shared.io import open_mpas_dataset

Expand Down Expand Up @@ -260,18 +259,11 @@ def run_task(self): # {{{

figureName = '{}/{}.png'.format(self.plotsDirectory, self.filePrefix)

(colormapName, colorbarLevels) = setup_colormap(config,
self.sectionName)

contourLevels = config.getExpression(self.sectionName,
'contourLevels',
usenumpyfunc=True)

plot_vertical_section(config, Time, depth, field,
colormapName, colorbarLevels, contourLevels,
self.unitsLabel, title, xLabel, yLabel,
figureName, linewidths=1, xArrayIsTime=True,
calendar=self.calendar)
plot_vertical_section(config, Time, depth, field, self.sectionName,
suffix='', colorbarLabel=self.unitsLabel,
title=title, xlabel=xLabel, ylabel=yLabel,
fileout=figureName, linewidths=1,
xArrayIsTime=True, calendar=self.calendar)

write_image_xml(
config=config,
Expand Down
18 changes: 6 additions & 12 deletions mpas_analysis/ocean/streamfunction_moc.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
import os

from mpas_analysis.shared.constants.constants import m3ps_to_Sv
from mpas_analysis.shared.plot.plotting import plot_vertical_section, \
timeseries_analysis_plot, setup_colormap
from mpas_analysis.shared.plot.plotting import plot_vertical_section,\
timeseries_analysis_plot

from mpas_analysis.shared.io.utility import build_config_full_path, \
make_directories, get_files_year_month
Expand Down Expand Up @@ -197,20 +197,14 @@ def run_task(self): # {{{
mainRunName)
filePrefix = self.filePrefixes[region]
figureName = '{}/{}.png'.format(self.plotsDirectory, filePrefix)
contourLevels = \
config.getExpression(self.sectionName,
'contourLevels{}'.format(region),
usenumpyfunc=True)
(colormapName, colorbarLevels) = setup_colormap(config,
self.sectionName,
suffix=region)

x = self.lat[region]
y = self.depth
z = self.moc[region]
plot_vertical_section(config, x, y, z, colormapName,
colorbarLevels, contourLevels, colorbarLabel,
title, xLabel, yLabel, figureName,
plot_vertical_section(config, x, y, z, self.sectionName,
suffix=region, colorbarLabel=colorbarLabel,
title=title, xlabel=xLabel, ylabel=yLabel,
fileout=figureName,
N=movingAveragePointsClimatological)

caption = '{} Meridional Overturning Streamfunction'.format(region)
Expand Down
13 changes: 2 additions & 11 deletions mpas_analysis/sea_ice/plot_climatology_map_subtask.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@

from mpas_analysis.shared import AnalysisTask

from mpas_analysis.shared.plot.plotting import plot_polar_comparison, \
setup_colormap
from mpas_analysis.shared.plot.plotting import plot_polar_comparison

from mpas_analysis.shared.html import write_image_xml

Expand Down Expand Up @@ -298,11 +297,6 @@ def run_task(self): # {{{
else:
plotProjection = 'spstere'

(colormapResult, colorbarLevelsResult) = setup_colormap(
config, sectionName, suffix='Result')
(colormapDifference, colorbarLevelsDifference) = setup_colormap(
config, sectionName, suffix='Difference')

referenceLongitude = config.getfloat(sectionName,
'referenceLongitude')
minimumLatitude = config.getfloat(sectionName,
Expand Down Expand Up @@ -373,10 +367,7 @@ def run_task(self): # {{{
modelOutput,
refOutput,
difference,
colormapResult,
colorbarLevelsResult,
colormapDifference,
colorbarLevelsDifference,
sectionName,
title=title,
fileout=fileout,
plotProjection=plotProjection,
Expand Down
Loading