99# distributed with this code, or at
1010# https://raw.githubusercontent.com/MPAS-Dev/MPAS-Analysis/main/LICENSE
1111
12+ import numpy as np
1213import xarray as xr
1314
1415from 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