Skip to content

Commit

Permalink
Divide sea ice area/volume data into 10 year chunks
Browse files Browse the repository at this point in the history
This prevents out-of-memory issues when computing total area and
volume per hemisphere for very long runs.
  • Loading branch information
xylar committed Feb 5, 2024
1 parent 27d0c23 commit f5907c7
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
9 changes: 6 additions & 3 deletions mpas_analysis/default.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -2175,15 +2175,15 @@ seasons = ['ANN', 'JFM', 'JAS']
fieldList = ['significantWaveHeight', 'peakWavePeriod']

era5ObsStartYear = 1959
era5ObsEndYear = 2021
era5ObsEndYear = 2021
sscciObsStartYear = 1991
sscciObsEndYear = 2018

[climatologyMapWavesSignificantWaveHeight]
## options related to plotting climatology maps of significant wave height

# colormap for model/observations
colormapNameResult = viridis
colormapNameResult = viridis
# whether the colormap is indexed or continuous
colormapTypeResult = continuous
# the type of norm used in the colormap
Expand All @@ -2208,7 +2208,7 @@ normArgsDifference = {'vmin': -5., 'vmax': 5.}
## options related to plotting climatology maps of peak wave frequency

# colormap for model/observations
colormapNameResult = plasma
colormapNameResult = plasma
# whether the colormap is indexed or continuous
colormapTypeResult = continuous
# the type of norm used in the colormap
Expand Down Expand Up @@ -3949,6 +3949,9 @@ titleFontSize = 18
# plot on polar plot
polarPlot = False

# the number of years to chunk the data over to prevent running out of memory
chunkYears = 10

# An optional first year for the tick marks on the x axis. Leave commented out
# to start at the beginning of the time series.
# firstYearXTicks = 1
Expand Down
10 changes: 9 additions & 1 deletion mpas_analysis/sea_ice/time_series.py
Original file line number Diff line number Diff line change
Expand Up @@ -587,10 +587,13 @@ def _compute_area_vol(self):
indices to process.
"""

config = self.config
chunkYears = config.get('timeSeriesSeaIceAreaVol', 'chunkYears')

outFileNames = {}
for hemisphere in ['NH', 'SH']:
baseDirectory = build_config_full_path(
self.config, 'output', 'timeSeriesSubdirectory')
config, 'output', 'timeSeriesSubdirectory')

make_directories(baseDirectory)

Expand All @@ -609,6 +612,11 @@ def _compute_area_vol(self):
startDate=self.startDate,
endDate=self.endDate)

nTime = ds.sizes['Time']
# chunk into 10-year seguments so we don't run out of memory
if nTime > 12 * chunkYears:
ds = ds.chunk({'Time': 12 * chunkYears})

for hemisphere in ['NH', 'SH']:

if hemisphere == 'NH':
Expand Down

0 comments on commit f5907c7

Please sign in to comment.