From f5907c7e60cab3f98378d67396a9cf404d062793 Mon Sep 17 00:00:00 2001 From: Xylar Asay-Davis Date: Mon, 5 Feb 2024 11:09:22 -0600 Subject: [PATCH] Divide sea ice area/volume data into 10 year chunks This prevents out-of-memory issues when computing total area and volume per hemisphere for very long runs. --- mpas_analysis/default.cfg | 9 ++++++--- mpas_analysis/sea_ice/time_series.py | 10 +++++++++- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/mpas_analysis/default.cfg b/mpas_analysis/default.cfg index 8173ccdd0..3903a90f2 100755 --- a/mpas_analysis/default.cfg +++ b/mpas_analysis/default.cfg @@ -2175,7 +2175,7 @@ seasons = ['ANN', 'JFM', 'JAS'] fieldList = ['significantWaveHeight', 'peakWavePeriod'] era5ObsStartYear = 1959 -era5ObsEndYear = 2021 +era5ObsEndYear = 2021 sscciObsStartYear = 1991 sscciObsEndYear = 2018 @@ -2183,7 +2183,7 @@ sscciObsEndYear = 2018 ## 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 @@ -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 @@ -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 diff --git a/mpas_analysis/sea_ice/time_series.py b/mpas_analysis/sea_ice/time_series.py index 709327b1f..46f83963e 100644 --- a/mpas_analysis/sea_ice/time_series.py +++ b/mpas_analysis/sea_ice/time_series.py @@ -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) @@ -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':