Changeset 26539


Ignore:
Timestamp:
11/04/21 12:47:30 (3 years ago)
Author:
jdquinn
Message:

BUG: Need to check on field type before taking length

File:
1 edited

Legend:

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

    r26538 r26539  
    7676    def marshall(self, prefix, md, fid):  # {{{
    7777        yts = md.constants.yts
    78         num_fields = range(self.fields)
    79         # Scaling covariance matrix (scale column-by-column and row-by-row)
    80         scaledfields = ['SMBautoregression'] # list of fields that need scaling * 1/yts
    81         for i in range(num_fields):
    82             print(i)
    83             if self.fields[i] in scaledfields:
    84                 print(self.fields[i])
    85                 inds = range(1 + np.sum(self.dimensions[0:i]), np.sum(self.dimensions[0:i]))
    86                 for row in inds: # scale rows corresponding to scaled field
    87                     self.covariance[row, :] = 1 / yts * self.covariance[row, :]
    88                 for col in inds: # scale columns corresponding to scaled field
    89                     self.covariance[:, col] = 1 / yts * self.covariance[:, col]
     78        if (type(self.fields) is list):
     79            num_fields = len(self.fields)
     80            # Scaling covariance matrix (scale column-by-column and row-by-row)
     81            scaledfields = ['SMBautoregression'] # list of fields that need scaling * 1/yts
     82            for i in range(num_fields):
     83                if self.fields[i] in scaledfields:
     84                    inds = range(1 + np.sum(self.dimensions[0:i]), np.sum(self.dimensions[0:i]))
     85                    for row in inds: # scale rows corresponding to scaled field
     86                        self.covariance[row, :] = 1 / yts * self.covariance[row, :]
     87                    for col in inds: # scale columns corresponding to scaled field
     88                        self.covariance[:, col] = 1 / yts * self.covariance[:, col]
    9089
    9190        WriteData(fid, prefix, 'object', self, 'fieldname', 'isstochasticforcing', 'format', 'Boolean')
Note: See TracChangeset for help on using the changeset viewer.