Esempio n. 1
0
    def __init__(self, ds):
        """ 
        input:
        ds       (xr.Dataset)  geometry dataset from one of the Geometry classes

        output:
        self.ds  (xr.Dataset)  original `ds` with additional fields:
            Tz   (z)   [degC]  ambient potential temperature
            Sz   (z)   [psu]   ambient salinity

            Plume/Sheet/Simple:  spatially extended ambient T/S fields
            Ta   (x,y) [degC]  ambient potential temperature
            Sa   (x,y) [psu]   ambient salinity

            PICO/PICOP:        single temperature/salinity values for  model
            TaD  ()    [degC]  temperature at deepest part of grounding line
            Ta5  ()    [degC]  temperature at 500 m
            Ta7  ()    [degC]  temperature at 700 m
            TaL  ()    [degC]  temperature at 
        """
        assert 'draft' in ds
        self.ds = ds
        self.ds = self.ds.assign_coords({'z': np.arange(-5000., 0, 1)})
        ModelConstants.__init__(self)
        return
Esempio n. 2
0
 def __init__(self, name, pdict=None):
     """ 
     input:
     name  .. (str) 
     pdict .. (dict)  parameter dictionary
     """
     ModelConstants.__init__(self)
     assert name in cases
     self.name = name
     self.pdict = pdict
     self.n = 5
     return
Esempio n. 3
0
    def __init__(self, ds):
        #Read input
        self.dx = ds.x[1]-ds.x[0]
        self.dy = ds.y[1]-ds.y[0]
        if self.dx<0:
            print('inverting x-coordinates')
            ds = ds.reindex(x=list(reversed(ds.x)))
            self.dx = -self.dx
        if self.dy<0:
            print('inverting y-coordinates')
            ds = ds.reindex(y=list(reversed(ds.y)))
            self.dy = -self.dy
            
        self.ds   = ds
        self.x    = ds.x
        self.y    = ds.y        
        self.mask = ds.mask
        self.zb   = ds.draft
        self.z    = ds.z.values
        self.Tz   = ds.Tz.values
        self.Sz   = ds.Sz.values
        self.ind  = np.indices(self.zb.shape)

        #Physical parameters
        ModelConstants.__init__(self)
        self.f = -1.37e-4     # Coriolis parameter [1/s]
        
        #Some input params
        self.nu   = .8          # Nondimensional factor for Robert Asselin time filter
        self.slip = 1           # Nondimensional factor Free slip: 0, no slip: 2, partial no slip: [0..2]  
        self.Ah   = 6           # Laplacian viscosity [m^2/s]
        self.Kh   = 1           # Diffusivity [m^2/s]
        self.dt   = 40          # Time step [s]
        
        self.cl   = 0.0245      # Parameter for Holland entrainment
        self.Cdtop= .0008       # Drag coefficient in Ustar
        self.utide = 0.01       # RMS tidal velocity [m/s]
        self.Pr   = 13.8        # Prandtl number
        self.Sc   = 2432.       # Schmidt number
        self.nu0  = 1.95e-6     # Molecular viscosity [m^2/s]
        self.rhofw = 1000.      # Density of freshwater [kg/m^3]
        
        self.boundop = 2        # Option for boundary conditions D,T,S. [use 1 for isomip]
        self.minD = 1.          # Cutoff thickness [m]
        self.maxD = 3000.       # Cutoff maximum thickness [m]
        self.vcut = 1.414       # Cutoff velocity U and V [m/s]
        self.Dinit = 10.        # Initial uniform thickness [m]
        
        #Some parameters for displaying output
        self.diagday = .1       # Timestep at which to print diagnostics
        self.verbose = True
        self.saveday = 10        # Interval at which to save time-average fields [days]
        self.restday = 10        # Interval at which to save restart file [days]
