Changeset 25679


Ignore:
Timestamp:
10/12/20 08:20:25 (4 years ago)
Author:
jdquinn
Message:

CHG: MATLAB -> Python

File:
1 edited

Legend:

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

    r25632 r25679  
    147147    #}}}
    148148
     149    def ncaps(self): #{{{
     150        return len(self.icecaps)
     151    #}}}
     152
    149153    def continents(self):  # {{{
    150154        list = []
     
    166170            raise RuntimeError('addbasin method only takes a \'basin\' class object as input')
    167171        self.basins.append(bas)
     172    #}}}
     173
     174    def intersections2d(self, *args): #{{{
     175        options = pairoptions(*args)
     176        force = options.getfieldvalue('force', 0)
     177
     178        # Initialize, to avoid issues of having more transitions than meshes
     179        self.transitions = []
     180        self.eltransitions = []
     181
     182        # For elements
     183        xe = np.mean(self.earth.mesh.x[self.earth.mesh.elements - 1], axis=1)
     184        ye = np.mean(self.earth.mesh.y[self.earth.mesh.elements - 1], axis=1)
     185
     186        for i in range(len(self.icecaps)):
     187            mdi = self.icecaps[i]
     188
     189            # For elements
     190            xei = np.mean(mdi.mesh.x[mdi.mesh.elements - 1], axis=1)
     191            yei = np.mean(mdi.mesh.y[mdi.mesh.elements - 1], axis=1)
     192
     193            print('Computing vertex intersections for basin {}'.format(self.basins[i].name))
     194
     195            self.transitions.append(meshintersect2d(self.earth.mesh.x, self.earth.mesh.y, mdi.mesh.x, mdi.mesh.y, 'force', force))
     196            self.eltransitions.append(meshintersect2d(xe, ye, xei, yei, 'force', force))
    168197    #}}}
    169198
     
    315344        if loneedgesdetect:
    316345            edges = loneedges(md)
     346            # TODO: Reconfigure the following in the process of bringing plotting online
    317347            plotmodel(md, 'data', md.mask.land_levelset)
    318348            for i in range(len(edges)):
    319349                ind1 = edges(i, 1)
    320350                ind2 = edges(i, 2)
    321                 # TODO: Reconfigure the following in the process of bringing plotting online
    322351                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*-')
    323352
     
    327356        # Create mesh radius
    328357        self.earth.mesh.r = planetradius('earth') * np.ones((md.mesh.numberofvertices, ))
     358    #}}}
     359
     360    def caticecaps2d(self, *args):  #{{{
     361        # Recover options
     362        options = pairoptions(*args)
     363        tolerance = options.getfieldvalue('tolerance', 1e-5)
     364        loneedgesdetect = options.getfieldvalue('loneedgesdetect', 0)
     365        models = self.icecaps
     366
     367        # Plug all models together
     368        md = models[0]
     369        for i in range(1, len(models)):
     370            md = modelmerge2d(md, models[i], 'tolerance', tolerance)
     371
     372        # Look for lone edges if asked for it
     373        if loneedgesdetect:
     374            edges = loneedges(md)
     375            # TODO: Reconfigure the following in the process of bringing plotting online
     376            plotmodel(md, 'data', md.mask.land_levelset)
     377            for i in range(len(edges)):
     378                ind1 = edges(i, 1)
     379                ind2 = edges(i, 2)
     380                plot([md.mesh.x[ind1], md.mesh.x[ind2]], [md.mesh.y[ind1], md.mesh.y[ind2]], 'g*-')
     381
     382        # Plug into earth
     383        self.earth = md
    329384    #}}}
    330385
Note: See TracChangeset for help on using the changeset viewer.