9
9
# distributed with this code, or at
10
10
# https://raw.githubusercontent.com/MPAS-Dev/MPAS-Analysis/main/LICENSE
11
11
12
+ import numpy as np
12
13
import xarray as xr
13
14
14
15
from mpas_analysis .shared import AnalysisTask
@@ -590,6 +591,14 @@ def _compute_area_vol(self):
590
591
config = self .config
591
592
chunkYears = config .getint ('timeSeriesSeaIceAreaVol' , 'chunkYears' )
592
593
594
+ maxAllowedSeaIceThickness = config .get (
595
+ 'timeSeriesSeaIceAreaVol' , 'maxAllowedSeaIceThickness' )
596
+
597
+ if maxAllowedSeaIceThickness == 'None' :
598
+ maxAllowedSeaIceThickness = None
599
+ else :
600
+ maxAllowedSeaIceThickness = float (maxAllowedSeaIceThickness )
601
+
593
602
outFileNames = {}
594
603
for hemisphere in ['NH' , 'SH' ]:
595
604
baseDirectory = build_config_full_path (
@@ -612,6 +621,10 @@ def _compute_area_vol(self):
612
621
startDate = self .startDate ,
613
622
endDate = self .endDate )
614
623
624
+ ds = ds .rename (
625
+ {'timeMonthly_avg_iceAreaCell' : 'iceConc' ,
626
+ 'timeMonthly_avg_iceVolumeCell' : 'iceThick' })
627
+
615
628
nTime = ds .sizes ['Time' ]
616
629
# chunk into 10-year seguments so we don't run out of memory
617
630
if nTime > 12 * chunkYears :
@@ -624,22 +637,26 @@ def _compute_area_vol(self):
624
637
else :
625
638
mask = dsMesh .latCell < 0
626
639
640
+ if maxAllowedSeaIceThickness is not None :
641
+ mask = np .logical_and (mask ,
642
+ ds .iceThick <= maxAllowedSeaIceThickness )
643
+
627
644
dsAreaSum = (ds .where (mask ) * dsMesh .areaCell ).sum ('nCells' )
628
645
dsAreaSum = dsAreaSum .rename (
629
- {'timeMonthly_avg_iceAreaCell ' : 'iceArea' ,
630
- 'timeMonthly_avg_iceVolumeCell ' : 'iceVolume' })
646
+ {'iceConc ' : 'iceArea' ,
647
+ 'iceThick ' : 'iceVolume' })
631
648
dsAreaSum ['iceThickness' ] = (dsAreaSum .iceVolume /
632
649
dsMesh .areaCell .sum ('nCells' ))
633
650
634
651
dsAreaSum ['iceArea' ].attrs ['units' ] = 'm$^2$'
635
652
dsAreaSum ['iceArea' ].attrs ['description' ] = \
636
- 'Total {} sea ice area' . format ( hemisphere )
653
+ f 'Total { hemisphere } sea ice area'
637
654
dsAreaSum ['iceVolume' ].attrs ['units' ] = 'm$^3$'
638
655
dsAreaSum ['iceVolume' ].attrs ['description' ] = \
639
- 'Total {} sea ice volume' . format ( hemisphere )
656
+ f 'Total { hemisphere } sea ice volume'
640
657
dsAreaSum ['iceThickness' ].attrs ['units' ] = 'm'
641
658
dsAreaSum ['iceThickness' ].attrs ['description' ] = \
642
- 'Mean {} sea ice volume' . format ( hemisphere )
659
+ f 'Mean { hemisphere } sea ice volume'
643
660
644
661
dsTimeSeries [hemisphere ] = dsAreaSum
645
662
0 commit comments