Changeset 25477


Ignore:
Timestamp:
Aug 26, 2020, 6:04:56 AM (6 years ago)
Author:
bdef
Message:

BUG: fixing typos and imports

File:
1 edited

Legend:

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

    r25455 r25477  
    11import warnings
    2 
    32import numpy as np
    4 
     3from fielddisplay import fielddisplay
     4from fieldnames import fieldnames
    55from generic import generic
    66from issmsettings import issmsettings
    … …  
    1212from private import private
    1313from TwoDToThreeD import TwoDToThreeD
    14 
     14from plotmodel import plotmodel
     15from plot3 import plot3
     16from loneedges import loneedges
     17from planetradius import planetradius
    1518
    1619class sealevelmodel(object):
    … …  
    3033    """
    3134
    32     def __init__(self, *args): #{{{
    33         self.icecaps        = [] # list of land/ice models; name should be changed later
    34         self.earth          = 0 # model for the whole earth
    35         self.basins         = [] # list of basins, matching icecaps, where shapefile info is held
    36         self.cluster        = 0
    37         self.miscellaneous  = 0
    38         self.settings       = 0
    39         self.private        = 0
    40         self.mergedcaps     = 0
    41         self.transitions    = []
    42         self.eltransitions  = []
    43         self.planet         = ''
     35    def __init__(self, *args):  #{{{
     36        self.icecaps = [] # list of land/ice models; name should be changed later
     37        self.earth = 0 # model for the whole earth
     38        self.basins = [] # list of basins, matching icecaps, where shapefile info is held
     39        self.cluster = 0
     40        self.miscellaneous = 0
     41        self.settings = 0
     42        self.private = 0
     43        self.mergedcaps = 0
     44        self.transitions = []
     45        self.eltransitions = []
     46        self.planet = ''
    4447
    4548        # Create a default object
    … …  
    6063    #}}}
    6164
    62     def __repr__(self): # {{{
     65    def __repr__(self):  # {{{
    6366        s = '{}\n'.format(fielddisplay(self, 'icecaps', 'ice caps'))
    6467        s += '{}\n'.format(fielddisplay(self, 'earth', 'earth'))
    … …  
    6871    #}}}
    6972
    70     def setdefaultparameters(self): # {{{
    71         self.icecaps        = []
    72         self.earth          = []
    73         self.cluster        = generic()
    74         self.miscellaneous  = miscellaneous()
    75         self.settings       = issmsettings()
    76         self.private        = private()
    77         self.transitions    = []
    78         self.eltransitions  = []
    79         self.planet         = 'earth'
     73    def setdefaultparameters(self):  # {{{
     74        self.icecaps = []
     75        self.earth = []
     76        self.cluster = generic()
     77        self.miscellaneous = miscellaneous()
     78        self.settings = issmsettings()
     79        self.private = private()
     80        self.transitions = []
     81        self.eltransitions = []
     82        self.planet = 'earth'
    8083    #}}}
    8184
    8285    @staticmethod
    83     def checkconsistency(slm, solutiontype): # {{{
     86    def checkconsistency(slm, solutiontype):  # {{{
    8487        # Is the coupler turned on?
    8588        for i in range(len(slm.icecaps)):
    … …  
    107110    #}}}
    108111
    109     def mergeresults(self): # {{{
    110         champs = fieldnames(self.icecaps[i].results.TransientSolution)
     112    def mergeresults(self):  # {{{
     113        champs = fieldnames(self.icecaps[0].results.TransientSolution)
    111114        for i in range(len(self.mergedcaps / 2)):
    112115            md = self.mergedcaps[2 * i]
    … …  
    135138            self.mergedcaps[2 * i] = md
    136139    #}}}
    137    
    138     def listcaps(self): # {{{
     140
     141    def listcaps(self):  # {{{
    139142        for i in range(len(self.icecaps)):
    140143            print('{}: {}'.format(i, self.icecaps[i].miscellaneous.name))
    141144    #}}}
    142145
    143     def continents(self): # {{{
     146    def continents(self):  # {{{
    144147        list = []
    145148        for i in range(len(self.basins)):
    … …  
    148151    #}}}
    149152
    150     def basinsfromcontinent(self, continent): # {{{
     153    def basinsfromcontinent(self, continent):  # {{{
    151154        list = []
    152155        for i in range(len(self.icecaps)):
    … …  
    156159    #}}}
    157160
    158     def addbasin(self, bas): # {{{
     161    def addbasin(self, bas):  # {{{
    159162        if bas.__class__.__name__ != 'basin':
    160163            raise RuntimeError('addbasin method only takes a \'basin\' class object as input')
    … …  
    162165    #}}}
    163166
    164     def intersections(self, *args): #{{{
     167    def intersections(self, *args):  #{{{
    165168        options = pairoptions(*args)
    166169        force = options.getfieldvalue('force', 0)
    … …  
    181184
    182185            # For elements
    183             zei = mdi.mesh.x[mdi.mesh.elements] * onesmatrix / 3
     186            xei = mdi.mesh.x[mdi.mesh.elements] * onesmatrix / 3
    184187            yei = mdi.mesh.y[mdi.mesh.elements] * onesmatrix / 3
    185188            zei = mdi.mesh.z[mdi.mesh.elements] * onesmatrix / 3
    … …  
    191194    #}}}
    192195
    193     def checkintersections(self): #{{{
     196    def checkintersections(self):  #{{{
    194197        flags = np.zeros(self.earth.mesh.numberofvertices, 1)
    195198        for i in range(len(self.basins)):
    … …  
    198201    #}}}
    199202
    200     def checkbasinconsistency(self): #{{{
     203    def checkbasinconsistency(self):  #{{{
    201204        for i in range(len(self.basins)):
    202205            self.basins[i].checkconsistency()
    203206    #}}}
    204207
    205     def basinindx(self, *args): #{{{
     208    def basinindx(self, *args):  #{{{
    206209        options = pairoptions(*args)
    207210        continent = options.getfieldvalue('continent', 'all')
    … …  
    218221                    continent = np.unique(continent)
    219222                else:
    220                     pass # Nothing to do: assume we have a list of continents
     223                    pass  # Nothing to do: assume we have a list of continents
    221224            else:
    222                 pass # Nothing to do: assume we have a list of continents
     225                pass  # Nothing to do: assume we have a list of continents
    223226        else:
    224227            if continent == 'all':
    … …  
    229232                continent = np.unique(continent)
    230233            else:
    231                 pass # Nothing to do: assume we have a list of continents
     234                pass  # Nothing to do: assume we have a list of continents
    232235        #}}}
    233236
    … …  
    278281    #}}}
    279282
    280     def addicecap(self, md): #{{{
    281         if not type(md) ==  model:
     283    def addicecap(self, md):  #{{{
     284        if not type(md) == model:
    282285            raise Exception("addicecap method only takes a 'model' class object as input")
    283286
    … …  
    285288    #}}}
    286289
    287     def basinsplot3d(self, *args): #{{{
     290    def basinsplot3d(self, *args):  #{{{
    288291        for i in range(len(self.basins)):
    289292            self.basins[i].plot3d(*args)
    290293    #}}}
    291294
    292     def caticecaps(self, *args): #{{{
     295    def caticecaps(self, *args):  #{{{
    293296        # Recover options
    294297        options = pairoptions(*args)
    … …  
    313316            for i in range(len(edges)):
    314317                ind1 = edges(i, 1)
    315                 ind1 = edges(i, 2)
     318                ind2 = edges(i, 2)
    316319                plot3([md.mesh.x[ind1], md.mesh.x[ind2]], [md.mesh.y[ind1], md.mesh.y[ind2]], [md.mesh.z[ind1], md.mesh.z[ind2]], 'g*-')
    317320
    … …  
    323326    #}}}
    324327
    325     def viscousiterations(self): #{{{
     328    def viscousiterations(self):  #{{{
    326329        for i in range(len(self.icecaps)):
    327330            ic = self.icecaps[i]
    … …  
    332335    #}}}
    333336
    334     def maxtimestep(self): #{{{
     337    def maxtimestep(self):  #{{{
    335338        for i in range(len(self.icecaps)):
    336339            ic = self.icecaps[i]
    … …  
    343346        print("Earth: {}/{}", mvi, timei)
    344347    #}}}
    345    
    346     def transfer(self, string): #{{{
     348
     349    def transfer(self, string):  #{{{
    347350        # Recover field size in one icecap
    348         n = np.size(getattr(self.icecaps[i], string), 0)
     351        n = np.size(getattr(self.icecaps[0], string), 0)
    349352
    350353        if n == self.icecaps[0].mesh.numberofvertices:
    … …  
    367370            # Initialize #{{{
    368371            field = np.zeros((self.earth.mesh.numberofvertices + 1, nsteps))
    369             field[-1, :] = times # Transfer the times only, not the values
     372            field[-1, :] = times  # Transfer the times only, not the values
    370373            #}}}
    371374            # Transfer all the time fields #{{{
    … …  
    373376                capfieldi = getattr(self.icecaps[i], string)
    374377                for j in range(nsteps):
    375                     field[self.transitions[i], j] = capfieldi[0:-2, j] # Transfer only the values, not the time
    376             setattr(self.earth, string, field) # Do not forget to plug the field variable into its final location
     378                    field[self.transitions[i], j] = capfieldi[0:-2, j]  # Transfer only the values, not the time
     379            setattr(self.earth, string, field)  # Do not forget to plug the field variable into its final location
    377380            #}}}
    378381        elif n == (self.icecaps[0].mesh.numberofelements):
    … …  
    384387    #}}}
    385388
    386     def homogenize(self, noearth=0): #{{{
     389    def homogenize(self, noearth=0):  #{{{
    387390        mintimestep = np.inf
    388391
    389392        for i in range(len(self.icecaps)):
    390393            ic = self.icecaps[i]
    391             mintimestep = np.min(mintimestep, len (ic.results.TransientSolution))
     394            mintimestep = np.min(mintimestep, len(ic.results.TransientSolution))
    392395
    393396        if not noearth:
    … …  
    409412    #}}}
    410413
    411     def initializemodels(self): #{{{
     414    def initializemodels(self):  #{{{
    412415        for i in range(len(self.basins)):
    413416            md = model()
Note: See TracChangeset for help on using the changeset viewer.