Ignore:
Timestamp:
10/11/19 00:25:20 (5 years ago)
Author:
bdef
Message:

CHG: syntax cahnge to meet most of Pep8 requirement

File:
1 edited

Legend:

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

    r21584 r24213  
    44from WriteData import WriteData
    55
     6
    67class giaivins(object):
    7         """
    8         GIA class definition
     8    """
     9    GIA class definition
    910
    10            Usage:
    11               giaivins=giaivins();
    12         """
     11       Usage:
     12          giaivins = giaivins()
     13    """
    1314
    14         def __init__(self): # {{{
    15                 self.mantle_viscosity              = float('NaN');
    16                 self.lithosphere_thickness         = float('NaN');
    17                 self.cross_section_shape           = 0;
    18        
    19                 #set defaults
    20                 self.setdefaultparameters()
     15    def __init__(self):  # {{{
     16        self.mantle_viscosity = float('NaN')
     17        self.lithosphere_thickness = float('NaN')
     18        self.cross_section_shape = 0
    2119
    22                 #}}}
    23         def __repr__(self): # {{{
    24                
    25                 string='   giaivins solution parameters:'
    26                
    27                 string="%s\n%s"%(string,fielddisplay(self,'mantle_viscosity','mantle viscosity constraints (NaN means no constraint) (Pa s)'))
    28                 string="%s\n%s"%(string,fielddisplay(self,'lithosphere_thickness','lithosphere thickness constraints (NaN means no constraint) (m)'))
    29                 string="%s\n%s"%(string,fielddisplay(self,'cross_section_shape',"1: square-edged, 2: elliptical-edged surface"))
    30                 return string
    31                 #}}}
    32         def extrude(self,md): # {{{
    33                 self.mantle_viscosity=project3d(md,'vector',self.mantle_viscosity,'type','node')
    34                 self.lithosphere_thickness=project3d(md,'vector',self.lithosphere_thickness,'type','node')
    35                 return self
    36         #}}}
    37         def setdefaultparameters(self): # {{{
     20    #set defaults
     21        self.setdefaultparameters()
    3822
    39                 self.cross_section_shape=1;
     23    #}}}
    4024
    41                 return self
    42         #}}}
    43         def checkconsistency(self,md,solution,analyses):    # {{{
     25    def __repr__(self):  # {{{
     26        string = '   giaivins solution parameters:'
    4427
    45                 # Early return
    46                 if ('GiaAnalysis' not in  analyses):
    47                         return md
    48                
    49                 md = checkfield(md,'fieldname','gia.mantle_viscosity','NaN',1,'Inf',1,'size',[md.mesh.numberofvertices],'>',0)
    50                 md = checkfield(md,'fieldname','gia.lithosphere_thickness','NaN',1,'Inf',1,'size',[md.mesh.numberofvertices],'>',0)
    51                 md = checkfield(md,'fieldname','gia.cross_section_shape','numel',[1],'values',[1,2])
     28        string = "%s\n%s" % (string, fielddisplay(self, 'mantle_viscosity', 'mantle viscosity constraints (NaN means no constraint) (Pa s)'))
     29        string = "%s\n%s" % (string, fielddisplay(self, 'lithosphere_thickness', 'lithosphere thickness constraints (NaN means no constraint) (m)'))
     30        string = "%s\n%s" % (string, fielddisplay(self, 'cross_section_shape', "1: square-edged, 2: elliptical - edged surface"))
     31        return string
     32    #}}}
    5233
    53                 #be sure that if we are running a masstransport ice flow model coupled with giaivins, that thickness forcings
    54                 #are not provided into the future.
     34    def extrude(self, md):  # {{{
     35        self.mantle_viscosity = project3d(md, 'vector', self.mantle_viscosity, 'type', 'node')
     36        self.lithosphere_thickness = project3d(md, 'vector', self.lithosphere_thickness, 'type', 'node')
     37        return self
     38    #}}}
    5539
    56                 return md
    57         # }}}
    58         def marshall(self,prefix,md,fid):    # {{{
     40    def setdefaultparameters(self):  # {{{
     41        self.cross_section_shape = 1
     42        return self
     43    #}}}
    5944
    60                 WriteData(fid,prefix,'object',self,'fieldname','mantle_viscosity','format','DoubleMat','mattype',1);
    61                 WriteData(fid,prefix,'object',self,'fieldname','lithosphere_thickness','format','DoubleMat','mattype',1,'scale',10.**3.);
    62                 WriteData(fid,prefix,'object',self,'fieldname','cross_section_shape','format','Integer');
    63         # }}}
     45    def checkconsistency(self, md, solution, analyses):  # {{{
     46        # Early return
     47        if ('GiaAnalysis' not in analyses):
     48            return md
     49
     50        md = checkfield(md, 'fieldname', 'gia.mantle_viscosity', 'NaN', 1, 'Inf', 1, 'size', [md.mesh.numberofvertices], '>', 0)
     51        md = checkfield(md, 'fieldname', 'gia.lithosphere_thickness', 'NaN', 1, 'Inf', 1, 'size', [md.mesh.numberofvertices], '>', 0)
     52        md = checkfield(md, 'fieldname', 'gia.cross_section_shape', 'numel', [1], 'values', [1, 2])
     53
     54        #be sure that if we are running a masstransport ice flow model coupled with giaivins, that thickness forcings
     55        #are not provided into the future.
     56
     57        return md
     58    # }}}
     59
     60    def marshall(self, prefix, md, fid):  # {{{
     61
     62        WriteData(fid, prefix, 'object', self, 'fieldname', 'mantle_viscosity', 'format', 'DoubleMat', 'mattype', 1)
     63        WriteData(fid, prefix, 'object', self, 'fieldname', 'lithosphere_thickness', 'format', 'DoubleMat', 'mattype', 1, 'scale', 10.**3.)
     64        WriteData(fid, prefix, 'object', self, 'fieldname', 'cross_section_shape', 'format', 'Integer')
     65    # }}}
Note: See TracChangeset for help on using the changeset viewer.