Esempio n. 4
0
    def __init__(self, dp):
        ModelConstants.__init__(self)
        assert type(dp) == xr.core.dataset.Dataset
        assert 'x' in dp.coords
        for q in ['dgrl', 'draft', 'alpha', 'grl_adv', 'Ta', 'Sa', 'Tf']:
            assert q in dp, f'missing {q}'
        self.dp = dp

        # setting minimum angle to 0
        self.dp['alpha'] = xr.where(self.dp.alpha > 0, self.dp.alpha, 0)

        # freezing point at corresponding grounding line, eqn (7)
        self.dp[
            'Tf0'] = self.l1 * self.dp.Sa + self.l2 + self.l3 * self.dp.grl_adv
        self.dp.Tf0.attrs = {
            'long_name':
            'potential pressure freezing point temperature at corresponding grounding line origin',
            'units': 'degC'
        }

        # calculate dimensionless coordinate dgrl_=$\tilde{x}$ (28b)
        self.Ea = self.E0 * np.sin(self.dp.alpha)
        self.dT = self.dp.Ta - self.dp.Tf0
        # self.dT = self.dT.where(self.dT>0,0)

        self.dp['dgrl_'] = self.l3*(self.dp.draft-self.dp.grl_adv)/self.dT/\
                           (1+self.Ce*(self.Ea/(self.CG+self.ct+self.Ea))**(3/4))
        self.dp.dgrl_.attrs = {
            'long_name':
            'dimensionless coordinate tilde{x} in limited range [0,1); eqn. (28b)'
        }

        # self.dp['dgrl_'] = xr.where(self.dp.dgrl_>0,self.dp.dgrl_,0)
        self.dp['dgrl_'] = xr.where(self.dp.dgrl_ > 0, self.dp.dgrl_, 0)
        self.dp['dgrl_'] = xr.where(self.dp.dgrl_ < 1, self.dp.dgrl_,
                                    1).where(self.dp.mask == 3)

        # reused parameter combinations
        self.f1 = self.bs * self.dp.Sa * self.g / (self.l3 *
                                                   (self.L / self.cp)**3)
        self.f2 = (1 - self.cr1 * self.CG) / (self.Cd + self.Ea)
        self.f3 = self.CG * self.Ea / (self.CG + self.ct * self.Ea)

        return
Esempio n. 5
0
    def __init__(self, ds):
        """ initialize model class

        input:
        ds  (xr.Dataset)  contains:
            draft

        output:
        ds  (xr.Dataset)  with the following added fields: 
            M
            Tk
            Sk
            mk
            q

        boxnr 0 refers to ambient (temperature/salinity) or total (area/melt)
        """
        ModelConstants.__init__(self)
        self.ds = ds
        self.n = int(self.ds.n.values)

        self.fn_PICO_output = f'{path}/results/PICO/PICO_{self.ds.name_geo}_{self.ds.name_forcing}.nc'

        # intermediate constants for each box
        self.nulambda = self.rhoi/self.rhow*self.L/self.cp
        self.g1 = np.zeros((self.n+1))  # A_k*gamma^\star_T
        self.g2 = np.zeros((self.n+1))  # g1/nu/lambda
        self.pk = np.zeros((self.n+1))  # average pressure of box k
        
        for k in np.arange(1,self.n+1):
            self.g1[k] = abs(self.ds.area_k[k])*self.gammae  # defined just above (A6)
            self.g2[k] = self.g1[k]/self.nulambda
            self.pk[k] = self.ds.p.where(self.ds.box==k).mean(['x','y'])
        
        self.M = xr.zeros_like(self.ds.draft).where(self.ds.mask==3)  # melt(x,y)
        self.M.name = 'melt'
        self.M.attrs = {'long_name':'dimensional melt', 'units':'m/yr'}
        self.T = np.zeros((self.n+1))  # box avg ambient temp
        self.S = np.zeros((self.n+1))  # box avg ambient temp
        self.m = np.zeros((self.n+1))  # box avg melt rate
        self.T[0] = self.ds.Ta.where(self.ds.draft==self.ds.draft.min()).mean().values
        self.S[0] = self.ds.Sa.where(self.ds.draft==self.ds.draft.min()).mean().values
        return
Esempio n. 6
0
    def __init__(self, name, n=None):
        """
        input:
        name .. name of ice shelf
        n    .. number of boxes in PICO model

        output:

        """
        ModelConstants.__init__(self)
        assert name in glaciers
        self.name = name
        if n is None: self.n = RealGeometry.find(self.name, 'n')
        else: self.n = n
        self.fn = f'{path}/results/geometry/{name}_n{self.n}_geometry.nc'
        self.fn_evo = f'{path}/results/advection/{name}_evo.nc'
        self.fn_isf = f'{path}/data/mask_polygons/{name}_isf.geojson'
        self.fn_grl = f'{path}/data/mask_polygons/{name}_grl.geojson'
        self.fn_grl2 = f'{path}/data/mask_polygons/{name}_grl2.geojson'
        self.fn_outline = f'{path}/data/mask_polygons/{name}_polygon.geojson'
        for fn in [self.fn_outline, self.fn_grl, self.fn_grl2, self.fn_isf]:
            assert os.path.exists(fn), f'file does not exists:  {fn}'
        return
Esempio n. 7
0
 def __init__(self, ds):
     ModelConstants.__init__(self)
     self.ds = ds
     for q in ['draft', 'Ta', 'Sa', 'p', 'Tf']:
         assert q in self.ds, f'{q} missing'
     return