Changeset 26645


Ignore:
Timestamp:
11/19/21 00:12:18 (3 years ago)
Author:
bdef
Message:

BUG:fixing stochasticforcing

File:
1 edited

Legend:

Unmodified
Added
Removed
  • issm/trunk-jpl/src/m/classes/stochasticforcing.py

    r26644 r26645  
    6060        # Check that all fields agree with the corresponding md class
    6161        checkdefaults = False
    62         structstoch   = self.structstochforcing()
     62        structstoch = self.structstochforcing()
     63        print(type(structstoch))
    6364        for field in self.fields:
    64             ### Checks are temporarily commented out: need to debug why this does not work (18Nov2021) ###
     65            # Checks are temporarily commented out: need to debug why this does not work (18Nov2021) #
    6566            if 'SMB' in field:
    66                 mdname = structstoch['mdnames'][structstoch['fields']==field]
    67                 #if (type(md.smb) != mdname):
    68                 #    raise TypeError('md.smb does not agree with stochasticforcing field {}'.format(field))
     67                mdname = structstoch[field]
     68                if (type(md.smb).__name__ != mdname):
     69                    raise TypeError('md.smb does not agree with stochasticforcing field {}'.format(mdname))
    6970            if 'FrontalForcings' in field:
    70                 mdname = structstoch['mdnames'][structstoch['fields']==field]
    71                 #if (type(md.frontalforcings) != mdname):
    72                 #    raise TypeError('md.frontalforcings does not agree with stochasticforcing field {}'.format(field))
     71                mdname = structstoch[field]
     72                if (type(md.frontalforcings).__name__ != mdname):
     73                    raise TypeError('md.frontalforcings does not agree with stochasticforcing field {}'.format(mdname))
    7374            if 'Calving' in field:
    74                 mdname = structstoch['mdnames'][structstoch['fields']==field]
    75                 #if (type(md.calving) != mdname):
    76                 #    raise TypeError('md.calving does not agree with stochasticforcing field {}'.format(field))
     75                mdname = structstoch[field]
     76                if (type(md.calving).__name__ != mdname):
     77                    raise TypeError('md.calving does not agree with stochasticforcing field {}'.format(mdname))
    7778            if 'BasalforcingsFloatingice' in field:
    78                 mdname = structstoch['mdnames'][structstoch['fields']==field]
    79                 #if (type(md.basalforcings) != mdname):
    80                 #    raise TypeError('md.basalforcings does not agree with stochasticforcing field {}'.format(field))#Checking for specific dimensions
     79                mdname = structstoch[field]
     80                if (type(md.basalforcings).__name__ != mdname):
     81                    raise TypeError('md.basalforcings does not agree with stochasticforcing field {}'.format(mdname))  #Checking for specific dimensions
    8182            if not (field == 'SMBautoregression' or field == 'FrontalForcingsRignotAutoregression'):
    8283                checkdefaults = True   #field with non-specific dimensionality
     
    9192        if ('FrontalForcingsRignotAutoregression' in self.fields):
    9293            size_tot = size_tot - self.defaultdimension + md.frontalforcings.num_basins
    93             indTFar  = self.fields.index('FrontalForcingsRignotAutoregression')
     94            indTFar = self.fields.index('FrontalForcingsRignotAutoregression')
    9495        if (indSMBar != -1 and indTFar != -1):
    9596            covsum = self.covariance[np.sum(self.defaultdimensions[0:indSMBar]).astype(int):np.sum(self.defaultdimensions[0:indSMBar + 1]).astype(int), np.sum(self.defaultdimensions[0:indTFar]).astype(int):np.sum(self.defaultdimensions[0:indTFar + 1]).astype(int)]
     
    152153    # }}}
    153154
    154     def supportedstochforcings(self): # {{{
     155    def supportedstochforcings(self):  # {{{
    155156        """Defines list of fields supported by the class md.stochasticforcing
    156157        """
    157158        list1 = self.structstochforcing()
    158         list1 = list1['fields']
    159         return(list1) #}}}
     159        list1 = list1.keys()
     160        return list(list1)
     161    #}}}
    160162
    161     def structstochforcing(self): # {{{
     163    def structstochforcing(self):  # {{{
    162164        """Defines dictionary with list of fields
    163165           supported and corresponding md names
    164166        """
    165         structure = dict({
    166                     'fields':
    167                         ['DefaultCalving',
    168                         'FloatingMeltRate',
    169                         'FrontalForcingsRignotAutoregression',
    170                         'SMBautoregression'],
    171 
    172                     'mdnames':
    173                         ['calving',
    174                         'basalforcings',
    175                         'frontalforcingsrignotautoregression',
    176                         'SMBautoregression']})
    177         return(structure) # }}}
    178 
     167        structure = {'DefaultCalving': 'calving',
     168                     'FloatingMeltRate': 'basalforcings',
     169                     'FrontalForcingsRignotAutoregression': 'frontalforcingsrignotautoregression',
     170                     'SMBautoregression': 'SMBautoregression'}
     171        return structure
     172    # }}}
Note: See TracChangeset for help on using the changeset viewer.