Skip to content

Commit

Permalink
Switch ClimatologyMapSeaIceThick to shared plot subtask
Browse files Browse the repository at this point in the history
  • Loading branch information
xylar committed Sep 30, 2022
1 parent 8f06dc8 commit 146d5dd
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 42 deletions.
16 changes: 4 additions & 12 deletions mpas_analysis/default.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -3697,12 +3697,8 @@ colorbarLevelsDifference = [-3., -2.5, -2, -0.5, -0.1, 0, 0.1, 0.5, 2, 2.5, 3.]
# observations are only available for these seasons)
seasons = ['FM', 'ON']

# comparison grid(s) ('latlon', 'antarctic') on which to plot analysis
comparisonGrids = ['latlon']

# reference lat/lon for sea ice plots in the northern hemisphere
minimumLatitude = 50
referenceLongitude = 0
# comparison grid(s) (typically 'arctic') on which to plot analysis
comparisonGrids = ['arctic']

# a list of prefixes describing the sources of the observations to be used
observationPrefixes = ['']
Expand Down Expand Up @@ -3742,12 +3738,8 @@ colorbarLevelsDifference = [-3., -2.5, -2, -0.5, -0.1, 0, 0.1, 0.5, 2, 2.5, 3.]
# observations are only available for these seasons)
seasons = ['FM', 'ON']

# comparison grid(s) ('latlon', 'antarctic') on which to plot analysis
comparisonGrids = ['latlon']

# reference lat/lon for sea ice plots in the northern hemisphere
minimumLatitude = -50
referenceLongitude = 180
# comparison grid(s) (typically 'antarctic') on which to plot analysis
comparisonGrids = ['antarctic']

# a list of prefixes describing the sources of the observations to be used
observationPrefixes = ['']
Expand Down
57 changes: 27 additions & 30 deletions mpas_analysis/sea_ice/climatology_map_sea_ice_thick.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,7 @@
from mpas_analysis.shared.climatology import RemapMpasClimatologySubtask, \
RemapObservedClimatologySubtask

from mpas_analysis.sea_ice.plot_climatology_map_subtask import \
PlotClimatologyMapSubtask
from mpas_analysis.shared.plot import PlotClimatologyMapSubtask

from mpas_analysis.shared.io.utility import build_obs_path

Expand Down Expand Up @@ -48,14 +47,14 @@ def __init__(self, config, mpasClimatologyTask, hemisphere,
hemisphere : {'NH', 'SH'}
The hemisphere to plot
controlconfig : mpas_tools.config.MpasConfigParser, optional
controlConfig : mpas_tools.config.MpasConfigParser, optional
Configuration options for a control run (if any)
"""
# Authors
# -------
# Xylar Asay-Davis

taskName = 'climatologyMapSeaIceThick{}'.format(hemisphere)
taskName = f'climatologyMapSeaIceThick{hemisphere}'

fieldName = 'seaIceThick'

Expand Down Expand Up @@ -85,22 +84,22 @@ def __init__(self, config, mpasClimatologyTask, hemisphere,
seasons = config.getexpression(sectionName, 'seasons')

if len(seasons) == 0:
raise ValueError('config section {} does not contain valid list '
'of seasons'.format(sectionName))
raise ValueError(f'config section {sectionName} does not contain '
f'a valid list of seasons')

comparisonGridNames = config.getexpression(sectionName,
'comparisonGrids')

if len(comparisonGridNames) == 0:
raise ValueError('config section {} does not contain valid list '
'of comparison grids'.format(sectionName))
raise ValueError(f'config section {sectionName} does not contain '
f'a valid list of comparison grids')

# the variable self.mpasFieldName will be added to mpasClimatologyTask
# along with the seasons.
remapClimatologySubtask = RemapMpasClimatologySubtask(
mpasClimatologyTask=mpasClimatologyTask,
parentTask=self,
climatologyName='{}{}'.format(fieldName, hemisphere),
climatologyName=f'{fieldName}{hemisphere}',
variableList=[mpasFieldName],
comparisonGridNames=comparisonGridNames,
seasons=seasons,
Expand All @@ -114,58 +113,56 @@ def __init__(self, config, mpasClimatologyTask, hemisphere,
else:
controlRunName = controlConfig.get('runs', 'mainRunName')
galleryName = None
refTitleLabel = 'Control: {}'.format(controlRunName)
refTitleLabel = f'Control: {controlRunName}'
refFieldName = mpasFieldName
diffTitleLabel = 'Main - Control'

remapObservationsSubtask = None

for season in seasons:
if controlConfig is None:
obsFileName = build_obs_path(
config, 'seaIce',
relativePathOption='thickness{}_{}'.format(hemisphere,
season),
relativePathOption=f'thickness{hemisphere}_{season}',
relativePathSection=sectionName)

remapObservationsSubtask = RemapObservedThickClimatology(
parentTask=self, seasons=[season],
fileName=obsFileName,
outFilePrefix='{}{}_{}'.format(refFieldName,
hemisphere,
season),
outFilePrefix=f'{refFieldName}{hemisphere}_{season}',
comparisonGridNames=comparisonGridNames,
subtaskName='remapObservations{}'.format(season))
subtaskName=f'remapObservations{season}')
self.add_subtask(remapObservationsSubtask)
else:
remapObservationsSubtask = None

for comparisonGridName in comparisonGridNames:

imageDescription = \
'{} Climatology Map of {}-Hemisphere Sea-Ice ' \
'Thickness.'.format(season, hemisphereLong)
imageCaption = imageDescription
imageCaption = \
f'Climatology Map of {hemisphereLong}-Hemisphere ' \
f'Sea-Ice Thickness.'
galleryGroup = \
'{}-Hemisphere Sea-Ice Thickness'.format(
hemisphereLong)
f'{hemisphereLong}-Hemisphere Sea-Ice Thickness'
# make a new subtask for this season and comparison grid
subtaskName = f'plot{season}_{comparisonGridName}'

subtask = PlotClimatologyMapSubtask(
self, hemisphere, season, comparisonGridName,
remapClimatologySubtask, remapObservationsSubtask,
controlConfig)
parentTask=self, season=season,
comparisonGridName=comparisonGridName,
remapMpasClimatologySubtask=remapClimatologySubtask,
remapObsClimatologySubtask=remapObservationsSubtask,
subtaskName=subtaskName)

subtask.set_plot_info(
outFileLabel='icethick{}'.format(hemisphere),
outFileLabel=f'icethick{hemisphere}',
fieldNameInTitle='Sea ice thickness',
mpasFieldName=mpasFieldName,
refFieldName=refFieldName,
refTitleLabel=refTitleLabel,
diffTitleLabel=diffTitleLabel,
unitsLabel=r'm',
imageDescription=imageDescription,
imageCaption=imageCaption,
galleryGroup=galleryGroup,
groupSubtitle=None,
groupLink='{}_thick'.format(hemisphere.lower()),
groupLink=f'{hemisphere.lower()}_thick',
galleryName=galleryName,
maskValue=0)

Expand Down

0 comments on commit 146d5dd

Please sign in to comment.