Skip to content

Commit da72e59

Browse files
authored
Merge pull request #998 from xylar/mask-very-thick-ice
Add support for maximum allowed sea-ice thickness
2 parents ffbf8e1 + 0728de9 commit da72e59

2 files changed

Lines changed: 25 additions & 5 deletions

File tree

mpas_analysis/default.cfg

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3970,6 +3970,9 @@ areaSH = IceArea_timeseries/iceAreaSH_climo_20180710.nc
39703970
volNH = PIOMAS/PIOMASvolume_monthly_climo_20180710.nc
39713971
volSH = none
39723972

3973+
# mask sea ice that is thicker than this a threshold (m)
3974+
maxAllowedSeaIceThickness = None
3975+
39733976

39743977
[climatologyMapSeaIceProductionNH]
39753978
# options related to plotting horizontally remapped climatologies of

mpas_analysis/sea_ice/time_series.py

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
# distributed with this code, or at
1010
# https://raw.githubusercontent.com/MPAS-Dev/MPAS-Analysis/main/LICENSE
1111

12+
import numpy as np
1213
import xarray as xr
1314

1415
from mpas_analysis.shared import AnalysisTask
@@ -590,6 +591,14 @@ def _compute_area_vol(self):
590591
config = self.config
591592
chunkYears = config.getint('timeSeriesSeaIceAreaVol', 'chunkYears')
592593

594+
maxAllowedSeaIceThickness = config.get(
595+
'timeSeriesSeaIceAreaVol', 'maxAllowedSeaIceThickness')
596+
597+
if maxAllowedSeaIceThickness == 'None':
598+
maxAllowedSeaIceThickness = None
599+
else:
600+
maxAllowedSeaIceThickness = float(maxAllowedSeaIceThickness)
601+
593602
outFileNames = {}
594603
for hemisphere in ['NH', 'SH']:
595604
baseDirectory = build_config_full_path(
@@ -612,6 +621,10 @@ def _compute_area_vol(self):
612621
startDate=self.startDate,
613622
endDate=self.endDate)
614623

624+
ds = ds.rename(
625+
{'timeMonthly_avg_iceAreaCell': 'iceConc',
626+
'timeMonthly_avg_iceVolumeCell': 'iceThick'})
627+
615628
nTime = ds.sizes['Time']
616629
# chunk into 10-year seguments so we don't run out of memory
617630
if nTime > 12 * chunkYears:
@@ -624,22 +637,26 @@ def _compute_area_vol(self):
624637
else:
625638
mask = dsMesh.latCell < 0
626639

640+
if maxAllowedSeaIceThickness is not None:
641+
mask = np.logical_and(mask,
642+
ds.iceThick <= maxAllowedSeaIceThickness)
643+
627644
dsAreaSum = (ds.where(mask) * dsMesh.areaCell).sum('nCells')
628645
dsAreaSum = dsAreaSum.rename(
629-
{'timeMonthly_avg_iceAreaCell': 'iceArea',
630-
'timeMonthly_avg_iceVolumeCell': 'iceVolume'})
646+
{'iceConc': 'iceArea',
647+
'iceThick': 'iceVolume'})
631648
dsAreaSum['iceThickness'] = (dsAreaSum.iceVolume /
632649
dsMesh.areaCell.sum('nCells'))
633650

634651
dsAreaSum['iceArea'].attrs['units'] = 'm$^2$'
635652
dsAreaSum['iceArea'].attrs['description'] = \
636-
'Total {} sea ice area'.format(hemisphere)
653+
f'Total {hemisphere} sea ice area'
637654
dsAreaSum['iceVolume'].attrs['units'] = 'm$^3$'
638655
dsAreaSum['iceVolume'].attrs['description'] = \
639-
'Total {} sea ice volume'.format(hemisphere)
656+
f'Total {hemisphere} sea ice volume'
640657
dsAreaSum['iceThickness'].attrs['units'] = 'm'
641658
dsAreaSum['iceThickness'].attrs['description'] = \
642-
'Mean {} sea ice volume'.format(hemisphere)
659+
f'Mean {hemisphere} sea ice volume'
643660

644661
dsTimeSeries[hemisphere] = dsAreaSum
645662

0 commit comments

Comments
 (0)