diff --git a/mpas_analysis/ocean/ocean_regional_profiles.py b/mpas_analysis/ocean/ocean_regional_profiles.py index 7f7c6b57b..5ff8f9485 100644 --- a/mpas_analysis/ocean/ocean_regional_profiles.py +++ b/mpas_analysis/ocean/ocean_regional_profiles.py @@ -349,6 +349,7 @@ def run_task(self): dsMesh = xr.open_dataset(meshFilename) dsMesh = dsMesh.isel(Time=0) areaCell = dsMesh.areaCell + openOceanMask = xr.where(dsMesh.landIceMask > 0, 0, 1) nVertLevels = dsMesh.sizes['nVertLevels'] @@ -382,7 +383,9 @@ def run_task(self): cellMasks = dsRegionMask.regionCellMasks regionNamesVar = dsRegionMask.regionNames - totalArea = self._masked_area_sum(cellMasks, areaCell, vertDepthMask) + totalArea = self._masked_area_sum( + cellMasks, openOceanMask, areaCell, vertDepthMask + ) datasets = [] for timeIndex, fileName in enumerate(inputFiles): @@ -410,13 +413,18 @@ def run_task(self): var = dsLocal[variableName].where(vertDepthMask) meanName = '{}_mean'.format(prefix) - dsLocal[meanName] = \ - self._masked_area_sum(cellMasks, areaCell, var) / totalArea + dsLocal[meanName] = ( + self._masked_area_sum( + cellMasks, openOceanMask, areaCell, var + ) / totalArea + ) meanSquaredName = '{}_meanSquared'.format(prefix) - dsLocal[meanSquaredName] = \ - self._masked_area_sum(cellMasks, areaCell, var**2) / \ - totalArea + dsLocal[meanSquaredName] = ( + self._masked_area_sum( + cellMasks, openOceanMask, areaCell, var**2 + ) / totalArea + ) # drop the original variables dsLocal = dsLocal.drop_vars(variableList) @@ -449,12 +457,15 @@ def run_task(self): write_netcdf_with_fill(dsOut, outputFileName) @staticmethod - def _masked_area_sum(cellMasks, areaCell, var): + def _masked_area_sum(cellMasks, openOceanMask, areaCell, var): """sum a variable over the masked areas""" nRegions = cellMasks.sizes['nRegions'] totals = [] for index in range(nRegions): - mask = cellMasks.isel(nRegions=slice(index, index+1)) + mask = ( + cellMasks.isel(nRegions=slice(index, index+1)) * + openOceanMask + ) totals.append((mask * areaCell * var).sum('nCells')) total = xr.concat(totals, 'nRegions') diff --git a/mpas_analysis/ocean/time_series_antarctic_melt.py b/mpas_analysis/ocean/time_series_antarctic_melt.py index 65dff877d..9764fef20 100644 --- a/mpas_analysis/ocean/time_series_antarctic_melt.py +++ b/mpas_analysis/ocean/time_series_antarctic_melt.py @@ -342,7 +342,7 @@ def run_task(self): dsOut = xarray.concat(objs=datasets, dim='Time') dsOut['regionNames'] = dsRegionMask.regionNames - dsOut.integratedMeltFlux.attrs['units'] = 'GT a$^{-1}$' + dsOut.integratedMeltFlux.attrs['units'] = 'Gt a$^{-1}$' dsOut.integratedMeltFlux.attrs['description'] = \ 'Integrated melt flux summed over each ice shelf or region' dsOut.meltRates.attrs['units'] = 'm a$^{-1}$' @@ -662,7 +662,7 @@ def run_task(self): suffix = self.iceShelf.replace(' ', '_') xLabel = 'Time (yr)' - yLabel = 'Melt Flux (GT/yr)' + yLabel = 'Melt Flux (Gt/yr)' timeSeries = integratedMeltFlux.isel(nRegions=self.regionIndex) @@ -723,7 +723,7 @@ def run_task(self): # and cartopy doesn't play too well with tight_layout anyway plt.tight_layout() - add_inset(fig, fc, width=2.0, height=2.0) + add_inset(fig, fc, width=1.0, height=1.0, lowerleft=[0.0, 0.0], xbuffer=0.01, ybuffer=0.01) savefig(outFileName, config) @@ -788,7 +788,7 @@ def run_task(self): # and cartopy doesn't play too well with tight_layout anyway plt.tight_layout() - add_inset(fig, fc, width=2.0, height=2.0) + add_inset(fig, fc, width=1.0, height=1.0, lowerleft=[0.0, 0.0], xbuffer=0.01, ybuffer=0.01) savefig(outFileName, config) diff --git a/mpas_analysis/ocean/time_series_ocean_regions.py b/mpas_analysis/ocean/time_series_ocean_regions.py index cd758e62d..c84f0dbc6 100644 --- a/mpas_analysis/ocean/time_series_ocean_regions.py +++ b/mpas_analysis/ocean/time_series_ocean_regions.py @@ -1350,7 +1350,7 @@ def run_task(self): # and cartopy doesn't play too well with tight_layout anyway plt.tight_layout() - add_inset(fig, fc, width=2.0, height=2.0) + add_inset(fig, fc, width=1.0, height=1.0, lowerleft=[0.0, 0.0], xbuffer=0.01, ybuffer=0.01) savefig(outFileName, config, tight=False)