Changeset 17480


Ignore:
Timestamp:
03/19/14 18:29:13 (11 years ago)
Author:
cborstad
Message:

CHG: cleaning up python imports. Use "m" prefix when using MatlabFuncs so that users can track down where these functions are defined rather than assuming they are mysterious python built-ins. Avoid importing * when possible, which cleans up the namespace and makes sure each module imports only what it needs (and that modules are not using functions imported by another module, which can break the code if modules are moved around)

Location:
issm/trunk-jpl/src/m
Files:
41 edited

Legend:

Unmodified
Added
Removed
  • TabularUnified issm/trunk-jpl/src/m/boundaryconditions/SetIceSheetBC.py

    r17071 r17480  
    11import os
    22import numpy
    3 from ContourToMesh import *
     3from ContourToMesh import ContourToMesh
    44
    55def SetIceSheetBC(md):
  • TabularUnified issm/trunk-jpl/src/m/boundaryconditions/SetIceShelfBC.py

    r17071 r17480  
    11import os
    22import numpy
    3 from ContourToMesh import *
    4 from MatlabFuncs import *
     3from ContourToMesh import ContourToMesh
     4import MatlabFuncs as m
    55
    66def SetIceShelfBC(md,icefrontfile=''):
     
    4444
    4545        #First find segments that are not completely on the front
    46         if strcmp(md.mesh.meshtype(),'3D'):
     46        if m.strcmp(md.mesh.meshtype(),'3D'):
    4747                numbernodesfront=4;
    48         elif strcmp(md.mesh.meshtype(),'2Dhorizontal'):
     48        elif m.strcmp(md.mesh.meshtype(),'2Dhorizontal'):
    4949                numbernodesfront=2;
    5050        else:
  • TabularUnified issm/trunk-jpl/src/m/boundaryconditions/SetMarineIceSheetBC.py

    r17477 r17480  
    11import os
    22import numpy
    3 from ContourToMesh import *
    4 from MatlabFuncs import *
     3from ContourToMesh import ContourToMesh
     4import MatlabFuncs as m
    55
    66def SetMarineIceSheetBC(md,icefrontfile=''):
     
    5353
    5454        #First find segments that are not completely on the front
    55         if not strcmp(md.mesh.meshtype(),'3D'):
     55        if not m.strcmp(md.mesh.meshtype(),'3D'):
    5656                numbernodesfront=2
    5757        else:
  • TabularUnified issm/trunk-jpl/src/m/classes/clusters/generic.py

    r17264 r17480  
    11import socket
     2import os
    23import math
    34import subprocess
    45from IssmConfig import IssmConfig
    56from EnumToString import EnumToString
    6 from issmdir import *
    7 from pairoptions import *
    8 from issmssh import *
    9 from issmscpin import *
    10 from issmscpout import *
    11 from MatlabFuncs import *
     7from issmdir import issmdir
     8from pairoptions import pairoptions
     9from issmssh import issmssh
     10from issmscpin import issmscpin
     11from issmscpout import issmscpout
     12import MatlabFuncs as m
    1213
    1314class generic(object):
     
    3738
    3839                #get name
    39                 self.name=gethostname()
     40                self.name=socket.gethostname()
    4041
    4142                #initialize cluster using user settings if provided
     
    7172
    7273                #write queuing script
    73                 if not ispc():
     74                if not m.ispc():
    7475
    7576                        fid=open(modelname+'.queue','w')
     
    123124
    124125                #write queuing script
    125                 if not ispc():
     126                if not m.ispc():
    126127
    127128                        fid=open(modelname+'.queue','w')
     
    181182        def Download(self,dirname,filelist):     # {{{
    182183
    183                 if ispc():
     184                if m.ispc():
    184185                        #do nothing
    185186                        return
  • TabularUnified issm/trunk-jpl/src/m/classes/damage.py

    r17401 r17480  
    22from EnumDefinitions import *
    33from StringToEnum import StringToEnum
    4 from checkfield import *
    5 from WriteData import *
     4from checkfield import checkfield
     5from WriteData import WriteData
     6import MatlabFuncs as m
    67
    78class damage(object):
     
    109110        def defaultoutputs(self,md): # {{{
    110111
    111                 if strcmp(md.mesh.meshtype(),'3D'):
     112                if m.strcmp(md.mesh.meshtype(),'3D'):
    112113                        list = ['DamageD']
    113                 elif strcmp(md.mesh.meshtype(),'2Dhorizontal'):
     114                elif m.strcmp(md.mesh.meshtype(),'2Dhorizontal'):
    114115                        list = ['DamageD']
    115                 elif strcmp(md.mesh.meshtype(),'2Dvertical'):
     116                elif m.strcmp(md.mesh.meshtype(),'2Dvertical'):
    116117                        list = ['DamageD']
    117118                else:
     
    143144                        md = checkfield(md,'fieldname','damage.equiv_stress','numel',[1],'values',[0,1])
    144145                        md = checkfield(md,'fieldname','damage.requested_outputs','stringrow',1)
    145                 elif strcmpi(self.law,'undamaged'):
     146                elif m.strcmpi(self.law,'undamaged'):
    146147                        if (solution==DamageEvolutionSolutionEnum):
    147148                                raise RuntimeError('Invalid evolution law (md.damage.law) for a damage solution')
  • TabularUnified issm/trunk-jpl/src/m/classes/dependent.py

    r14640 r17480  
    11import os.path
    22import numpy
    3 from pairoptions import *
    4 from fielddisplay import *
    5 from MatlabFuncs import *
     3from pairoptions import pairoptions
     4from fielddisplay import fielddisplay
     5import MatlabFuncs as m
    66from EnumDefinitions import *
    7 from WriteData import *
    8 from MeshProfileIntersection import *
     7from MeshProfileIntersection import MeshProfileIntersection
    98
    109class dependent(object):
  • TabularUnified issm/trunk-jpl/src/m/classes/flowequation.py

    r17151 r17480  
    33from fielddisplay import fielddisplay
    44from EnumDefinitions import *
    5 from checkfield import *
    6 from WriteData import *
     5from checkfield import checkfield
     6from WriteData import WriteData
     7import MatlabFuncs as m
    78
    89class flowequation(object):
     
    7980                        md = checkfield(md,'fieldname','flowequation.borderHO','size',[md.mesh.numberofvertices],'values',[0,1])
    8081                        md = checkfield(md,'fieldname','flowequation.borderFS','size',[md.mesh.numberofvertices],'values',[0,1])
    81                         if strcmp(md.mesh.meshtype(),'2Dhorizontal'):
     82                        if m.strcmp(md.mesh.meshtype(),'2Dhorizontal'):
    8283                                md = checkfield(md,'fieldname','flowequation.vertex_equation','size',[md.mesh.numberofvertices],'values',[1,2])
    8384                                md = checkfield(md,'fieldname','flowequation.element_equation','size',[md.mesh.numberofelements],'values',[1,2])
    84                         elif strcmp(md.mesh.meshtype(),'3D'):
     85                        elif m.strcmp(md.mesh.meshtype(),'3D'):
    8586                                md = checkfield(md,'fieldname','flowequation.vertex_equation','size',[md.mesh.numberofvertices],'values',numpy.arange(0,8+1))
    8687                                md = checkfield(md,'fieldname','flowequation.element_equation','size',[md.mesh.numberofelements],'values',numpy.arange(0,8+1))
  • TabularUnified issm/trunk-jpl/src/m/classes/groundingline.py

    r17037 r17480  
    33from EnumDefinitions import *
    44from StringToEnum import StringToEnum
    5 from checkfield import *
    6 from WriteData import *
    7 from MatlabFuncs import *
     5from checkfield import checkfield
     6from WriteData import WriteData
     7import MatlabFuncs as m
    88
    99class groundingline(object):
     
    4444                md = checkfield(md,'fieldname','groundingline.migration','values',['None','AgressiveMigration','SoftMigration','SubelementMigration','SubelementMigration2'])
    4545
    46                 if not strcmp(self.migration,'None'):
     46                if not m.strcmp(self.migration,'None'):
    4747                        if numpy.any(numpy.isnan(md.geometry.bathymetry)):
    4848                                md.checkmessage("requesting grounding line migration, but bathymetry is absent!")
  • TabularUnified issm/trunk-jpl/src/m/classes/independent.py

    r16815 r17480  
    11import numpy
    2 from pairoptions import *
    3 from fielddisplay import *
    4 from MatlabFuncs import *
     2from pairoptions import pairoptions
     3from fielddisplay import fielddisplay
     4import MatlabFuncs as m
    55from EnumDefinitions import *
    6 from WriteData import *
    76
    87class independent(object):
  • TabularUnified issm/trunk-jpl/src/m/classes/initialization.py

    r16764 r17480  
    22from fielddisplay import fielddisplay
    33from EnumDefinitions import *
    4 from checkfield import *
    5 from WriteData import *
     4from checkfield import checkfield
     5from WriteData import WriteData
     6import MatlabFuncs as m
    67
    78class initialization(object):
     
    6566                        md = checkfield(md,'fieldname','initialization.vx','NaN',1,'size',[md.mesh.numberofvertices])
    6667                        md = checkfield(md,'fieldname','initialization.vy','NaN',1,'size',[md.mesh.numberofvertices])
    67                         if strcmp(md.mesh.meshtype(),'3D'):
     68                        if m.strcmp(md.mesh.meshtype(),'3D'):
    6869                                md = checkfield(md,'fieldname','initialization.vz','NaN',1,'size',[md.mesh.numberofvertices])
    6970                        md = checkfield(md,'fieldname','initialization.pressure','NaN',1,'size',[md.mesh.numberofvertices])
  • TabularUnified issm/trunk-jpl/src/m/classes/mesh.py

    r16764 r17480  
    22from fielddisplay import fielddisplay
    33from EnumDefinitions import *
    4 from checkfield import *
    5 from MatlabFuncs import *
     4from checkfield import checkfield
     5import MatlabFuncs as m
     6from WriteData import WriteData
    67
    78class mesh(object):
     
    131132                else:
    132133                        md = checkfield(md,'fieldname','mesh.elements','size',[md.mesh.numberofelements,6])
    133                 if numpy.any(numpy.logical_not(ismember(numpy.arange(1,md.mesh.numberofvertices+1),md.mesh.elements))):
     134                if numpy.any(numpy.logical_not(m.ismember(numpy.arange(1,md.mesh.numberofvertices+1),md.mesh.elements))):
    134135                        md.checkmessage("orphan nodes have been found. Check the mesh outline")
    135136                md = checkfield(md,'fieldname','mesh.dimension','values',[2,3])
  • TabularUnified issm/trunk-jpl/src/m/classes/mesh2d.py

    r16764 r17480  
    22from fielddisplay import fielddisplay
    33from EnumDefinitions import *
    4 from checkfield import *
    5 from MatlabFuncs import *
     4from checkfield import checkfield
     5import MatlabFuncs as m
    66
    77class mesh2d(object):
     
    8888                md = checkfield(md,'fieldname','mesh.elements','NaN',1,'>',0,'values',numpy.arange(1,md.mesh.numberofvertices+1))
    8989                md = checkfield(md,'fieldname','mesh.elements','size',[md.mesh.numberofelements,3])
    90                 if numpy.any(numpy.logical_not(ismember(numpy.arange(1,md.mesh.numberofvertices+1),md.mesh.elements))):
     90                if numpy.any(numpy.logical_not(m.ismember(numpy.arange(1,md.mesh.numberofvertices+1),md.mesh.elements))):
    9191                        md.checkmessage("orphan nodes have been found. Check the mesh outline")
    9292                md = checkfield(md,'fieldname','mesh.numberofelements','>',0)
  • TabularUnified issm/trunk-jpl/src/m/classes/pairoptions.py

    r15331 r17480  
    11from collections import OrderedDict
    2 from WriteData import *
     2from WriteData import WriteData
    33
    44class pairoptions(object):
  • TabularUnified issm/trunk-jpl/src/m/classes/plotoptions.py

    r15331 r17480  
    11from collections import OrderedDict, Counter, defaultdict
    2 from pairoptions import *
     2import pairoptions
    33
    44class plotoptions(object):
  • TabularUnified issm/trunk-jpl/src/m/classes/qmu.py

    r16304 r17480  
    33from fielddisplay import fielddisplay
    44from EnumDefinitions import *
    5 from checkfield import *
    6 from WriteData import *
    7 from MatlabFuncs import *
     5from checkfield import checkfield
     6from WriteData import WriteData
     7import MatlabFuncs as m
    88
    99class qmu(object):
     
    5656                                md.checkmessage("for qmu analysis, partitioning vector cannot go over npart, number of partition areas")
    5757
    58                 if not strcmpi(md.cluster.name,'none'):
     58                if not m.strcmpi(md.cluster.name,'none'):
    5959                        if not md.settings.waitonlock:
    6060                                md.checkmessage("waitonlock should be activated when running qmu in parallel mode!")
  • TabularUnified issm/trunk-jpl/src/m/classes/results.py

    r15131 r17480  
    11import numpy
    2 from pairoptions import *
    3 from fielddisplay import *
    4 from MatlabFuncs import *
     2from pairoptions import pairoptions
     3from fielddisplay import fielddisplay
     4import MatlabFuncs as m
    55from EnumDefinitions import *
    6 from WriteData import *
    76
    87class results(object):
  • TabularUnified issm/trunk-jpl/src/m/classes/stressbalance.py

    r16764 r17480  
    44from fielddisplay import fielddisplay
    55from EnumDefinitions import *
    6 from checkfield import *
    7 from WriteData import *
    8 from MatlabFuncs import *
     6from checkfield import checkfield
     7from WriteData import WriteData
     8import MatlabFuncs as m
    99
    1010class stressbalance(object):
     
    110110        def defaultoutputs(self,md): # {{{
    111111
    112                 if strcmp(md.mesh.meshtype(),'3D'):
     112                if m.strcmp(md.mesh.meshtype(),'3D'):
    113113                        list = ['Vx','Vy','Vz','Vel','Pressure']
    114                 elif strcmp(md.mesh.meshtype(),'2Dhorizontal'):
     114                elif m.strcmp(md.mesh.meshtype(),'2Dhorizontal'):
    115115                        list = ['Vx','Vy','Vel','Pressure']
    116                 elif strcmp(md.mesh.meshtype(),'2Dvertical'):
     116                elif m.strcmp(md.mesh.meshtype(),'2Dvertical'):
    117117                        list = ['Vx','Vy','Vel','Pressure']
    118118                else:
     
    129129                md = checkfield(md,'fieldname','stressbalance.spcvx','forcing',1)
    130130                md = checkfield(md,'fieldname','stressbalance.spcvy','forcing',1)
    131                 if strcmp(md.mesh.meshtype(),'3D'):
     131                if m.strcmp(md.mesh.meshtype(),'3D'):
    132132                        md = checkfield(md,'fieldname','stressbalance.spcvz','forcing',1)
    133133                md = checkfield(md,'fieldname','stressbalance.restol','size',[1],'>',0)
     
    161161                                        md.checkmessage("Vectors in stressbalance.referential (columns 1 to 3 and 4 to 6) must be orthogonal")
    162162                #CHECK THAT NO rotation specified for FS Grounded ice at base
    163                 if strcmp(md.mesh.meshtype(),'3D') and md.flowequation.isFS:
     163                if m.strcmp(md.mesh.meshtype(),'3D') and md.flowequation.isFS:
    164164                        pos=numpy.nonzero(numpy.logical_and(md.mask.groundedice_levelset,md.mesh.vertexonbed))
    165165                        if numpy.any(numpy.logical_not(numpy.isnan(md.stressbalance.referential[pos,:]))):
  • TabularUnified issm/trunk-jpl/src/m/classes/toolkits.py

    r16192 r17480  
    11from IssmConfig import IssmConfig
    2 from mumpsoptions import *
    3 from iluasmoptions import *
     2from mumpsoptions import mumpsoptions
     3from iluasmoptions import iluasmoptions
    44from EnumToString import EnumToString
    55from fielddisplay import fielddisplay
    66from EnumDefinitions import *
    7 from checkfield import *
    8 from MatlabFuncs import *
     7from checkfield import checkfield
    98
    109class toolkits(object):
  • TabularUnified issm/trunk-jpl/src/m/classes/verbose.py

    r15131 r17480  
    1 from pairoptions import *
    2 from MatlabFuncs import *
     1from pairoptions import pairoptions
     2import MatlabFuncs as m
    33from EnumDefinitions import *
    4 from WriteData import *
     4from WriteData import WriteData
    55
    66class verbose(object):
  • TabularUnified issm/trunk-jpl/src/m/consistency/checkfield.py

    r16764 r17480  
    11import numpy
    22import os
    3 from pairoptions import *
    4 from MatlabFuncs import *
     3from pairoptions import pairoptions
     4import MatlabFuncs as m
    55
    66def checkfield(md,*args):
     
    107107        if options.exist('values'):
    108108                fieldvalues=options.getfieldvalue('values')
    109                 if False in ismember(field,fieldvalues):
     109                if False in m.ismember(field,fieldvalues):
    110110                        if   len(fieldvalues)==1:
    111111                                md = md.checkmessage(options.getfieldvalue('message',\
  • TabularUnified issm/trunk-jpl/src/m/contrib/bamg/YamsCall.py

    r15749 r17480  
    33import subprocess
    44import os
    5 from ComputeHessian import *
    6 from ComputeMetric import *
    7 from MatlabFuncs import *
     5from ComputeHessian import ComputeHessian
     6from ComputeMetric import ComputeMetric
    87
    98def YamsCall(md,field,hmin,hmax,gradation,epsilon):
     
    8584        #call yams
    8685        print "%s\n" % '      call Yams...'
    87         if   ispc():
     86        if   m.ispc():
    8887                #windows
    8988                subprocess.call('yams2-win -O 1 -v -0 -ecp -hgrad %g carre0 carre1' % gradation,shell=True)
  • TabularUnified issm/trunk-jpl/src/m/exp/expcoarsen.py

    r16102 r17480  
    22import numpy as npy
    33from collections import OrderedDict
    4 from MatlabFuncs import *
    54from expread import expread
    65from expwrite import expwrite
  • TabularUnified issm/trunk-jpl/src/m/exp/expread.py

    r13341 r17480  
    22import numpy
    33from collections import OrderedDict
    4 from MatlabFuncs import *
     4import MatlabFuncs as m
    55
    66def expread(filename):
     
    4848                        break
    4949                A=A.split(None,1)
    50                 if not (len(A) == 2 and strcmp(A[0],'##') and strncmp(A[1],'Name:',5)):
     50                if not (len(A) == 2 and m.strcmp(A[0],'##') and strncmp(A[1],'Name:',5)):
    5151                        break
    5252                if len(A[1])>5:
     
    5757                #Get Icon
    5858                A=fid.readline().split(None,1)
    59                 if not (len(A) == 2 and strcmp(A[0],'##') and strncmp(A[1],'Icon:',5)):
     59                if not (len(A) == 2 and m.strcmp(A[0],'##') and strncmp(A[1],'Icon:',5)):
    6060                        break
    6161
    6262                #Get Info
    6363                A=fid.readline().split()
    64                 if not (len(A) == 4 and strcmp(A[0],'#') and strcmp(A[1],'Points')):
     64                if not (len(A) == 4 and m.strcmp(A[0],'#') and m.strcmp(A[1],'Points')):
    6565                        break
    6666
     
    7272                #Get Info
    7373                A=fid.readline().split()
    74                 if not (len(A) == 5 and strcmp(A[0],'#') and strcmp(A[1],'X') and strcmp(A[2],'pos') \
    75                                                          and strcmp(A[3],'Y') and strcmp(A[4],'pos')):
     74                if not (len(A) == 5 and m.strcmp(A[0],'#') and m.strcmp(A[1],'X') and m.strcmp(A[2],'pos') \
     75                                                         and m.strcmp(A[3],'Y') and m.strcmp(A[4],'pos')):
    7676                        break
    7777
  • TabularUnified issm/trunk-jpl/src/m/extrusion/project3d.py

    r17465 r17480  
    11import numpy
    2 from pairoptions import *
    3 from MatlabFuncs import *
     2from pairoptions import pairoptions
     3import MatlabFuncs as m
    44
    55def project3d(md,*args):
     
    2727        if not md:
    2828                raise TypeError("bad usage")
    29         if not strcmp(md.mesh.meshtype(),'3D'):
     29        if not m.strcmp(md.mesh.meshtype(),'3D'):
    3030                raise TypeError("input model is not 3d")
    3131
     
    4545                projected_vector=vector2d
    4646
    47         elif strcmpi(type,'node'):
     47        elif m.strcmpi(type,'node'):
    4848
    4949                #Initialize 3d vector
     
    6464                        projected_vector[((layer-1)*md.mesh.numberofvertices2d):(layer*md.mesh.numberofvertices2d),:]=vector2d
    6565
    66         elif strcmpi(type,'element'):
     66        elif m.strcmpi(type,'element'):
    6767
    6868                #Initialize 3d vector
  • TabularUnified issm/trunk-jpl/src/m/geometry/FlagElements.py

    r15998 r17480  
    11import numpy
    22import os
    3 #from basinzoom import *
    4 from ContourToMesh import *
    5 from MatlabFuncs import *
    6 from PythonFuncs import *
     3#from basinzoom import basinzoon
     4from ContourToMesh import ContourToMesh
     5import MatlabFuncs as m
     6import PythonFuncs as p
    77
    88def FlagElements(md,region):
     
    2626                        flag=numpy.zeros(md.mesh.numberofelements,bool)
    2727                        invert=0
    28                 elif strcmpi(region,'all'):
     28                elif m.strcmpi(region,'all'):
    2929                        flag=numpy.ones(md.mesh.numberofelements,bool)
    3030                        invert=0
    3131                else:
    3232                        #make sure that we actually don't want the elements outside the domain outline!
    33                         if strcmpi(region[0],'~'):
     33                        if m.strcmpi(region[0],'~'):
    3434                                region=region[1:]
    3535                                invert=1
     
    3939                        #does the region domain outline exist or do we have to look for xlim,ylim in basinzoom?
    4040                        if not os.path.exists(region):
    41                                 if len(region)>3 and not strcmp(region[-4:],'.exp'):
     41                                if len(region)>3 and not m.strcmp(region[-4:],'.exp'):
    4242                                        raise IOError("Error: File 'region' not found!" % region)
    4343                                raise RuntimeError("FlagElements.py calling basinzoom.py is not complete.")
    4444                                xlim,ylim=basinzoom('basin',region)
    45                                 flag_nodes=logical_and_n(md.mesh.x<xlim[1],md.mesh.x>xlim[0],md.mesh.y<ylim[1],md.mesh.y>ylim[0])
     45                                flag_nodes=p.logical_and_n(md.mesh.x<xlim[1],md.mesh.x>xlim[0],md.mesh.y<ylim[1],md.mesh.y>ylim[0])
    4646                                flag=numpy.prod(flag_nodes[md.mesh.elements],axis=1).astype(bool)
    4747                        else:
  • TabularUnified issm/trunk-jpl/src/m/mesh/ComputeHessian.py

    r13984 r17480  
    11import numpy
    2 from GetNodalFunctionsCoeff import *
    3 from GetAreas import *
    4 from MatlabFuncs import *
     2from GetNodalFunctionsCoeff import GetNodalFunctionsCoeff
     3from GetAreas import GetAreas
     4import MatlabFuncs as m
    55
    66def ComputeHessian(index,x,y,field,type):
     
    2626        if numpy.size(field)!=numberofnodes and numpy.size(field)!=numberofelements:
    2727                raise TypeError("ComputeHessian error message: the given field size not supported yet")
    28         if not strcmpi(type,'node') and not strcmpi(type,'element'):
     28        if not m.strcmpi(type,'node') and not m.strcmpi(type,'element'):
    2929                raise TypeError("ComputeHessian error message: only 'node' or 'element' type supported yet")
    3030
     
    5757        hessian=numpy.hstack((numpy.sum(gradx[index-1,0]*alpha,axis=1).reshape(-1,1),numpy.sum(grady[index-1,0]*alpha,axis=1).reshape(-1,1),numpy.sum(grady[index-1,0]*beta,axis=1).reshape(-1,1)))
    5858
    59         if strcmpi(type,'node'):
     59        if m.strcmpi(type,'node'):
    6060                #Compute Hessian on the nodes (average of the elements around)
    6161                hessian=numpy.hstack((sparse(line,numpy.ones((linesize,1)),numpy.tile((areas*hessian[:,0]).reshape(-1,1),(3,1)),numberofnodes,1)/weights, \
  • TabularUnified issm/trunk-jpl/src/m/mesh/bamg.py

    r16967 r17480  
    22import numpy
    33from collections import OrderedDict
    4 from pairoptions import *
    5 from bamggeom import *
    6 from bamgmesh import *
    7 from expread import *
    8 from expwrite import *
    9 from SegIntersect import *
    10 from MatlabFuncs import *
    11 from BamgMesher import *
    12 from ContourToNodes import *
     4from pairoptions import pairoptions
     5from bamggeom import bamggeom
     6from bamgmesh import bamgmesh
     7from expread import expread
     8from expwrite import expwrite
     9from SegIntersect import SegIntersect
     10import MatlabFuncs as m
     11from BamgMesher import BamgMesher
     12from ContourToNodes import ContourToNodes
    1313
    1414def bamg(md,*args):
     
    374374
    375375                        #Skip if the two edges already have a vertex in common
    376                         if any(ismember(geom.Edges[i,0:2],geom.Edges[j,0:2])):
     376                        if any(m.ismember(geom.Edges[i,0:2],geom.Edges[j,0:2])):
    377377                                continue
    378378
     
    471471
    472472                                        %update edges
    473                                         posedges=find(ismember(geom.Edges,j));
     473                                        posedges=find(m.ismember(geom.Edges,j));
    474474                                        geom.Edges(posedges)=i;
    475475                                        posedges=find(geom.Edges>j);
  • TabularUnified issm/trunk-jpl/src/m/mesh/rifts/meshprocessoutsiderifts.py

    r14098 r17480  
    11import numpy
    2 from ElementsFromEdge import *
    3 from MatlabFuncs import *
     2from ElementsFromEdge import ElementsFromEdge
     3import MatlabFuncs as m
    44
    55def meshprocessoutsiderifts(md,domainoutline):
     
    4747                                edgeelements=ElementsFromEdge(md.mesh.elements,A,B)
    4848                                #rule out those we already detected
    49                                 already_detected=ismember(edgeelements,elements)
     49                                already_detected=m.ismember(edgeelements,elements)
    5050                                nextelement=edgeelements(numpy.nonzero(numpy.logical_not(already_detected))[0])
    5151                                #add new detected element to the list of elements we are looking for.
    5252                                elements=numpy.concatenate((elements,nextelement))
    5353                                #new B:
    54                                 B=md.mesh.elements[nextelement-1,numpy.nonzero(numpy.logical_not(ismember(md.mesh.elements[nextelement-1,:],numpy.array([A,B]))))]
     54                                B=md.mesh.elements[nextelement-1,numpy.nonzero(numpy.logical_not(m.ismember(md.mesh.elements[nextelement-1,:],numpy.array([A,B]))))]
    5555               
    5656                        #take the list of elements on one side of the rift that connect to the tip,
  • TabularUnified issm/trunk-jpl/src/m/mesh/triangle.py

    r14018 r17480  
    11import numpy
    2 from TriMesh import *
    3 from NodeConnectivity import *
    4 from ElementConnectivity import *
    5 from MatlabFuncs import *
     2from TriMesh import TriMesh
     3from NodeConnectivity import NodeConnectivity
     4from ElementConnectivity import ElementConnectivity
     5import MatlabFuncs as m
    66
    77def triangle(md,domainname,*args):
     
    3636        if md.mesh.numberofelements:
    3737                choice = raw_input('This model already has a mesh. Are you sure you want to go ahead? (y/n)')
    38                 if not strcmp(choice,'y'):
     38                if not m.strcmp(choice,'y'):
    3939                        print 'no meshing done ... exiting'
    4040                        return None
  • TabularUnified issm/trunk-jpl/src/m/miscellaneous/fielddisplay.py

    r13965 r17480  
    22import numpy
    33from math import isnan
    4 from MatlabFuncs import *
     4import MatlabFuncs as m
    55
    66def fielddisplay(md,name,comment):
     
    101101                                break
    102102
    103         if strcmp(string,sbeg):
     103        if m.strcmp(string,sbeg):
    104104                string="%s%dx1%s" % (sbeg,len(field),send)
    105105        else:
     
    117117       
    118118        #take care of characterization
    119         if strcmp(characterization,"''") or strcmp(characterization,'""') or strcmpi(characterization,'nan'):
     119        if m.strcmp(characterization,"''") or m.strcmp(characterization,'""') or m.strcmpi(characterization,'nan'):
    120120                characterization="N/A"
    121121       
  • TabularUnified issm/trunk-jpl/src/m/os/issmdir.py

    r13170 r17480  
    11import os
    2 from MatlabFuncs import *
     2import MatlabFuncs as m
    33
    44def issmdir():
     
    1010        """
    1111
    12         if not ispc():
     12        if not m.ispc():
    1313                ISSM_DIR =os.environ['ISSM_DIR']
    1414        else:
    1515                ISSM_DIR =os.environ['ISSM_DIR_WIN']
    16                 if strcmpi(ISSM_DIR[-1],'/') or strcmpi(ISSM_DIR[-1],'\\'):
     16                if m.strcmpi(ISSM_DIR[-1],'/') or m.strcmpi(ISSM_DIR[-1],'\\'):
    1717                        ISSM_DIR = ISSM_DIR[:-1]    #shave off the last '/'
    1818
  • TabularUnified issm/trunk-jpl/src/m/os/issmscpin.py

    r17127 r17480  
    33import os
    44import shutil
    5 from MatlabFuncs import *
     5import MatlabFuncs as m
    66
    77def issmscpin(host, login,port,path, packages):
     
    2424
    2525        #if hostname and host are the same, do a simple copy
    26         if strcmpi(hostname,host):
     26        if m.strcmpi(hostname,host):
    2727
    2828                for package in packages:
     
    3434        else:
    3535
    36                 if ispc():
     36                if m.ispc():
    3737                        #use the putty project pscp.exe: it should be in the path.
    3838               
  • TabularUnified issm/trunk-jpl/src/m/os/issmscpout.py

    r17126 r17480  
    22import subprocess
    33import os
    4 from MatlabFuncs import *
     4import MatlabFuncs as m
    55
    66def issmscpout(host,path,login,port,packages):
     
    1616        #if hostname and host are the same, do a simple copy
    1717
    18         if strcmpi(host,hostname):
     18        if m.strcmpi(host,hostname):
    1919                for package in packages:
    2020                        here=os.getcwd()
     
    2727                        os.chdir(here)
    2828        else:
    29                 if ispc():
     29                if m.ispc():
    3030                        #use the putty project pscp.exe: it should be in the path.
    3131               
  • TabularUnified issm/trunk-jpl/src/m/os/issmssh.py

    r17127 r17480  
    22import subprocess
    33import os
    4 from MatlabFuncs import *
     4import MatlabFuncs as m
    55
    66def issmssh(host,login,port,command):
     
    1616
    1717        #if same as host, just run the command.
    18         if strcmpi(host,hostname):
     18        if m.strcmpi(host,hostname):
    1919                subprocess.call(command,shell=True)
    2020        else:
    21                 if ispc():
     21                if m.ispc():
    2222                        #use the putty project plink.exe: it should be in the path.
    2323               
  • TabularUnified issm/trunk-jpl/src/m/parameterization/setflowequation.py

    r17466 r17480  
    11import numpy
    22from model import *
    3 from pairoptions import *
    4 from MatlabFuncs import *
    5 from PythonFuncs import *
    6 from FlagElements import *
     3from pairoptions import pairoptions
     4import MatlabFuncs as m
     5import PythonFuncs as p
     6from FlagElements import FlagElements
    77
    88def setflowequation(md,*args):
     
    3737        #Find_out what kind of coupling to use
    3838        coupling_method=options.getfieldvalue('coupling','tiling')
    39         if not strcmpi(coupling_method,'tiling') and not strcmpi(coupling_method,'penalties'):
     39        if not m.strcmpi(coupling_method,'tiling') and not m.strcmpi(coupling_method,'penalties'):
    4040                raise TypeError("coupling type can only be: tiling or penalties")
    4141
     
    4949
    5050        #Flag the elements that have not been flagged as filltype
    51         if   strcmpi(filltype,'SIA'):
     51        if   m.strcmpi(filltype,'SIA'):
    5252                SIAflag[numpy.nonzero(numpy.logical_not(logical_or_n(SSAflag,HOflag)))]=True
    53         elif strcmpi(filltype,'SSA'):
     53        elif m.strcmpi(filltype,'SSA'):
    5454                SSAflag[numpy.nonzero(numpy.logical_not(logical_or_n(SIAflag,HOflag,FSflag)))]=True
    55         elif strcmpi(filltype,'HO'):
     55        elif m.strcmpi(filltype,'HO'):
    5656                HOflag[numpy.nonzero(numpy.logical_not(logical_or_n(SIAflag,SSAflag,FSflag)))]=True
    5757
     
    114114        SSAFSflag=numpy.zeros(md.mesh.numberofelements,bool)
    115115        HOFSflag=numpy.zeros(md.mesh.numberofelements,bool)
    116         if   strcmpi(coupling_method,'penalties'):
     116        if   m.strcmpi(coupling_method,'penalties'):
    117117                #Create the border nodes between HO and SSA and extrude them
    118118                numnodes2d=md.mesh.numberofvertices2d
     
    127127                        md.stressbalance.vertex_pairing=penalties
    128128
    129         elif strcmpi(coupling_method,'tiling'):
     129        elif m.strcmpi(coupling_method,'tiling'):
    130130                if   any(SSAflag) and any(HOflag):    #coupling SSA HO
    131131                        #Find node at the border
    132132                        nodeonSSAHO[numpy.nonzero(numpy.logical_and(nodeonSSA,nodeonHO))]=True
    133133                        #SSA elements in contact with this layer become SSAHO elements
    134                         matrixelements=ismember(md.mesh.elements-1,numpy.nonzero(nodeonSSAHO)[0])
     134                        matrixelements=m.ismember(md.mesh.elements-1,numpy.nonzero(nodeonSSAHO)[0])
    135135                        commonelements=numpy.sum(matrixelements,axis=1)!=0
    136136                        commonelements[numpy.nonzero(HOflag)]=False    #only one layer: the elements previously in SSA
     
    164164                        nodeonHOFS[numpy.nonzero(numpy.logical_and(nodeonHO,nodeonFS))]=True
    165165                        #FS elements in contact with this layer become HOFS elements
    166                         matrixelements=ismember(md.mesh.elements-1,numpy.nonzero(nodeonHOFS)[0])
     166                        matrixelements=m.ismember(md.mesh.elements-1,numpy.nonzero(nodeonHOFS)[0])
    167167                        commonelements=numpy.sum(matrixelements,axis=1)!=0
    168168                        commonelements[numpy.nonzero(HOflag)]=False    #only one layer: the elements previously in SSA
     
    196196                        nodeonSSAFS[numpy.nonzero(numpy.logical_and(nodeonSSA,nodeonFS))]=True
    197197                        #FS elements in contact with this layer become SSAFS elements
    198                         matrixelements=ismember(md.mesh.elements-1,numpy.nonzero(nodeonSSAFS)[0])
     198                        matrixelements=m.ismember(md.mesh.elements-1,numpy.nonzero(nodeonSSAFS)[0])
    199199                        commonelements=numpy.sum(matrixelements,axis=1)!=0
    200200                        commonelements[numpy.nonzero(SSAflag)]=False    #only one layer: the elements previously in SSA
  • TabularUnified issm/trunk-jpl/src/m/solve/WriteData.py

    r17169 r17480  
    22import math
    33import struct
    4 from pairoptions import *
    5 from MatlabFuncs import *
     4import pairoptions
     5import MatlabFuncs as m
    66from EnumDefinitions import *
    77from EnumToString import EnumToString
     
    1616
    1717        #process options
    18         #  the import above the function level doesn't work?
    19         from pairoptions import pairoptions
    20         options=pairoptions(*args)
     18        options=pairoptions.pairoptions(*args)
    2119
    2220        #Get data properties
     
    6260
    6361        #Step 2: write the data itself.
    64         if   strcmpi(format,'Boolean'):    # {{{
     62        if   m.strcmpi(format,'Boolean'):    # {{{
    6563#               if len(data) !=1:
    6664#                       raise ValueError('field %s cannot be marshalled as it has more than one element!' % EnumToString(enum)[0])
     
    7674                # }}}
    7775
    78         elif strcmpi(format,'Integer'):    # {{{
     76        elif m.strcmpi(format,'Integer'):    # {{{
    7977#               if len(data) !=1:
    8078#                       raise ValueError('field %s cannot be marshalled as it has more than one element!' % EnumToString(enum)[0])
     
    9088                # }}}
    9189
    92         elif strcmpi(format,'Double'):    # {{{
     90        elif m.strcmpi(format,'Double'):    # {{{
    9391#               if len(data) !=1:
    9492#                       raise ValueError('field %s cannot be marshalled as it has more than one element!' % EnumToString(enum)[0])
     
    104102                # }}}
    105103
    106         elif strcmpi(format,'String'):    # {{{
     104        elif m.strcmpi(format,'String'):    # {{{
    107105                #first write length of record
    108106                fid.write(struct.pack('i',len(data)+4+4))  #string + string size + code
     
    116114                # }}}
    117115
    118         elif strcmpi(format,'BooleanMat'):    # {{{
     116        elif m.strcmpi(format,'BooleanMat'):    # {{{
    119117
    120118                if   isinstance(data,bool):
     
    149147                # }}}
    150148
    151         elif strcmpi(format,'IntMat'):    # {{{
     149        elif m.strcmpi(format,'IntMat'):    # {{{
    152150
    153151                if   isinstance(data,(int,long)):
     
    182180                # }}}
    183181
    184         elif strcmpi(format,'DoubleMat'):    # {{{
     182        elif m.strcmpi(format,'DoubleMat'):    # {{{
    185183
    186184                if   isinstance(data,(bool,int,long,float)):
     
    219217                # }}}
    220218
    221         elif strcmpi(format,'MatArray'):    # {{{
     219        elif m.strcmpi(format,'MatArray'):    # {{{
    222220
    223221                #first get length of record
     
    263261                # }}}
    264262
    265         elif strcmpi(format,'StringArray'):    # {{{
     263        elif m.strcmpi(format,'StringArray'):    # {{{
    266264
    267265                #first get length of record
     
    319317        """
    320318
    321         if   strcmpi(format,'Boolean'):
     319        if   m.strcmpi(format,'Boolean'):
    322320                code=1
    323         elif strcmpi(format,'Integer'):
     321        elif m.strcmpi(format,'Integer'):
    324322                code=2
    325         elif strcmpi(format,'Double'):
     323        elif m.strcmpi(format,'Double'):
    326324                code=3
    327         elif strcmpi(format,'String'):
     325        elif m.strcmpi(format,'String'):
    328326                code=4
    329         elif strcmpi(format,'BooleanMat'):
     327        elif m.strcmpi(format,'BooleanMat'):
    330328                code=5
    331         elif strcmpi(format,'IntMat'):
     329        elif m.strcmpi(format,'IntMat'):
    332330                code=6
    333         elif strcmpi(format,'DoubleMat'):
     331        elif m.strcmpi(format,'DoubleMat'):
    334332                code=7
    335         elif strcmpi(format,'MatArray'):
     333        elif m.strcmpi(format,'MatArray'):
    336334                code=8
    337         elif strcmpi(format,'StringArray'):
     335        elif m.strcmpi(format,'StringArray'):
    338336                code=9
    339337        else:
  • TabularUnified issm/trunk-jpl/src/m/solve/loadresultsfromcluster.py

    r17265 r17480  
    11import os
    22import socket
    3 from MatlabFuncs import *
    4 from loadresultsfromdisk import *
     3import MatlabFuncs as m
     4from loadresultsfromdisk import loadresultsfromdisk
    55
    66def loadresultsfromcluster(md,runtimename=False):
     
    4141                os.remove(md.miscellaneous.name+'.errlog')
    4242                os.remove(md.miscellaneous.name+'.outbin')
    43                 if not ispc():
     43                if not m.ispc():
    4444                        os.remove(md.private.runtimename+'.tar.gz')
    4545
    4646        #erase input file if run was carried out on same platform.
    4747        hostname=socket.gethostname()
    48         if strcmpi(hostname,cluster.name):
     48        if m.strcmpi(hostname,cluster.name):
    4949                if md.qmu.isdakota:
    5050                        os.remove(os.path.join('qmu'+str(os.getpid()),md.miscellaneous.name+'.bin'))
     
    5353                        os.remove(md.miscellaneous.name+'.bin')
    5454                        os.remove(md.miscellaneous.name+'.toolkits')
    55                         if not ispc():
     55                        if not m.ispc():
    5656                                os.remove(md.miscellaneous.name+'.queue')
    5757                        else:
  • TabularUnified issm/trunk-jpl/src/m/solve/loadresultsfromdisk.py

    r13966 r17480  
    11import os
    2 from results import *
    3 from parseresultsfromdisk import *
     2from results import results
     3from parseresultsfromdisk import parseresultsfromdisk
    44from EnumToString import EnumToString
    5 from MatlabFuncs import *
     5import MatlabFuncs as m
    66
    77def loadresultsfromdisk(md,filename):
     
    5353
    5454                #if only one solution, extract it from list for user friendliness
    55                 if len(structure) == 1 and not strcmp(structure[0].SolutionType,'TransientSolution'):
     55                if len(structure) == 1 and not m.strcmp(structure[0].SolutionType,'TransientSolution'):
    5656                        setattr(md.results,structure[0].SolutionType,structure[0])
    5757
  • TabularUnified issm/trunk-jpl/src/m/solve/parseresultsfromdisk.py

    r16470 r17480  
    33from collections import OrderedDict
    44import results as resultsclass
    5 from MatlabFuncs import *
     5import MatlabFuncs as m
    66
    77def parseresultsfromdisk(filename,iosplit):
     
    5050       
    5151                #Add result
    52                 if hasattr(results[result['step']-1],result['fieldname']) and not strcmp(result['fieldname'],'SolutionType'):
     52                if hasattr(results[result['step']-1],result['fieldname']) and not m.strcmp(result['fieldname'],'SolutionType'):
    5353                        setattr(results[result['step']-1],result['fieldname'],numpy.vstack((getattr(results[result['step']-1],result['fieldname']),result['field'])))
    5454                else:
     
    162162                #Process units here FIXME: this should not be done here!
    163163                yts=365.0*24.0*3600.0
    164                 if strcmp(fieldname,'BalancethicknessThickeningRate'):
    165                         field = field*yts
    166                 elif strcmp(fieldname,'Time'):
     164                if m.strcmp(fieldname,'BalancethicknessThickeningRate'):
     165                        field = field*yts
     166                elif m.strcmp(fieldname,'Time'):
    167167                        field = field/yts
    168                 elif strcmp(fieldname,'HydrologyWaterVx'):
    169                         field = field*yts
    170                 elif strcmp(fieldname,'HydrologyWaterVy'):
    171                         field = field*yts
    172                 elif strcmp(fieldname,'Vx'):
    173                         field = field*yts
    174                 elif strcmp(fieldname,'Vy'):
    175                         field = field*yts
    176                 elif strcmp(fieldname,'Vz'):
    177                         field = field*yts
    178                 elif strcmp(fieldname,'Vel'):
    179                         field = field*yts
    180                 elif strcmp(fieldname,'BasalforcingsMeltingRate'):
    181                         field = field*yts
    182                 elif strcmp(fieldname,'TotalSmb'):
     168                elif m.strcmp(fieldname,'HydrologyWaterVx'):
     169                        field = field*yts
     170                elif m.strcmp(fieldname,'HydrologyWaterVy'):
     171                        field = field*yts
     172                elif m.strcmp(fieldname,'Vx'):
     173                        field = field*yts
     174                elif m.strcmp(fieldname,'Vy'):
     175                        field = field*yts
     176                elif m.strcmp(fieldname,'Vz'):
     177                        field = field*yts
     178                elif m.strcmp(fieldname,'Vel'):
     179                        field = field*yts
     180                elif m.strcmp(fieldname,'BasalforcingsMeltingRate'):
     181                        field = field*yts
     182                elif m.strcmp(fieldname,'TotalSmb'):
    183183                        field = field/10.**12.*yts #(GigaTon/year)
    184                 elif strcmp(fieldname,'SurfaceforcingsMassBalance'):
     184                elif m.strcmp(fieldname,'SurfaceforcingsMassBalance'):
    185185                        field = field*yts
    186186
  • TabularUnified issm/trunk-jpl/src/m/solve/solve.py

    r15907 r17480  
    22import os
    33import shutil
    4 from pairoptions import *
    5 from process_solve_options import *
     4from pairoptions import pairoptions
     5from process_solve_options import process_solve_options
    66from EnumDefinitions import *
    77from EnumToString import EnumToString
    8 from ismodelselfconsistent import *
    9 from marshall import *
    10 from waitonlock import *
    11 from loadresultsfromcluster import *
     8from ismodelselfconsistent import ismodelselfconsistent
     9from marshall import marshall
     10from waitonlock import waitonlock
     11from loadresultsfromcluster import loadresultsfromcluster
     12import MatlabFuncs as m
    1213
    1314def solve(md,solutionenum,*args):
     
    8384
    8485        #Stop here if batch mode
    85         if strcmpi(options['batch'],'yes'):
     86        if m.strcmpi(options['batch'],'yes'):
    8687                print 'batch mode requested: not launching job interactively'
    8788                print 'launch solution sequence on remote cluster by hand'
     
    9697
    9798        #did we even try to run? if so, wait on lock
    98         if strcmpi(options['upload'],'on'):
     99        if m.strcmpi(options['upload'],'on'):
    99100                print 'solve done uploading test decks'
    100101                return md
  • TabularUnified issm/trunk-jpl/src/m/solve/waitonlock.py

    r17264 r17480  
    22import socket
    33import time
    4 from MatlabFuncs import *
     4import MatlabFuncs as m
    55
    66def waitonlock(md):
     
    2424
    2525        #waitonlock will work if the lock is on the same machine only:
    26         if not strcmpi(socket.gethostname(),cluster):
     26        if not m.strcmpi(socket.gethostname(),cluster):
    2727
    2828                print 'solution launched on remote cluster. log in to detect job completion.'
    2929                choice=raw_input('Is the job successfully completed? (y/n) ')
    30                 if not strcmp(choice,'y'):
     30                if not m.strcmp(choice,'y'):
    3131                        print 'Results not loaded... exiting'
    3232                        flag=0
Note: See TracChangeset for help on using the changeset viewer.