Skip to content

Commit 1bac984

Browse files
authored
Merge pull request #1138 from xylar/fix-control-global-subtitle-spacing
Several fixes to global plots
2 parents a80d719 + 4d01e34 commit 1bac984

File tree

7 files changed

+47
-24
lines changed

7 files changed

+47
-24
lines changed

mpas_analysis/ocean/climatology_map_fluxes.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ def __init__(self, config, mpasClimatologyTask, controlConfig=None,
142142
unitsLabel = r'W m$^{-2}$'
143143
else:
144144
groupSubtitle = 'Mass fluxes'
145-
unitsLabel = r'kg m$^{-2}$ s^${-1}$'
145+
unitsLabel = r'kg m$^{-2}$ s$^{-1}$'
146146

147147
subtask.set_plot_info(
148148
outFileLabel=outFileName,

mpas_analysis/shared/plot/climatology_map.py

Lines changed: 35 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -414,6 +414,9 @@ def _plot_panel(ax, title, array, colormap, norm, levels, ticks, contours,
414414
plottitle_font = {'size': config.get('plot',
415415
'threePanelPlotTitleFontSize')}
416416

417+
multi_line_ref_title = (
418+
refArray is not None and refTitle is not None and '\n' in refTitle)
419+
417420
if refArray is None:
418421
subplots = [111]
419422
else:
@@ -427,21 +430,43 @@ def _plot_panel(ax, title, array, colormap, norm, levels, ticks, contours,
427430
dictDiff = setup_colormap(config, colorMapSectionName, suffix='Difference')
428431

429432
axes = []
430-
ax = plt.subplot(subplots[0], projection=projection)
431-
_plot_panel(ax, modelTitle, modelArray, **dictModelRef)
432-
axes.append(ax)
433+
if refArray is not None and multi_line_ref_title:
434+
# Use a GridSpec with unequal gaps but equal-sized panels
435+
gs = fig.add_gridspec(
436+
nrows=5,
437+
ncols=1,
438+
height_ratios=[1.0, 0.18, 1.0, 0.08, 1.0])
439+
440+
ax = fig.add_subplot(gs[0, 0], projection=projection)
441+
_plot_panel(ax, modelTitle, modelArray, **dictModelRef)
442+
axes.append(ax)
433443

434-
if refArray is not None:
435-
ax = plt.subplot(subplots[1], projection=projection)
444+
ax = fig.add_subplot(gs[2, 0], projection=projection)
436445
_plot_panel(ax, refTitle, refArray, **dictModelRef)
437446
axes.append(ax)
438447

439-
ax = plt.subplot(subplots[2], projection=projection)
448+
ax = fig.add_subplot(gs[4, 0], projection=projection)
440449
_plot_panel(ax, diffTitle, diffArray, **dictDiff)
441450
axes.append(ax)
451+
else:
452+
ax = plt.subplot(subplots[0], projection=projection)
453+
_plot_panel(ax, modelTitle, modelArray, **dictModelRef)
454+
axes.append(ax)
455+
456+
if refArray is not None:
457+
ax = plt.subplot(subplots[1], projection=projection)
458+
_plot_panel(ax, refTitle, refArray, **dictModelRef)
459+
axes.append(ax)
460+
461+
ax = plt.subplot(subplots[2], projection=projection)
462+
_plot_panel(ax, diffTitle, diffArray, **dictDiff)
463+
axes.append(ax)
442464

443465
_add_stats(modelArray, refArray, diffArray, Lats, axes)
444466

467+
# Note: in the multi-line reference-title case, uneven spacing is handled
468+
# via GridSpec so all three panels keep identical sizes.
469+
445470
if fileout is not None:
446471
savefig(fileout, config, pad_inches=0.2)
447472

@@ -775,12 +800,12 @@ def _add_stats(modelArray, refArray, diffArray, Lats, axes):
775800

776801
def _add_stats_text(names, values, ax, loc):
777802
if loc == 'upper':
778-
text_ax = inset_axes(ax, width='17%', height='20%', loc='upper right',
779-
bbox_to_anchor=(0.2, 0.1, 1., 1.),
803+
text_ax = inset_axes(ax, width='19%', height='20%', loc='upper right',
804+
bbox_to_anchor=(0.22, 0.1, 1., 1.),
780805
bbox_transform=ax.transAxes, borderpad=0)
781806
else:
782-
text_ax = inset_axes(ax, width='17%', height='20%', loc='lower right',
783-
bbox_to_anchor=(0.2, 0.03, 1., 1.),
807+
text_ax = inset_axes(ax, width='19%', height='20%', loc='lower right',
808+
bbox_to_anchor=(0.22, 0.03, 1., 1.),
784809
bbox_transform=ax.transAxes, borderpad=0)
785810

786811
text = '\n'.join(names)

suite/main_vs_ctrl.cfg

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,3 @@
77
# control run is desired.
88
controlRunConfigFile = ../ctrl.cfg
99

10-
# config file for a main run on which the analysis was already run to
11-
# completion. The relevant MPAS climatologies already exist and have been
12-
# remapped to the comparison grid and time series have been extracted.
13-
# Leave this option commented out if the analysis for the main run should be
14-
# performed.
15-
mainRunConfigFile = ../main.cfg
16-

suite/run_dev_suite.bash

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ py=$(python -c 'import sys; print(f"{sys.version_info[0]}.{sys.version_info[1]}"
2525
./suite/setup.py -p ${py} -r wc_defaults -b ${branch} --no_polar_regions -e ${env_name}
2626
./suite/setup.py -p ${py} -r moc_am -b ${branch} -e ${env_name}
2727
./suite/setup.py -p ${py} -r no_ncclimo -b ${branch} -e ${env_name}
28-
./suite/setup.py -p ${py} -r main -b ${branch} -e ${env_name}
2928
./suite/setup.py -p ${py} -r ctrl -b ${branch} -e ${env_name}
3029
./suite/setup.py -p ${py} -r main_vs_ctrl -b ${branch} -e ${env_name}
3130
./suite/setup.py -p ${py} -r no_polar_regions -b ${branch} --no_polar_regions -e ${env_name}

suite/run_e3sm_unified_suite.bash

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ machine=${E3SMU_MACHINE}
1313
./suite/setup.py -p ${py} -r wc_defaults -b ${branch} --no_polar_regions
1414
./suite/setup.py -p ${py} -r moc_am -b ${branch}
1515
./suite/setup.py -p ${py} -r no_ncclimo -b ${branch}
16-
./suite/setup.py -p ${py} -r main -b ${branch}
1716
./suite/setup.py -p ${py} -r ctrl -b ${branch}
1817
./suite/setup.py -p ${py} -r main_vs_ctrl -b ${branch}
1918
./suite/setup.py -p ${py} -r no_polar_regions -b ${branch} --no_polar_regions

suite/run_suite.bash

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,6 @@ conda deactivate
5959

6060
py=${alt_py}
6161
conda activate test_mpas_analysis_py${py}
62-
./suite/setup.py -p ${py} -r main -b ${branch}
6362
./suite/setup.py -p ${py} -r main_py${py} -b ${branch}
6463
conda deactivate
6564

suite/setup.py

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -91,15 +91,23 @@ def main():
9191
shutil.copytree(os.path.join('docs', '_build', 'html'), docs_path)
9292

9393
if mesh == 'oQU240wLI':
94-
generate = "['all', 'no_BGC', 'no_icebergs', 'no_index', 'no_eke', " \
95-
"'no_waves']"
94+
generate = [
95+
'all', 'no_BGC', 'no_icebergs', 'no_index', 'no_eke', 'no_waves'
96+
]
9697
end_year = '10'
98+
ctrl_end_year = '8'
9799
else:
98100
raise ValueError(f'Unexpected mesh: {mesh}')
99101

100102
if args.run == 'mesh_rename':
101103
mesh = f'new_{mesh}'
102104

105+
if args.run == 'main_vs_ctrl':
106+
end_year = ctrl_end_year
107+
generate.append('no_hovmoller')
108+
109+
generate_string = f"['" + "', '".join(generate) + "']"
110+
103111
sbatch = list()
104112
if account is not None:
105113
sbatch.append(f'#SBATCH -A {account}')
@@ -136,7 +144,7 @@ def main():
136144
use_e3sm_unified=use_e3sm_unified, run_name=args.run,
137145
input_base=input_base, simulation=simulation, mesh=mesh,
138146
output_base=output_base, html_base=html_base, out_subdir=out_subdir,
139-
generate=generate, end_year=end_year)
147+
generate=generate_string, end_year=end_year)
140148
with open(config, 'w') as config_file:
141149
config_file.write(config_text)
142150

0 commit comments

Comments
 (0)