1010# https://raw.githubusercontent.com/MPAS-Dev/MPAS-Analysis/main/LICENSE
1111
1212import numpy as np
13+ import xarray as xr
1314from mpas_tools .cime .constants import constants as cime_constants
1415
1516from mpas_analysis .ocean .remap_depth_slices_subtask import (
@@ -173,7 +174,7 @@ def __init__(self, config, mpasClimatologyTask, controlConfig=None):
173174 subtaskName = subtaskName )
174175
175176 subtask .set_plot_info (
176- outFileLabel = varName ,
177+ outFileLabel = f'cust_ { varName } ' ,
177178 fieldNameInTitle = title ,
178179 mpasFieldName = mpasVarName ,
179180 refFieldName = mpasVarName ,
@@ -269,14 +270,19 @@ def customize_masked_climatology(self, climatology, season):
269270 the modified climatology data set
270271 """
271272
272- # first, call the base class's version of this function so we extract
273- # the desired slices.
274- climatology = super ().customize_masked_climatology (climatology ,
275- season )
273+ # first, compute the derived variables, which may rely on having the
274+ # full 3D variables available
275+
276276 derivedVars = []
277277 self ._add_vel_mag (climatology , derivedVars )
278278 self ._add_thermal_forcing (climatology , derivedVars )
279279
280+ # then, call the superclass's version of this function so we extract
281+ # the desired slices (but before renaming because it expects the
282+ # original MPAS variable names)
283+ climatology = super ().customize_masked_climatology (climatology ,
284+ season )
285+ # finally, rename the variables and add metadata
280286 for varName , variable in self .variables .items ():
281287 if varName not in derivedVars :
282288 # rename variables from MPAS names to shorter names
@@ -295,10 +301,8 @@ def _add_vel_mag(self, climatology, derivedVars):
295301 """
296302 Add the velocity magnitude to the climatology if requested
297303 """
298- variables = self .variables
299-
300- varName = 'verlocityMagnitude'
301- if varName not in variables :
304+ varName = 'velocityMagnitude'
305+ if varName not in self .variables :
302306 return
303307
304308 derivedVars .append (varName )
@@ -311,10 +315,8 @@ def _add_thermal_forcing(self, climatology, derivedVars):
311315 """
312316 Add thermal forcing to the climatology if requested
313317 """
314- variables = self .variables
315-
316318 varName = 'thermalForcing'
317- if varName not in variables :
319+ if varName not in self . variables :
318320 return
319321
320322 derivedVars .append (varName )
@@ -336,6 +338,12 @@ def _add_thermal_forcing(self, climatology, derivedVars):
336338 dp = cime_constants ['SHR_CONST_G' ]* dens * thick
337339 press = dp .cumsum (dim = 'nVertLevels' ) - 0.5 * dp
338340
341+ # add land ice pressure if available
342+ ds_restart = xr .open_dataset (self .restartFileName )
343+ ds_restart = ds_restart .isel (Time = 0 )
344+ if 'landIcePressure' in ds_restart :
345+ press += ds_restart .landIcePressure
346+
339347 tempFreeze = c0 + cs * salin + cp * press + cps * press * salin
340348
341349 climatology [varName ] = temp - tempFreeze
0 commit comments