Skip to content

Commit

Permalink
Switch to total land-ice flux in melt time series
Browse files Browse the repository at this point in the history
We still use the old variable if necessary for backwards
compatibility.
  • Loading branch information
xylar committed Feb 28, 2024
1 parent 519349f commit 6bf8b0d
Showing 1 changed file with 19 additions and 5 deletions.
24 changes: 19 additions & 5 deletions mpas_analysis/ocean/time_series_antarctic_melt.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,8 @@ def __init__(self, config, mpasTimeSeriesTask, regionMasksTask,
# nothing else to do
return

masksSubtask = regionMasksTask.add_mask_subtask(regionGroup=regionGroup)
masksSubtask = \
regionMasksTask.add_mask_subtask(regionGroup=regionGroup)
self.iceShelfMasksFile = masksSubtask.geojsonFileName

iceShelvesToPlot = masksSubtask.expand_region_names(iceShelvesToPlot)
Expand Down Expand Up @@ -185,8 +186,7 @@ def __init__(self, parentTask, startYear, endYear, mpasTimeSeriesTask,
self.endYear = endYear
self.startDate = f'{self.startYear:04d}-01-01_00:00:00'
self.endDate = f'{self.endYear:04d}-12-31_23:59:59'
self.variableList = \
['timeMonthly_avg_landIceFreshwaterFlux']
self.variableList = None

def setup_and_check(self):
"""
Expand Down Expand Up @@ -230,6 +230,13 @@ def setup_and_check(self):
raise IOError('No MPAS-O restart file found: need at least one '
'restart file for Antarctic melt calculations')

totalFluxVar = 'timeMonthly_avg_landIceFreshwaterFluxTotal'
landIceFluxVar = 'timeMonthly_avg_landIceFreshwaterFlux'
if totalFluxVar in self.mpasTimeSeriesTask.allVariables:
self.variableList = [totalFluxVar]
else:
self.variableList = [landIceFluxVar]

self.mpasTimeSeriesTask.add_variables(variableList=self.variableList)

return
Expand Down Expand Up @@ -309,13 +316,20 @@ def run_task(self):

regionNames = decode_strings(dsRegionMask.regionNames)

totalFluxVar = 'timeMonthly_avg_landIceFreshwaterFluxTotal'
landIceFluxVar = 'timeMonthly_avg_landIceFreshwaterFlux'

if totalFluxVar in dsIn:
fluxVar = totalFluxVar
else:
fluxVar = landIceFluxVar

datasets = []
nTime = dsIn.sizes['Time']
for tIndex in range(nTime):
self.logger.info(f' {tIndex + 1}/{nTime}')

freshwaterFlux = \
dsIn.timeMonthly_avg_landIceFreshwaterFlux.isel(Time=tIndex)
freshwaterFlux = dsIn[fluxVar].isel(Time=tIndex)

nRegions = dsRegionMask.sizes['nRegions']
meltRates = numpy.zeros((nRegions,))
Expand Down

0 comments on commit 6bf8b0d

Please sign in to comment.