Changeset 23833


Ignore:
Timestamp:
04/08/19 16:35:05 (6 years ago)
Author:
kruegern
Message:

BUG: fixed various tab vs 4-space bugs and misaligned tabs

Location:
issm/trunk-jpl
Files:
6 edited

Legend:

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

    r23814 r23833  
    55
    66class SMBcomponents(object):
    7         """
    8         SMBcomponents Class definition
     7    """
     8    SMBcomponents Class definition
    99
    10            Usage:
    11               SMBcomponents=SMBcomponents();
    12         """
     10       Usage:
     11          SMBcomponents=SMBcomponents();
     12    """
    1313
    14         def __init__(self): # {{{
    15                 self.accumulation = float('NaN')
    16                 self.runoff = float('NaN')
    17                 self.evaporation = float('NaN')
    18                 self.isclimatology = 0
    19                 self.requested_outputs      = []
    20                 #}}}
    21         def __repr__(self): # {{{
    22                 string="   surface forcings parameters (SMB=accumulation-runoff-evaporation) :"
    23                 string="%s\n%s"%(string,fielddisplay(self,'accumulation','accumulated snow [m/yr ice eq]'))
    24                 string="%s\n%s"%(string,fielddisplay(self,'runoff','amount of ice melt lost from the ice column [m/yr ice eq]'))
    25                 string="%s\n%s"%(string,fielddisplay(self,'evaporation','mount of ice lost to evaporative processes [m/yr ice eq]'))
    26                 string="%s\n%s"%(string,fielddisplay(self,'isclimatology','repeat all forcings when past last forcing time (default false)'))
    27                 string="%s\n%s"%(string,fielddisplay(self,'requested_outputs','additional outputs requested'))
    28                 return string
    29                 #}}}
    30         def extrude(self,md): # {{{
     14    def __init__(self): # {{{
     15        self.accumulation = float('NaN')
     16        self.runoff = float('NaN')
     17        self.evaporation = float('NaN')
     18        self.isclimatology = 0
     19        self.requested_outputs      = []
     20        #}}}
     21    def __repr__(self): # {{{
     22        string="   surface forcings parameters (SMB=accumulation-runoff-evaporation) :"
     23        string="%s\n%s"%(string,fielddisplay(self,'accumulation','accumulated snow [m/yr ice eq]'))
     24        string="%s\n%s"%(string,fielddisplay(self,'runoff','amount of ice melt lost from the ice column [m/yr ice eq]'))
     25        string="%s\n%s"%(string,fielddisplay(self,'evaporation','mount of ice lost to evaporative processes [m/yr ice eq]'))
     26        string="%s\n%s"%(string,fielddisplay(self,'isclimatology','repeat all forcings when past last forcing time (default false)'))
     27        string="%s\n%s"%(string,fielddisplay(self,'requested_outputs','additional outputs requested'))
     28        return string
     29        #}}}
     30    def extrude(self,md): # {{{
    3131
    32                 self.mass_balance=project3d(md,'vector',self.accumulation,'type','node');
    33                 self.mass_balance=project3d(md,'vector',self.runoff,'type','node');
    34                 self.mass_balance=project3d(md,'vector',self.evaporation,'type','node');
    35                 return self
    36         #}}}
    37         def defaultoutputs(self,md): # {{{
    38                 return []
    39         #}}}
    40         def initialize(self,md): # {{{
     32        self.mass_balance=project3d(md,'vector',self.accumulation,'type','node');
     33        self.mass_balance=project3d(md,'vector',self.runoff,'type','node');
     34        self.mass_balance=project3d(md,'vector',self.evaporation,'type','node');
     35        return self
     36    #}}}
     37    def defaultoutputs(self,md): # {{{
     38        return []
     39    #}}}
     40    def initialize(self,md): # {{{
    4141
    42                 if np.all(np.isnan(self.accumulation)):
    43                         self.accumulation=np.zeros((md.mesh.numberofvertices))
    44                         print("      no SMB.accumulation specified: values set as zero")
     42        if np.all(np.isnan(self.accumulation)):
     43            self.accumulation=np.zeros((md.mesh.numberofvertices))
     44            print("      no SMB.accumulation specified: values set as zero")
    4545
    46                 if np.all(np.isnan(self.runoff)):
    47                         self.runoff=np.zeros((md.mesh.numberofvertices))
    48                         print("      no SMB.runoff specified: values set as zero")
     46        if np.all(np.isnan(self.runoff)):
     47            self.runoff=np.zeros((md.mesh.numberofvertices))
     48            print("      no SMB.runoff specified: values set as zero")
    4949
    50                 if np.all(np.isnan(self.evaporation)):
    51                         self.evaporation=np.zeros((md.mesh.numberofvertices))
    52                         print("      no SMB.evaporation specified: values set as zero")
     50        if np.all(np.isnan(self.evaporation)):
     51            self.evaporation=np.zeros((md.mesh.numberofvertices))
     52            print("      no SMB.evaporation specified: values set as zero")
    5353
    54                 return self
    55         #}}}
    56         def checkconsistency(self,md,solution,analyses):    # {{{
     54        return self
     55    #}}}
     56    def checkconsistency(self,md,solution,analyses):    # {{{
    5757
    58                 if 'MasstransportAnalysis' in analyses:
    59                         md = checkfield(md,'fieldname','smb.accumulation','timeseries',1,'NaN',1,'Inf',1)
     58        if 'MasstransportAnalysis' in analyses:
     59            md = checkfield(md,'fieldname','smb.accumulation','timeseries',1,'NaN',1,'Inf',1)
    6060
    61                 if 'BalancethicknessAnalysis' in analyses:
    62                         md = checkfield(md,'fieldname','smb.accumulation','size',[md.mesh.numberofvertices],'NaN',1,'Inf',1)
     61        if 'BalancethicknessAnalysis' in analyses:
     62            md = checkfield(md,'fieldname','smb.accumulation','size',[md.mesh.numberofvertices],'NaN',1,'Inf',1)
    6363
    64                 if 'MasstransportAnalysis' in analyses:
    65                         md = checkfield(md,'fieldname','smb.runoff','timeseries',1,'NaN',1,'Inf',1)
     64        if 'MasstransportAnalysis' in analyses:
     65            md = checkfield(md,'fieldname','smb.runoff','timeseries',1,'NaN',1,'Inf',1)
    6666
    67                 if 'BalancethicknessAnalysis' in analyses:
    68                         md = checkfield(md,'fieldname','smb.runoff','size',[md.mesh.numberofvertices],'NaN',1,'Inf',1)
     67        if 'BalancethicknessAnalysis' in analyses:
     68            md = checkfield(md,'fieldname','smb.runoff','size',[md.mesh.numberofvertices],'NaN',1,'Inf',1)
    6969
    70                 if 'MasstransportAnalysis' in analyses:
    71                         md = checkfield(md,'fieldname','smb.evaporation','timeseries',1,'NaN',1,'Inf',1)
     70        if 'MasstransportAnalysis' in analyses:
     71            md = checkfield(md,'fieldname','smb.evaporation','timeseries',1,'NaN',1,'Inf',1)
    7272
    73                 if 'BalancethicknessAnalysis' in analyses:
    74                         md = checkfield(md,'fieldname','smb.evaporation','size',[md.mesh.numberofvertices],'NaN',1,'Inf',1)
    75                
    76                 md = checkfield(md,'fieldname','masstransport.requested_outputs','stringrow',1)
    77                 md = checkfield(md,'fieldname','smb.isclimatology','values',[0,1])
     73        if 'BalancethicknessAnalysis' in analyses:
     74            md = checkfield(md,'fieldname','smb.evaporation','size',[md.mesh.numberofvertices],'NaN',1,'Inf',1)
     75       
     76        md = checkfield(md,'fieldname','masstransport.requested_outputs','stringrow',1)
     77        md = checkfield(md,'fieldname','smb.isclimatology','values',[0,1])
    7878
    79                 return md
    80         # }}}
    81         def marshall(self,prefix,md,fid):    # {{{
     79        return md
     80    # }}}
     81    def marshall(self,prefix,md,fid):    # {{{
    8282
    83                 yts=md.constants.yts
     83        yts=md.constants.yts
    8484
    85                 WriteData(fid,prefix,'name','md.smb.model','data',2,'format','Integer');
    86                 WriteData(fid,prefix,'object',self,'class','smb','fieldname','accumulation','format','DoubleMat','mattype',1,'scale',1./yts,'timeserieslength',md.mesh.numberofvertices+1,'yts',md.constants.yts)
    87                 WriteData(fid,prefix,'object',self,'class','smb','fieldname','runoff','format','DoubleMat','mattype',1,'scale',1./yts,'timeserieslength',md.mesh.numberofvertices+1,'yts',md.constants.yts)
    88                 WriteData(fid,prefix,'object',self,'class','smb','fieldname','evaporation','format','DoubleMat','mattype',1,'scale',1./yts,'timeserieslength',md.mesh.numberofvertices+1,'yts',md.constants.yts)
    89                
    90                 #process requested outputs
    91                 outputs = self.requested_outputs
    92                 indices = [i for i, x in enumerate(outputs) if x == 'default']
    93                 if len(indices) > 0:
    94                         outputscopy=outputs[0:max(0,indices[0]-1)]+self.defaultoutputs(md)+outputs[indices[0]+1:]
    95                         outputs    =outputscopy
    96                 WriteData(fid,prefix,'data',outputs,'name','md.smb.requested_outputs','format','StringArray')
    97                 WriteData(fid,prefix,'object',self,'class','smb','fieldname','isclimatology','format','Boolean')
    98                 if (self.isclimatology>0):
    99                         md = checkfield(md,'fieldname', 'smb.accumulation', 'size',[md.mesh.numberofvertices+1],'message','accumulation must have md.mesh.numberofvertices+1 rows in order to force a climatology')
    100                         md = checkfield(md,'fieldname', 'smb.runoff', 'size',[md.mesh.numberofvertices+1],'message','runoff must have md.mesh.numberofvertices+1 rows in order to force a climatology')
    101                         md = checkfield(md,'fieldname', 'smb.evaporation', 'size',[md.mesh.numberofvertices+1],'message','evaporation must have md.mesh.numberofvertices+1 rows in order to force a climatology')
     85        WriteData(fid,prefix,'name','md.smb.model','data',2,'format','Integer');
     86        WriteData(fid,prefix,'object',self,'class','smb','fieldname','accumulation','format','DoubleMat','mattype',1,'scale',1./yts,'timeserieslength',md.mesh.numberofvertices+1,'yts',md.constants.yts)
     87        WriteData(fid,prefix,'object',self,'class','smb','fieldname','runoff','format','DoubleMat','mattype',1,'scale',1./yts,'timeserieslength',md.mesh.numberofvertices+1,'yts',md.constants.yts)
     88        WriteData(fid,prefix,'object',self,'class','smb','fieldname','evaporation','format','DoubleMat','mattype',1,'scale',1./yts,'timeserieslength',md.mesh.numberofvertices+1,'yts',md.constants.yts)
     89       
     90        #process requested outputs
     91        outputs = self.requested_outputs
     92        indices = [i for i, x in enumerate(outputs) if x == 'default']
     93        if len(indices) > 0:
     94            outputscopy=outputs[0:max(0,indices[0]-1)]+self.defaultoutputs(md)+outputs[indices[0]+1:]
     95            outputs    =outputscopy
     96        WriteData(fid,prefix,'data',outputs,'name','md.smb.requested_outputs','format','StringArray')
     97        WriteData(fid,prefix,'object',self,'class','smb','fieldname','isclimatology','format','Boolean')
     98        if (self.isclimatology>0):
     99            md = checkfield(md,'fieldname', 'smb.accumulation', 'size',[md.mesh.numberofvertices+1],'message','accumulation must have md.mesh.numberofvertices+1 rows in order to force a climatology')
     100            md = checkfield(md,'fieldname', 'smb.runoff', 'size',[md.mesh.numberofvertices+1],'message','runoff must have md.mesh.numberofvertices+1 rows in order to force a climatology')
     101            md = checkfield(md,'fieldname', 'smb.evaporation', 'size',[md.mesh.numberofvertices+1],'message','evaporation must have md.mesh.numberofvertices+1 rows in order to force a climatology')
    102102
    103         # }}}
     103    # }}}
  • issm/trunk-jpl/src/m/classes/SMBforcing.py

    r23814 r23833  
    66
    77class SMBforcing(object):
    8         """
    9         SMBforcing Class definition
     8    """
     9    SMBforcing Class definition
    1010
    11            Usage:
    12               SMB=SMBforcing();
    13         """
     11       Usage:
     12          SMB=SMBforcing();
     13    """
    1414
    15         def __init__(self): # {{{
    16                 self.mass_balance = float('NaN')
    17                 self.requested_outputs      = []
    18                 self.isclimatology = 0
    19                 #}}}
    20         def __repr__(self): # {{{
    21                 string="   surface forcings parameters:"
    22                 string="%s\n%s"%(string,fielddisplay(self,'mass_balance','surface mass balance [m/yr ice eq]'))
    23                 string="%s\n%s"%(string,fielddisplay(self,'isclimatology','repeat all forcings when past last forcing time (default false)'))
    24                 string="%s\n%s"%(string,fielddisplay(self,'requested_outputs','additional outputs requested'))
    25                 return string
    26                 #}}}
    27         def extrude(self,md): # {{{
     15    def __init__(self): # {{{
     16        self.mass_balance = float('NaN')
     17        self.requested_outputs      = []
     18        self.isclimatology = 0
     19        #}}}
     20    def __repr__(self): # {{{
     21        string="   surface forcings parameters:"
     22        string="%s\n%s"%(string,fielddisplay(self,'mass_balance','surface mass balance [m/yr ice eq]'))
     23        string="%s\n%s"%(string,fielddisplay(self,'isclimatology','repeat all forcings when past last forcing time (default false)'))
     24        string="%s\n%s"%(string,fielddisplay(self,'requested_outputs','additional outputs requested'))
     25        return string
     26        #}}}
     27    def extrude(self,md): # {{{
    2828
    29                 self.mass_balance=project3d(md,'vector',self.mass_balance,'type','node');
    30                 return self
    31         #}}}
    32         def defaultoutputs(self,md): # {{{
    33                 return []
    34         #}}}
    35         def initialize(self,md): # {{{
     29        self.mass_balance=project3d(md,'vector',self.mass_balance,'type','node');
     30        return self
     31    #}}}
     32    def defaultoutputs(self,md): # {{{
     33        return []
     34    #}}}
     35    def initialize(self,md): # {{{
    3636
    37                 if np.all(np.isnan(self.mass_balance)):
    38                         self.mass_balance=np.zeros((md.mesh.numberofvertices))
    39                         print("      no SMBforcing.mass_balance specified: values set as zero")
     37        if np.all(np.isnan(self.mass_balance)):
     38            self.mass_balance=np.zeros((md.mesh.numberofvertices))
     39            print("      no SMBforcing.mass_balance specified: values set as zero")
    4040
    41                 return self
    42         #}}}
    43         def checkconsistency(self,md,solution,analyses):    # {{{
     41        return self
     42    #}}}
     43    def checkconsistency(self,md,solution,analyses):    # {{{
    4444
    45                 if 'MasstransportAnalysis' in analyses:
    46                         md = checkfield(md,'fieldname','smb.mass_balance','timeseries',1,'NaN',1,'Inf',1)
     45        if 'MasstransportAnalysis' in analyses:
     46            md = checkfield(md,'fieldname','smb.mass_balance','timeseries',1,'NaN',1,'Inf',1)
    4747
    48                 if 'BalancethicknessAnalysis' in analyses:
    49                         md = checkfield(md,'fieldname','smb.mass_balance','size',[md.mesh.numberofvertices],'NaN',1,'Inf',1)
     48        if 'BalancethicknessAnalysis' in analyses:
     49            md = checkfield(md,'fieldname','smb.mass_balance','size',[md.mesh.numberofvertices],'NaN',1,'Inf',1)
    5050
    51                 md = checkfield(md,'fieldname','masstransport.requested_outputs','stringrow',1)
    52                 md = checkfield(md,'fieldname','smb.isclimatology','values',[0,1])
    53                 if (self.isclimatology>0):
    54                     md = checkfield(md,'fieldname', 'smb.mass_balance', 'size',[md.mesh.numberofvertices+1],'message','mass_balance must have md.mesh.numberofvertices+1 rows in order to force a climatology')
     51        md = checkfield(md,'fieldname','masstransport.requested_outputs','stringrow',1)
     52        md = checkfield(md,'fieldname','smb.isclimatology','values',[0,1])
     53        if (self.isclimatology>0):
     54            md = checkfield(md,'fieldname', 'smb.mass_balance', 'size',[md.mesh.numberofvertices+1],'message','mass_balance must have md.mesh.numberofvertices+1 rows in order to force a climatology')
    5555
    56                 return md
    57         # }}}
    58         def marshall(self,prefix,md,fid):    # {{{
     56        return md
     57    # }}}
     58    def marshall(self,prefix,md,fid):    # {{{
    5959
    60                 yts=md.constants.yts
     60        yts=md.constants.yts
    6161
    62                 WriteData(fid,prefix,'name','md.smb.model','data',1,'format','Integer');
    63                 WriteData(fid,prefix,'object',self,'class','smb','fieldname','mass_balance','format','DoubleMat','mattype',1,'scale',1./yts,'timeserieslength',md.mesh.numberofvertices+1,'yts',md.constants.yts)
    64                 #WriteData(fid,prefix,'object',self,'class','smb','fieldname','mass_balance','format','CompressedMat','mattype',1,'scale',1./yts,'timeserieslength',md.mesh.numberofvertices+1,'yts',md.constants.yts);
    65                
    66                 #process requested outputs
    67                 outputs = self.requested_outputs
    68                 indices = [i for i, x in enumerate(outputs) if x == 'default']
    69                 if len(indices) > 0:
    70                         outputscopy=outputs[0:max(0,indices[0]-1)]+self.defaultoutputs(md)+outputs[indices[0]+1:]
    71                         outputs    =outputscopy
    72                 WriteData(fid,prefix,'data',outputs,'name','md.smb.requested_outputs','format','StringArray')
    73                 WriteData(fid,prefix,'object',self,'class','smb','fieldname','isclimatology','format','Boolean')
     62        WriteData(fid,prefix,'name','md.smb.model','data',1,'format','Integer');
     63        WriteData(fid,prefix,'object',self,'class','smb','fieldname','mass_balance','format','DoubleMat','mattype',1,'scale',1./yts,'timeserieslength',md.mesh.numberofvertices+1,'yts',md.constants.yts)
     64        #WriteData(fid,prefix,'object',self,'class','smb','fieldname','mass_balance','format','CompressedMat','mattype',1,'scale',1./yts,'timeserieslength',md.mesh.numberofvertices+1,'yts',md.constants.yts);
     65       
     66        #process requested outputs
     67        outputs = self.requested_outputs
     68        indices = [i for i, x in enumerate(outputs) if x == 'default']
     69        if len(indices) > 0:
     70            outputscopy=outputs[0:max(0,indices[0]-1)]+self.defaultoutputs(md)+outputs[indices[0]+1:]
     71            outputs    =outputscopy
     72        WriteData(fid,prefix,'data',outputs,'name','md.smb.requested_outputs','format','StringArray')
     73        WriteData(fid,prefix,'object',self,'class','smb','fieldname','isclimatology','format','Boolean')
    7474
    75         # }}}
     75    # }}}
  • issm/trunk-jpl/src/m/classes/SMBmeltcomponents.py

    r23814 r23833  
    55
    66class SMBmeltcomponents(object):
    7         """
    8         SMBmeltcomponents Class definition
     7    """
     8    SMBmeltcomponents Class definition
    99
    10            Usage:
    11               SMBmeltcomponents=SMBmeltcomponents();
    12         """
     10       Usage:
     11          SMBmeltcomponents=SMBmeltcomponents();
     12    """
    1313
    14         def __init__(self): # {{{
    15                 self.accumulation = float('NaN')
    16                 self.runoff = float('NaN')
    17                 self.evaporation = float('NaN')
    18                 self.isclimatology = 0
    19                 self.requested_outputs      = []
    20                 #}}}
    21         def __repr__(self): # {{{
    22                 string="   surface forcings parameters with melt (SMB=accumulation-evaporation-melt+refreeze) :"
    23                 string="%s\n%s"%(string,fielddisplay(self,'accumulation','accumulated snow [m/yr ice eq]'))
    24                 string="%s\n%s"%(string,fielddisplay(self,'evaporation','mount of ice lost to evaporative processes [m/yr ice eq]'))
    25                 string="%s\n%s"%(string,fielddisplay(self,'melt','amount of ice melt in the ice column [m/yr ice eq]'))
    26                 string="%s\n%s"%(string,fielddisplay(self,'refreeze','amount of ice melt refrozen in the ice column [m/yr ice eq]'))
    27                 string="%s\n%s"%(string,fielddisplay(self,'isclimatology','repeat all forcings when past last forcing time (default false)'))
    28                 string="%s\n%s"%(string,fielddisplay(self,'requested_outputs','additional outputs requested'))
    29                 return string
    30                 #}}}
    31         def extrude(self,md): # {{{
     14    def __init__(self): # {{{
     15        self.accumulation = float('NaN')
     16        self.runoff = float('NaN')
     17        self.evaporation = float('NaN')
     18        self.isclimatology = 0
     19        self.requested_outputs      = []
     20        #}}}
     21    def __repr__(self): # {{{
     22        string="   surface forcings parameters with melt (SMB=accumulation-evaporation-melt+refreeze) :"
     23        string="%s\n%s"%(string,fielddisplay(self,'accumulation','accumulated snow [m/yr ice eq]'))
     24        string="%s\n%s"%(string,fielddisplay(self,'evaporation','mount of ice lost to evaporative processes [m/yr ice eq]'))
     25        string="%s\n%s"%(string,fielddisplay(self,'melt','amount of ice melt in the ice column [m/yr ice eq]'))
     26        string="%s\n%s"%(string,fielddisplay(self,'refreeze','amount of ice melt refrozen in the ice column [m/yr ice eq]'))
     27        string="%s\n%s"%(string,fielddisplay(self,'isclimatology','repeat all forcings when past last forcing time (default false)'))
     28        string="%s\n%s"%(string,fielddisplay(self,'requested_outputs','additional outputs requested'))
     29        return string
     30        #}}}
     31    def extrude(self,md): # {{{
    3232
    33                 self.accumulation=project3d(md,'vector',self.accumulation,'type','node');
    34                 self.evaporation=project3d(md,'vector',self.evaporation,'type','node');
    35                 self.melt=project3d(md,'vector',self.melt,'type','node');
    36                 self.refreeze=project3d(md,'vector',self.refreeze,'type','node');
    37                 return self
    38         #}}}
    39         def defaultoutputs(self,md): # {{{
    40                 return []
    41         #}}}
    42         def initialize(self,md): # {{{
     33        self.accumulation=project3d(md,'vector',self.accumulation,'type','node');
     34        self.evaporation=project3d(md,'vector',self.evaporation,'type','node');
     35        self.melt=project3d(md,'vector',self.melt,'type','node');
     36        self.refreeze=project3d(md,'vector',self.refreeze,'type','node');
     37        return self
     38    #}}}
     39    def defaultoutputs(self,md): # {{{
     40        return []
     41    #}}}
     42    def initialize(self,md): # {{{
    4343
    44                 if np.all(np.isnan(self.accumulation)):
    45                         self.accumulation=np.zeros((md.mesh.numberofvertices))
    46                         print("      no SMB.accumulation specified: values set as zero")
     44        if np.all(np.isnan(self.accumulation)):
     45            self.accumulation=np.zeros((md.mesh.numberofvertices))
     46            print("      no SMB.accumulation specified: values set as zero")
    4747
    48                 if np.all(np.isnan(self.evaporation)):
    49                         self.evaporation=np.zeros((md.mesh.numberofvertices))
    50                         print("      no SMB.evaporation specified: values set as zero")
     48        if np.all(np.isnan(self.evaporation)):
     49            self.evaporation=np.zeros((md.mesh.numberofvertices))
     50            print("      no SMB.evaporation specified: values set as zero")
    5151
    52                 if np.all(np.isnan(self.melt)):
    53                         self.melt=np.zeros((md.mesh.numberofvertices))
    54                         print("      no SMB.melt specified: values set as zero")
     52        if np.all(np.isnan(self.melt)):
     53            self.melt=np.zeros((md.mesh.numberofvertices))
     54            print("      no SMB.melt specified: values set as zero")
    5555
    56                 if np.all(np.isnan(self.refreeze)):
    57                         self.refreeze=np.zeros((md.mesh.numberofvertices))
    58                         print("      no SMB.refreeze specified: values set as zero")
     56        if np.all(np.isnan(self.refreeze)):
     57            self.refreeze=np.zeros((md.mesh.numberofvertices))
     58            print("      no SMB.refreeze specified: values set as zero")
    5959
    60                 return self
    61         #}}}
    62         def checkconsistency(self,md,solution,analyses):    # {{{
     60        return self
     61    #}}}
     62    def checkconsistency(self,md,solution,analyses):    # {{{
    6363
    64                 if 'MasstransportAnalysis' in analyses:
    65                         md = checkfield(md,'fieldname','smb.accumulation','timeseries',1,'NaN',1,'Inf',1)
     64        if 'MasstransportAnalysis' in analyses:
     65            md = checkfield(md,'fieldname','smb.accumulation','timeseries',1,'NaN',1,'Inf',1)
    6666
    67                 if 'BalancethicknessAnalysis' in analyses:
    68                         md = checkfield(md,'fieldname','smb.accumulation','size',[md.mesh.numberofvertices],'NaN',1,'Inf',1)
     67        if 'BalancethicknessAnalysis' in analyses:
     68            md = checkfield(md,'fieldname','smb.accumulation','size',[md.mesh.numberofvertices],'NaN',1,'Inf',1)
    6969
    70                 if 'MasstransportAnalysis' in analyses:
    71                         md = checkfield(md,'fieldname','smb.melt','timeseries',1,'NaN',1,'Inf',1)
     70        if 'MasstransportAnalysis' in analyses:
     71            md = checkfield(md,'fieldname','smb.melt','timeseries',1,'NaN',1,'Inf',1)
    7272
    73                 if 'BalancethicknessAnalysis' in analyses:
    74                         md = checkfield(md,'fieldname','smb.melt','size',[md.mesh.numberofvertices],'NaN',1,'Inf',1)
     73        if 'BalancethicknessAnalysis' in analyses:
     74            md = checkfield(md,'fieldname','smb.melt','size',[md.mesh.numberofvertices],'NaN',1,'Inf',1)
    7575
    76                 if 'MasstransportAnalysis' in analyses:
    77                         md = checkfield(md,'fieldname','smb.refreeze','timeseries',1,'NaN',1,'Inf',1)
     76        if 'MasstransportAnalysis' in analyses:
     77            md = checkfield(md,'fieldname','smb.refreeze','timeseries',1,'NaN',1,'Inf',1)
    7878
    79                 if 'BalancethicknessAnalysis' in analyses:
    80                         md = checkfield(md,'fieldname','smb.refreeze','size',[md.mesh.numberofvertices],'NaN',1,'Inf',1)
     79        if 'BalancethicknessAnalysis' in analyses:
     80            md = checkfield(md,'fieldname','smb.refreeze','size',[md.mesh.numberofvertices],'NaN',1,'Inf',1)
    8181
    82                 if 'MasstransportAnalysis' in analyses:
    83                         md = checkfield(md,'fieldname','smb.evaporation','timeseries',1,'NaN',1,'Inf',1)
     82        if 'MasstransportAnalysis' in analyses:
     83            md = checkfield(md,'fieldname','smb.evaporation','timeseries',1,'NaN',1,'Inf',1)
    8484
    85                 if 'BalancethicknessAnalysis' in analyses:
    86                         md = checkfield(md,'fieldname','smb.evaporation','size',[md.mesh.numberofvertices],'NaN',1,'Inf',1)
     85        if 'BalancethicknessAnalysis' in analyses:
     86            md = checkfield(md,'fieldname','smb.evaporation','size',[md.mesh.numberofvertices],'NaN',1,'Inf',1)
    8787
    88                 md = checkfield(md,'fieldname','masstransport.requested_outputs','stringrow',1)
    89                 md = checkfield(md,'fieldname','smb.isclimatology','values',[0,1])
    90                 return md
    91         # }}}
    92         def marshall(self,prefix,md,fid):    # {{{
     88        md = checkfield(md,'fieldname','masstransport.requested_outputs','stringrow',1)
     89        md = checkfield(md,'fieldname','smb.isclimatology','values',[0,1])
     90        return md
     91    # }}}
     92    def marshall(self,prefix,md,fid):    # {{{
    9393
    94                 yts=md.constants.yts
     94        yts=md.constants.yts
    9595
    96                 WriteData(fid,prefix,'name','md.smb.model','data',3,'format','Integer');
    97                 WriteData(fid,prefix,'object',self,'class','smb','fieldname','accumulation','format','DoubleMat','mattype',1,'scale',1./yts,'timeserieslength',md.mesh.numberofvertices+1,'yts',md.constants.yts)
    98                 WriteData(fid,prefix,'object',self,'class','smb','fieldname','evaporation','format','DoubleMat','mattype',1,'scale',1./yts,'timeserieslength',md.mesh.numberofvertices+1,'yts',md.constants.yts)
    99                 WriteData(fid,prefix,'object',self,'class','smb','fieldname','melt','format','DoubleMat','mattype',1,'scale',1./yts,'timeserieslength',md.mesh.numberofvertices+1,'yts',md.constants.yts)
    100                 WriteData(fid,prefix,'object',self,'class','smb','fieldname','refreeze','format','DoubleMat','mattype',1,'scale',1./yts,'timeserieslength',md.mesh.numberofvertices+1,'yts',md.constants.yts)
     96        WriteData(fid,prefix,'name','md.smb.model','data',3,'format','Integer');
     97        WriteData(fid,prefix,'object',self,'class','smb','fieldname','accumulation','format','DoubleMat','mattype',1,'scale',1./yts,'timeserieslength',md.mesh.numberofvertices+1,'yts',md.constants.yts)
     98        WriteData(fid,prefix,'object',self,'class','smb','fieldname','evaporation','format','DoubleMat','mattype',1,'scale',1./yts,'timeserieslength',md.mesh.numberofvertices+1,'yts',md.constants.yts)
     99        WriteData(fid,prefix,'object',self,'class','smb','fieldname','melt','format','DoubleMat','mattype',1,'scale',1./yts,'timeserieslength',md.mesh.numberofvertices+1,'yts',md.constants.yts)
     100        WriteData(fid,prefix,'object',self,'class','smb','fieldname','refreeze','format','DoubleMat','mattype',1,'scale',1./yts,'timeserieslength',md.mesh.numberofvertices+1,'yts',md.constants.yts)
    101101
    102                 #process requested outputs
    103                 outputs = self.requested_outputs
    104                 indices = [i for i, x in enumerate(outputs) if x == 'default']
    105                 if len(indices) > 0:
    106                         outputscopy=outputs[0:max(0,indices[0]-1)]+self.defaultoutputs(md)+outputs[indices[0]+1:]
    107                         outputs    =outputscopy
    108                 WriteData(fid,prefix,'data',outputs,'name','md.smb.requested_outputs','format','StringArray')
    109                 WriteData(fid,prefix,'object',self,'class','smb','fieldname','isclimatology','format','Boolean')
    110                 if (self.isclimatology>0):
    111                         md = checkfield(md,'fieldname', 'smb.accumulation', 'size',[md.mesh.numberofvertices+1],'message','accumulation must have md.mesh.numberofvertices+1 rows in order to force a climatology')
    112                         md = checkfield(md,'fieldname', 'smb.melt', 'size',[md.mesh.numberofvertices+1],'message','melt must have md.mesh.numberofvertices+1 rows in order to force a climatology')
    113                         md = checkfield(md,'fieldname', 'smb.refreeze', 'size',[md.mesh.numberofvertices+1],'message','refreeze must have md.mesh.numberofvertices+1 rows in order to force a climatology')
    114                         md = checkfield(md,'fieldname', 'smb.evaporation', 'size',[md.mesh.numberofvertices+1],'message','evaporation must have md.mesh.numberofvertices+1 rows in order to force a climatology')
     102        #process requested outputs
     103        outputs = self.requested_outputs
     104        indices = [i for i, x in enumerate(outputs) if x == 'default']
     105        if len(indices) > 0:
     106            outputscopy=outputs[0:max(0,indices[0]-1)]+self.defaultoutputs(md)+outputs[indices[0]+1:]
     107            outputs    =outputscopy
     108        WriteData(fid,prefix,'data',outputs,'name','md.smb.requested_outputs','format','StringArray')
     109        WriteData(fid,prefix,'object',self,'class','smb','fieldname','isclimatology','format','Boolean')
     110        if (self.isclimatology>0):
     111            md = checkfield(md,'fieldname', 'smb.accumulation', 'size',[md.mesh.numberofvertices+1],'message','accumulation must have md.mesh.numberofvertices+1 rows in order to force a climatology')
     112            md = checkfield(md,'fieldname', 'smb.melt', 'size',[md.mesh.numberofvertices+1],'message','melt must have md.mesh.numberofvertices+1 rows in order to force a climatology')
     113            md = checkfield(md,'fieldname', 'smb.refreeze', 'size',[md.mesh.numberofvertices+1],'message','refreeze must have md.mesh.numberofvertices+1 rows in order to force a climatology')
     114            md = checkfield(md,'fieldname', 'smb.evaporation', 'size',[md.mesh.numberofvertices+1],'message','evaporation must have md.mesh.numberofvertices+1 rows in order to force a climatology')
    115115
    116         # }}}
     116    # }}}
  • issm/trunk-jpl/src/m/classes/geometry.py

    r23831 r23833  
    6060                                    md.checkmessage('base<bed on one or more vertex')
    6161                                pos = np.where(md.mask.groundedice_levelset > 0)
    62                                 if np.any(np.abs(self.bed[pos]-self.base[pos]>10**-9):
     62                                if np.any(np.abs(self.bed[pos]-self.base[pos])>10**-9):
    6363                                    md.checkmessage('equality base=bed on grounded ice violated')
    6464                                md = checkfield(md,'fieldname','geometry.bed','NaN',1,'Inf',1,'size',[md.mesh.numberofvertices])
  • issm/trunk-jpl/src/m/classes/initialization.py

    r23812 r23833  
    77
    88class initialization(object):
    9         """
    10         INITIALIZATION class definition
    11        
    12         Usage:
    13         initialization=initialization();
    14         """
     9    """
     10    INITIALIZATION class definition
     11   
     12    Usage:
     13    initialization=initialization();
     14    """
    1515
    16         def __init__(self): # {{{
    17                                        
    18                 self.vx            = float('NaN')
    19                 self.vy            = float('NaN')
    20                 self.vz            = float('NaN')
    21                 self.vel           = float('NaN')
    22                 self.enthalpy      = float('NaN')
    23                 self.pressure      = float('NaN')
    24                 self.temperature   = float('NaN')
    25                 self.waterfraction = float('NaN')
    26                 self.watercolumn   = float('NaN')
    27                 self.sediment_head = float('NaN')
    28                 self.epl_head      = float('NaN')
    29                 self.epl_thickness = float('NaN')
     16    def __init__(self): # {{{
     17                   
     18        self.vx            = float('NaN')
     19        self.vy            = float('NaN')
     20        self.vz            = float('NaN')
     21        self.vel           = float('NaN')
     22        self.enthalpy      = float('NaN')
     23        self.pressure      = float('NaN')
     24        self.temperature   = float('NaN')
     25        self.waterfraction = float('NaN')
     26        self.watercolumn   = float('NaN')
     27        self.sediment_head = float('NaN')
     28        self.epl_head      = float('NaN')
     29        self.epl_thickness = float('NaN')
    3030
    31                 #set defaults
    32                 self.setdefaultparameters()
     31        #set defaults
     32        self.setdefaultparameters()
    3333
    34                 #}}}
    35         def __repr__(self): # {{{
    36                 string='   initial field values:'
    37                 string="%s\n%s"%(string,fielddisplay(self,'vx','x component of velocity [m/yr]'))
    38                 string="%s\n%s"%(string,fielddisplay(self,'vy','y component of velocity [m/yr]'))
    39                 string="%s\n%s"%(string,fielddisplay(self,'vz','z component of velocity [m/yr]'))
    40                 string="%s\n%s"%(string,fielddisplay(self,'vel','velocity norm [m/yr]'))
    41                 string="%s\n%s"%(string,fielddisplay(self,'pressure','pressure [Pa]'))
    42                 string="%s\n%s"%(string,fielddisplay(self,'temperature','temperature [K]'))
    43                 string="%s\n%s"%(string,fielddisplay(self,'enthalpy','enthalpy [J]'))
    44                 string="%s\n%s"%(string,fielddisplay(self,'waterfraction','fraction of water in the ice'))
    45                 string="%s\n%s"%(string,fielddisplay(self,'watercolumn','thickness of subglacial water [m]'))
    46                 string="%s\n%s"%(string,fielddisplay(self,'sediment_head','sediment water head of subglacial system [m]'))
    47                 string="%s\n%s"%(string,fielddisplay(self,'epl_head','epl water head of subglacial system [m]'))
    48                 string="%s\n%s"%(string,fielddisplay(self,'epl_thickness','thickness of the epl [m]'))
     34        #}}}
     35    def __repr__(self): # {{{
     36        string='   initial field values:'
     37        string="%s\n%s"%(string,fielddisplay(self,'vx','x component of velocity [m/yr]'))
     38        string="%s\n%s"%(string,fielddisplay(self,'vy','y component of velocity [m/yr]'))
     39        string="%s\n%s"%(string,fielddisplay(self,'vz','z component of velocity [m/yr]'))
     40        string="%s\n%s"%(string,fielddisplay(self,'vel','velocity norm [m/yr]'))
     41        string="%s\n%s"%(string,fielddisplay(self,'pressure','pressure [Pa]'))
     42        string="%s\n%s"%(string,fielddisplay(self,'temperature','temperature [K]'))
     43        string="%s\n%s"%(string,fielddisplay(self,'enthalpy','enthalpy [J]'))
     44        string="%s\n%s"%(string,fielddisplay(self,'waterfraction','fraction of water in the ice'))
     45        string="%s\n%s"%(string,fielddisplay(self,'watercolumn','thickness of subglacial water [m]'))
     46        string="%s\n%s"%(string,fielddisplay(self,'sediment_head','sediment water head of subglacial system [m]'))
     47        string="%s\n%s"%(string,fielddisplay(self,'epl_head','epl water head of subglacial system [m]'))
     48        string="%s\n%s"%(string,fielddisplay(self,'epl_thickness','thickness of the epl [m]'))
    4949
    50                 return string
    51                 #}}}
    52         def extrude(self,md): # {{{
    53                 self.vx=project3d(md,'vector',self.vx,'type','node')
    54                 self.vy=project3d(md,'vector',self.vy,'type','node')
    55                 self.vz=project3d(md,'vector',self.vz,'type','node')
    56                 self.vel=project3d(md,'vector',self.vel,'type','node')
    57                 self.temperature=project3d(md,'vector',self.temperature,'type','node')
    58                 self.enthalpy=project3d(md,'vector',self.enthalpy,'type','node')
    59                 self.waterfraction=project3d(md,'vector',self.waterfraction,'type','node')
    60                 self.watercolumn=project3d(md,'vector',self.watercolumn,'type','node')
    61                 self.sediment_head=project3d(md,'vector',self.sediment_head,'type','node','layer',1)
    62                 self.epl_head=project3d(md,'vector',self.epl_head,'type','node','layer',1)
    63                 self.epl_thickness=project3d(md,'vector',self.epl_thickness,'type','node','layer',1)
     50        return string
     51        #}}}
     52    def extrude(self,md): # {{{
     53        self.vx=project3d(md,'vector',self.vx,'type','node')
     54        self.vy=project3d(md,'vector',self.vy,'type','node')
     55        self.vz=project3d(md,'vector',self.vz,'type','node')
     56        self.vel=project3d(md,'vector',self.vel,'type','node')
     57        self.temperature=project3d(md,'vector',self.temperature,'type','node')
     58        self.enthalpy=project3d(md,'vector',self.enthalpy,'type','node')
     59        self.waterfraction=project3d(md,'vector',self.waterfraction,'type','node')
     60        self.watercolumn=project3d(md,'vector',self.watercolumn,'type','node')
     61        self.sediment_head=project3d(md,'vector',self.sediment_head,'type','node','layer',1)
     62        self.epl_head=project3d(md,'vector',self.epl_head,'type','node','layer',1)
     63        self.epl_thickness=project3d(md,'vector',self.epl_thickness,'type','node','layer',1)
    6464
    65                 #Lithostatic pressure by default
    66                 #               self.pressure=md.constants.g*md.materials.rho_ice*(md.geometry.surface[:,0]-md.mesh.z)
    67                 #self.pressure=md.constants.g*md.materials.rho_ice*(md.geometry.surface-md.mesh.z.reshape(-1,))
     65        #Lithostatic pressure by default
     66        #        self.pressure=md.constants.g*md.materials.rho_ice*(md.geometry.surface[:,0]-md.mesh.z)
     67        #self.pressure=md.constants.g*md.materials.rho_ice*(md.geometry.surface-md.mesh.z.reshape(-1,))
    6868
    69                 if np.ndim(md.geometry.surface)==2:
    70                         print('Reshaping md.geometry.surface for you convenience but you should fix it in you files')
    71                         self.pressure=md.constants.g*md.materials.rho_ice*(md.geometry.surface.reshape(-1,)-md.mesh.z)
    72                 else:
    73                         self.pressure=md.constants.g*md.materials.rho_ice*(md.geometry.surface-md.mesh.z)
     69        if np.ndim(md.geometry.surface)==2:
     70            print('Reshaping md.geometry.surface for you convenience but you should fix it in you files')
     71            self.pressure=md.constants.g*md.materials.rho_ice*(md.geometry.surface.reshape(-1,)-md.mesh.z)
     72        else:
     73            self.pressure=md.constants.g*md.materials.rho_ice*(md.geometry.surface-md.mesh.z)
    7474
    75                 return self
    76         #}}}
    77         def setdefaultparameters(self): # {{{
    78                 return self
    79         #}}}
    80         def checkconsistency(self,md,solution,analyses):    # {{{
    81                 if 'StressbalanceAnalysis' in analyses:
    82                         if not np.any(np.logical_or(np.isnan(md.initialization.vx),np.isnan(md.initialization.vy))):
    83                                 md = checkfield(md,'fieldname','initialization.vx','NaN',1,'Inf',1,'size',[md.mesh.numberofvertices])
    84                                 md = checkfield(md,'fieldname','initialization.vy','NaN',1,'Inf',1,'size',[md.mesh.numberofvertices])
    85                 if 'MasstransportAnalysis' in analyses:
    86                         md = checkfield(md,'fieldname','initialization.vx','NaN',1,'Inf',1,'size',[md.mesh.numberofvertices])
    87                         md = checkfield(md,'fieldname','initialization.vy','NaN',1,'Inf',1,'size',[md.mesh.numberofvertices])
    88                 if 'BalancethicknessAnalysis' in analyses:
    89                         md = checkfield(md,'fieldname','initialization.vx','NaN',1,'Inf',1,'size',[md.mesh.numberofvertices])
    90                         md = checkfield(md,'fieldname','initialization.vy','NaN',1,'Inf',1,'size',[md.mesh.numberofvertices])
    91                         #Triangle with zero velocity
    92                         if np.any(np.logical_and(np.sum(np.abs(md.initialization.vx[md.mesh.elements-1]),axis=1)==0,\
    93                                                        np.sum(np.abs(md.initialization.vy[md.mesh.elements-1]),axis=1)==0)):
    94                                 md.checkmessage("at least one triangle has all its vertices with a zero velocity")
    95                 if 'ThermalAnalysis' in analyses:
    96                         md = checkfield(md,'fieldname','initialization.vx','NaN',1,'Inf',1,'size',[md.mesh.numberofvertices])
    97                         md = checkfield(md,'fieldname','initialization.vy','NaN',1,'Inf',1,'size',[md.mesh.numberofvertices])
    98                         md = checkfield(md,'fieldname','initialization.temperature','NaN',1,'Inf',1,'size',[md.mesh.numberofvertices])
    99                         if md.mesh.dimension()==3:
    100                                 md = checkfield(md,'fieldname','initialization.vz','NaN',1,'Inf',1,'size',[md.mesh.numberofvertices])
    101                         md = checkfield(md,'fieldname','initialization.pressure','NaN',1,'Inf',1,'size',[md.mesh.numberofvertices])
    102                         if ('EnthalpyAnalysis' in analyses and md.thermal.isenthalpy):
    103                                 md = checkfield(md,'fieldname','initialization.waterfraction','>=',0,'size',[md.mesh.numberofvertices])
    104                                 md = checkfield(md,'fieldname','initialization.watercolumn'  ,'>=',0,'size',[md.mesh.numberofvertices])
    105                                 pos = np.nonzero(md.initialization.waterfraction > 0.)[0]
    106                                 if(pos.size):
    107                                         md = checkfield(md,'fieldname', 'delta Tpmp', 'field', np.absolute(md.initialization.temperature[pos]-(md.materials.meltingpoint-md.materials.beta*md.initialization.pressure[pos])),'<',1e-11, 'message','set temperature to pressure melting point at locations with waterfraction>0');
    108                 if 'HydrologyShreveAnalysis' in analyses:
    109                         if hasattr(md.hydrology,'hydrologyshreve'):
    110                                 md = checkfield(md,'fieldname','initialization.watercolumn','NaN',1,'Inf',1,'size',[md.mesh.numberofvertices])
    111                 if 'HydrologyDCInefficientAnalysis' in analyses:
    112                         if hasattr(md.hydrology,'hydrologydc'):
    113                                 md = checkfield(md,'fieldname','initialization.sediment_head','NaN',1,'Inf',1,'size',[md.mesh.numberofvertices])
    114                 if 'HydrologyDCEfficientAnalysis' in analyses:
    115                         if hasattr(md.hydrology,'hydrologydc'):
    116                                 if md.hydrology.isefficientlayer==1:
    117                                         md = checkfield(md,'fieldname','initialization.epl_head','NaN',1,'Inf',1,'size',[md.mesh.numberofvertices])
    118                                         md = checkfield(md,'fieldname','initialization.epl_thickness','NaN',1,'Inf',1,'size',[md.mesh.numberofvertices])
     75        return self
     76    #}}}
     77    def setdefaultparameters(self): # {{{
     78        return self
     79    #}}}
     80    def checkconsistency(self,md,solution,analyses):    # {{{
     81        if 'StressbalanceAnalysis' in analyses:
     82            if not np.any(np.logical_or(np.isnan(md.initialization.vx),np.isnan(md.initialization.vy))):
     83                md = checkfield(md,'fieldname','initialization.vx','NaN',1,'Inf',1,'size',[md.mesh.numberofvertices])
     84                md = checkfield(md,'fieldname','initialization.vy','NaN',1,'Inf',1,'size',[md.mesh.numberofvertices])
     85        if 'MasstransportAnalysis' in analyses:
     86            md = checkfield(md,'fieldname','initialization.vx','NaN',1,'Inf',1,'size',[md.mesh.numberofvertices])
     87            md = checkfield(md,'fieldname','initialization.vy','NaN',1,'Inf',1,'size',[md.mesh.numberofvertices])
     88        if 'BalancethicknessAnalysis' in analyses:
     89            md = checkfield(md,'fieldname','initialization.vx','NaN',1,'Inf',1,'size',[md.mesh.numberofvertices])
     90            md = checkfield(md,'fieldname','initialization.vy','NaN',1,'Inf',1,'size',[md.mesh.numberofvertices])
     91            #Triangle with zero velocity
     92            if np.any(np.logical_and(np.sum(np.abs(md.initialization.vx[md.mesh.elements-1]),axis=1)==0,\
     93                                           np.sum(np.abs(md.initialization.vy[md.mesh.elements-1]),axis=1)==0)):
     94                md.checkmessage("at least one triangle has all its vertices with a zero velocity")
     95        if 'ThermalAnalysis' in analyses:
     96            md = checkfield(md,'fieldname','initialization.vx','NaN',1,'Inf',1,'size',[md.mesh.numberofvertices])
     97            md = checkfield(md,'fieldname','initialization.vy','NaN',1,'Inf',1,'size',[md.mesh.numberofvertices])
     98            md = checkfield(md,'fieldname','initialization.temperature','NaN',1,'Inf',1,'size',[md.mesh.numberofvertices])
     99            if md.mesh.dimension()==3:
     100                md = checkfield(md,'fieldname','initialization.vz','NaN',1,'Inf',1,'size',[md.mesh.numberofvertices])
     101            md = checkfield(md,'fieldname','initialization.pressure','NaN',1,'Inf',1,'size',[md.mesh.numberofvertices])
     102            if ('EnthalpyAnalysis' in analyses and md.thermal.isenthalpy):
     103                md = checkfield(md,'fieldname','initialization.waterfraction','>=',0,'size',[md.mesh.numberofvertices])
     104                md = checkfield(md,'fieldname','initialization.watercolumn'  ,'>=',0,'size',[md.mesh.numberofvertices])
     105                pos = np.nonzero(md.initialization.waterfraction > 0.)[0]
     106                if(pos.size):
     107                    md = checkfield(md,'fieldname', 'delta Tpmp', 'field', np.absolute(md.initialization.temperature[pos]-(md.materials.meltingpoint-md.materials.beta*md.initialization.pressure[pos])),'<',1e-11,    'message','set temperature to pressure melting point at locations with waterfraction>0');
     108        if 'HydrologyShreveAnalysis' in analyses:
     109            if hasattr(md.hydrology,'hydrologyshreve'):
     110                md = checkfield(md,'fieldname','initialization.watercolumn','NaN',1,'Inf',1,'size',[md.mesh.numberofvertices])
     111        if 'HydrologyDCInefficientAnalysis' in analyses:
     112            if hasattr(md.hydrology,'hydrologydc'):
     113                md = checkfield(md,'fieldname','initialization.sediment_head','NaN',1,'Inf',1,'size',[md.mesh.numberofvertices])
     114        if 'HydrologyDCEfficientAnalysis' in analyses:
     115            if hasattr(md.hydrology,'hydrologydc'):
     116                if md.hydrology.isefficientlayer==1:
     117                    md = checkfield(md,'fieldname','initialization.epl_head','NaN',1,'Inf',1,'size',[md.mesh.numberofvertices])
     118                    md = checkfield(md,'fieldname','initialization.epl_thickness','NaN',1,'Inf',1,'size',[md.mesh.numberofvertices])
    119119
    120                 return md
    121         # }}}
    122         def marshall(self,prefix,md,fid):    # {{{
     120        return md
     121    # }}}
     122    def marshall(self,prefix,md,fid):    # {{{
    123123
    124                 yts=md.constants.yts
     124        yts=md.constants.yts
    125125
    126                 WriteData(fid,prefix,'object',self,'fieldname','vx','format','DoubleMat','mattype',1,'scale',1./yts)
    127                 WriteData(fid,prefix,'object',self,'fieldname','vy','format','DoubleMat','mattype',1,'scale',1./yts)
    128                 WriteData(fid,prefix,'object',self,'fieldname','vz','format','DoubleMat','mattype',1,'scale',1./yts)
    129                 WriteData(fid,prefix,'object',self,'fieldname','pressure','format','DoubleMat','mattype',1)
    130                 WriteData(fid,prefix,'object',self,'fieldname','temperature','format','DoubleMat','mattype',1)
    131                 WriteData(fid,prefix,'object',self,'fieldname','waterfraction','format','DoubleMat','mattype',1)
    132                 WriteData(fid,prefix,'object',self,'fieldname','sediment_head','format','DoubleMat','mattype',1)
    133                 WriteData(fid,prefix,'object',self,'fieldname','epl_head','format','DoubleMat','mattype',1)
    134                 WriteData(fid,prefix,'object',self,'fieldname','epl_thickness','format','DoubleMat','mattype',1)
    135                 WriteData(fid,prefix,'object',self,'fieldname','watercolumn','format','DoubleMat','mattype',1)
    136                
    137                 if md.thermal.isenthalpy:
    138                     if (np.size(self.enthalpy)<=1):
    139                         tpmp = md.materials.meltingpoint - md.materials.beta*md.initialization.pressure;
    140                         pos  = np.nonzero(md.initialization.waterfraction > 0.)[0]
    141                         self.enthalpy      = md.materials.heatcapacity*(md.initialization.temperature-md.constants.referencetemperature);
    142                         self.enthalpy[pos] = md.materials.heatcapacity*(tpmp[pos].reshape(-1,) - md.constants.referencetemperature) + md.materials.latentheat*md.initialization.waterfraction[pos].reshape(-1,)
     126        WriteData(fid,prefix,'object',self,'fieldname','vx','format','DoubleMat','mattype',1,'scale',1./yts)
     127        WriteData(fid,prefix,'object',self,'fieldname','vy','format','DoubleMat','mattype',1,'scale',1./yts)
     128        WriteData(fid,prefix,'object',self,'fieldname','vz','format','DoubleMat','mattype',1,'scale',1./yts)
     129        WriteData(fid,prefix,'object',self,'fieldname','pressure','format','DoubleMat','mattype',1)
     130        WriteData(fid,prefix,'object',self,'fieldname','temperature','format','DoubleMat','mattype',1)
     131        WriteData(fid,prefix,'object',self,'fieldname','waterfraction','format','DoubleMat','mattype',1)
     132        WriteData(fid,prefix,'object',self,'fieldname','sediment_head','format','DoubleMat','mattype',1)
     133        WriteData(fid,prefix,'object',self,'fieldname','epl_head','format','DoubleMat','mattype',1)
     134        WriteData(fid,prefix,'object',self,'fieldname','epl_thickness','format','DoubleMat','mattype',1)
     135        WriteData(fid,prefix,'object',self,'fieldname','watercolumn','format','DoubleMat','mattype',1)
     136       
     137        if md.thermal.isenthalpy:
     138            if (np.size(self.enthalpy)<=1):
     139                tpmp = md.materials.meltingpoint - md.materials.beta*md.initialization.pressure;
     140                pos  = np.nonzero(md.initialization.waterfraction > 0.)[0]
     141                self.enthalpy      = md.materials.heatcapacity*(md.initialization.temperature-md.constants.referencetemperature);
     142                self.enthalpy[pos] = md.materials.heatcapacity*(tpmp[pos].reshape(-1,) - md.constants.referencetemperature) + md.materials.latentheat*md.initialization.waterfraction[pos].reshape(-1,)
    143143
    144                     WriteData(fid,prefix,'data',self.enthalpy,'format','DoubleMat','mattype',1,'name','md.initialization.enthalpy');
     144            WriteData(fid,prefix,'data',self.enthalpy,'format','DoubleMat','mattype',1,'name','md.initialization.enthalpy');
    145145
    146         # }}}
     146    # }}}
  • issm/trunk-jpl/test/NightlyRun/runme.py

    r23831 r23833  
    229229
    230230if __name__ == '__main__':
    231         if 'PYTHONSTARTUP' in os.environ:
    232                 PYTHONSTARTUP = os.environ['PYTHONSTARTUP']
    233                 #print 'PYTHONSTARTUP =', PYTHONSTARTUP
    234                 if os.path.exists(PYTHONSTARTUP):
    235                         try:
    236                                 exec(compile(open(PYTHONSTARTUP).read(), PYTHONSTARTUP, 'exec'))
    237                         except Exception as e:
    238                                 print("PYTHONSTARTUP error: ", e)
    239                 else:
    240                         print(("PYTHONSTARTUP file '{}' does not exist.".format(PYTHONSTARTUP)))
    241 
    242                 parser = argparse.ArgumentParser(description='RUNME - test deck for ISSM nightly runs')
    243                 parser.add_argument('-i', '--id', nargs='*', type=int, help='followed by the list of ids requested', default=[])
    244                 parser.add_argument('-in', '--include_name', nargs='*', type=str, help='followed by the list of test names requested', default=[])
    245                 parser.add_argument('-e', '--exclude', nargs='+', type=int, help='ids to be excluded from the test', default=[])
    246                 parser.add_argument('-en', '--exclude_name', nargs='+', type=str, help='test names to be excluded from the test', default=[])
    247                 parser.add_argument('-b', '--benchmark', help='nightly/ismip/eismint/thermal/mesh/...', default='nightly')
    248                 parser.add_argument('-p', '--procedure', help='check/update', default='check')
    249                 parser.add_argument('-o', '--output', help='nightly/daily/none', default='none')
    250                 parser.add_argument('-r', '--rank', type=int, help='rank', default=1)
    251                 parser.add_argument('-n', '--numprocs', type=int, help='numprocs', default=1)
    252                 args = parser.parse_args()
    253 
    254                 md = runme([args.id, args.include_name], [args.exclude, args.exclude_name], args.benchmark, args.procedure, args.output, args.rank, args.numprocs)
    255 
    256                 exit(md)
     231    if 'PYTHONSTARTUP' in os.environ:
     232        PYTHONSTARTUP = os.environ['PYTHONSTARTUP']
     233        #print 'PYTHONSTARTUP =', PYTHONSTARTUP
     234        if os.path.exists(PYTHONSTARTUP):
     235            try:
     236                exec(compile(open(PYTHONSTARTUP).read(), PYTHONSTARTUP, 'exec'))
     237            except Exception as e:
     238                print("PYTHONSTARTUP error: ", e)
     239        else:
     240            print(("PYTHONSTARTUP file '{}' does not exist.".format(PYTHONSTARTUP)))
     241
     242        parser = argparse.ArgumentParser(description='RUNME - test deck for ISSM nightly runs')
     243        parser.add_argument('-i', '--id', nargs='*', type=int, help='followed by the list of ids requested', default=[])
     244        parser.add_argument('-in', '--include_name', nargs='*', type=str, help='followed by the list of test names requested', default=[])
     245        parser.add_argument('-e', '--exclude', nargs='+', type=int, help='ids to be excluded from the test', default=[])
     246        parser.add_argument('-en', '--exclude_name', nargs='+', type=str, help='test names to be excluded from the test', default=[])
     247        parser.add_argument('-b', '--benchmark', help='nightly/ismip/eismint/thermal/mesh/...', default='nightly')
     248        parser.add_argument('-p', '--procedure', help='check/update', default='check')
     249        parser.add_argument('-o', '--output', help='nightly/daily/none', default='none')
     250        parser.add_argument('-r', '--rank', type=int, help='rank', default=1)
     251        parser.add_argument('-n', '--numprocs', type=int, help='numprocs', default=1)
     252        args = parser.parse_args()
     253
     254        md = runme([args.id, args.include_name], [args.exclude, args.exclude_name], args.benchmark, args.procedure, args.output, args.rank, args.numprocs)
     255
     256        exit(md)
    257257    else:
    258258        print("PYTHONSTARTUP not defined in environment")
Note: See TracChangeset for help on using the changeset viewer.