Changeset 14212


Ignore:
Timestamp:
01/07/13 10:30:35 (12 years ago)
Author:
jschierm
Message:

CHG: Get rid of more ugly Python logical nesting.

Location:
issm/trunk-jpl/test/NightlyRun
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • issm/trunk-jpl/test/NightlyRun/test1101.py

    r14134 r14212  
    99from solve import *
    1010from MatlabFuncs import *
     11from PythonFuncs import *
    1112
    1213"""
     
    4647        posx2=numpy.nonzero(md.mesh.x==numpy.max(md.mesh.x))[0]
    4748
    48         posy=numpy.nonzero(numpy.logical_and(numpy.logical_and(md.mesh.y==0.,md.mesh.x!=0.),md.mesh.x!=numpy.max(md.mesh.x)))[0]    #Don't take the same nodes two times
    49         posy2=numpy.nonzero(numpy.logical_and(numpy.logical_and(md.mesh.y==numpy.max(md.mesh.y),md.mesh.x!=0.),md.mesh.x!=numpy.max(md.mesh.x)))[0]
     49        posy=numpy.nonzero(logical_and_n(md.mesh.y==0.,md.mesh.x!=0.,md.mesh.x!=numpy.max(md.mesh.x)))[0]    #Don't take the same nodes two times
     50        posy2=numpy.nonzero(logical_and_n(md.mesh.y==numpy.max(md.mesh.y),md.mesh.x!=0.,md.mesh.x!=numpy.max(md.mesh.x)))[0]
    5051
    5152        md.diagnostic.vertex_pairing=numpy.vstack((numpy.hstack((posx.reshape(-1,1)+1,posx2.reshape(-1,1)+1)),numpy.hstack((posy.reshape(-1,1)+1,posy2.reshape(-1,1)+1))))
  • issm/trunk-jpl/test/NightlyRun/test1102.py

    r14134 r14212  
    99from solve import *
    1010from MatlabFuncs import *
     11from PythonFuncs import *
    1112
    1213"""
     
    4950#       posx=numpy.nonzero(md.mesh.x==0.)[0]
    5051#       posx2=numpy.nonzero(md.mesh.x==numpy.max(md.mesh.x))[0]
    51 #       posx=numpy.nonzero(numpy.logical_and(numpy.logical_and(md.mesh.x==0.,md.mesh.y!=0.),numpy.logical_and(md.mesh.y!=numpy.max(md.mesh.y),numpy.logical_not(md.mesh.vertexonbed))))[0]
    52 #       posx2=numpy.nonzero(numpy.logical_and(numpy.logical_and(md.mesh.x==numpy.max(md.mesh.x),md.mesh.y!=0.),numpy.logical_and(md.mesh.y!=numpy.max(md.mesh.y),numpy.logical_not(md.mesh.vertexonbed))))[0]
     52#       posx=numpy.nonzero(logical_and_n(md.mesh.x==0.,md.mesh.y!=0.,md.mesh.y!=numpy.max(md.mesh.y),numpy.logical_not(md.mesh.vertexonbed)))[0]
     53#       posx2=numpy.nonzero(logical_and_n(md.mesh.x==numpy.max(md.mesh.x),md.mesh.y!=0.,md.mesh.y!=numpy.max(md.mesh.y),numpy.logical_not(md.mesh.vertexonbed)))[0]
    5354
    54 #       posy=numpy.nonzero(numpy.logical_and(numpy.logical_and(md.mesh.y==0.,md.mesh.x!=0.),numpy.logical_and(md.mesh.x!=numpy.max(md.mesh.x),numpy.logical_not(md.mesh.vertexonbed))))[0]    #Don't take the same nodes two times
    55 #       posy2=numpy.nonzero(numpy.logical_and(numpy.logical_and(md.mesh.y==numpy.max(md.mesh.y),md.mesh.x!=0.),numpy.logical_and(md.mesh.x!=numpy.max(md.mesh.x),numpy.logical_not(md.mesh.vertexonbed))))[0]
     55#       posy=numpy.nonzero(logical_and_n(md.mesh.y==0.,md.mesh.x!=0.,md.mesh.x!=numpy.max(md.mesh.x),numpy.logical_not(md.mesh.vertexonbed)))[0]    #Don't take the same nodes two times
     56#       posy2=numpy.nonzero(logical_and_n(md.mesh.y==numpy.max(md.mesh.y),md.mesh.x!=0.,md.mesh.x!=numpy.max(md.mesh.x),numpy.logical_not(md.mesh.vertexonbed)))[0]
    5657
    5758#       md.diagnostic.vertex_pairing=numpy.vstack((numpy.hstack((posx.reshape(-1,1)+1,posx2.reshape(-1,1)+1)),numpy.hstack((posy.reshape(-1,1)+1,posy2.reshape(-1,1)+1))))
  • issm/trunk-jpl/test/NightlyRun/test1103.py

    r14134 r14212  
    99from solve import *
    1010from MatlabFuncs import *
     11from PythonFuncs import *
    1112
    1213"""
     
    4546        posx2=numpy.nonzero(md.mesh.x==numpy.max(md.mesh.x))[0]
    4647
    47         posy=numpy.nonzero(numpy.logical_and(numpy.logical_and(md.mesh.y==0.,md.mesh.x!=0.),md.mesh.x!=numpy.max(md.mesh.x)))[0]    #Don't take the same nodes two times
    48         posy2=numpy.nonzero(numpy.logical_and(numpy.logical_and(md.mesh.y==numpy.max(md.mesh.y),md.mesh.x!=0.),md.mesh.x!=numpy.max(md.mesh.x)))[0]
     48        posy=numpy.nonzero(logical_and_n(md.mesh.y==0.,md.mesh.x!=0.,md.mesh.x!=numpy.max(md.mesh.x)))[0]    #Don't take the same nodes two times
     49        posy2=numpy.nonzero(logical_and_n(md.mesh.y==numpy.max(md.mesh.y),md.mesh.x!=0.,md.mesh.x!=numpy.max(md.mesh.x)))[0]
    4950
    5051        md.diagnostic.vertex_pairing=numpy.vstack((numpy.hstack((posx.reshape(-1,1)+1,posx2.reshape(-1,1)+1)),numpy.hstack((posy.reshape(-1,1)+1,posy2.reshape(-1,1)+1))))
  • issm/trunk-jpl/test/NightlyRun/test1104.py

    r14134 r14212  
    88from solve import *
    99from MatlabFuncs import *
     10from PythonFuncs import *
    1011
    1112"""
     
    4041        posx2=numpy.nonzero(md.mesh.x==numpy.max(md.mesh.x))[0]
    4142
    42         posy=numpy.nonzero(numpy.logical_and(numpy.logical_and(md.mesh.y==0.,md.mesh.x!=0.),md.mesh.x!=numpy.max(md.mesh.x)))[0]    #Don't take the same nodes two times
    43         posy2=numpy.nonzero(numpy.logical_and(numpy.logical_and(md.mesh.y==numpy.max(md.mesh.y),md.mesh.x!=0.),md.mesh.x!=numpy.max(md.mesh.x)))[0]
     43        posy=numpy.nonzero(logical_and_n(md.mesh.y==0.,md.mesh.x!=0.,md.mesh.x!=numpy.max(md.mesh.x)))[0]    #Don't take the same nodes two times
     44        posy2=numpy.nonzero(logical_and_n(md.mesh.y==numpy.max(md.mesh.y),md.mesh.x!=0.,md.mesh.x!=numpy.max(md.mesh.x)))[0]
    4445
    4546        md.diagnostic.vertex_pairing=numpy.vstack((numpy.hstack((posx.reshape(-1,1)+1,posx2.reshape(-1,1)+1)),numpy.hstack((posy.reshape(-1,1)+1,posy2.reshape(-1,1)+1))))
     
    4950        md.cluster=generic('name',oshostname(),'np',8)
    5051        md=solve(md,DiagnosticSolutionEnum())
    51         pos=numpy.nonzero(numpy.logical_or(numpy.logical_or(md.mesh.x==0.,md.mesh.y==0.),numpy.logical_or(md.mesh.x==numpy.max(md.mesh.x),md.mesh.y==numpy.max(md.mesh.y))))
     52        pos=numpy.nonzero(logical_or_n(md.mesh.x==0.,md.mesh.y==0.,md.mesh.x==numpy.max(md.mesh.x),md.mesh.y==numpy.max(md.mesh.y)))
    5253        md.diagnostic.spcvx[pos]=md.results.DiagnosticSolution.Vx[pos]
    5354        md.diagnostic.spcvy[pos]=md.results.DiagnosticSolution.Vy[pos]
  • issm/trunk-jpl/test/NightlyRun/test1105.py

    r14134 r14212  
    99from solve import *
    1010from MatlabFuncs import *
     11from PythonFuncs import *
    1112
    1213"""
     
    3839        md.diagnostic.spcvz=float('NaN')*numpy.ones((md.mesh.numberofvertices,1))
    3940
    40         posx=numpy.nonzero(numpy.logical_and(numpy.logical_and(md.mesh.x==0.,md.mesh.y!=0.),md.mesh.y!=L))[0]
    41         posx2=numpy.nonzero(numpy.logical_and(numpy.logical_and(md.mesh.x==L,md.mesh.y!=0.),md.mesh.y!=L))[0]
     41        posx=numpy.nonzero(logical_and_n(md.mesh.x==0.,md.mesh.y!=0.,md.mesh.y!=L))[0]
     42        posx2=numpy.nonzero(logical_and_n(md.mesh.x==L,md.mesh.y!=0.,md.mesh.y!=L))[0]
    4243
    43         posy=numpy.nonzero(numpy.logical_and(numpy.logical_and(md.mesh.y==0.,md.mesh.x!=0.),md.mesh.x!=L))[0]    #Don't take the same nodes two times
    44         posy2=numpy.nonzero(numpy.logical_and(numpy.logical_and(md.mesh.y==L,md.mesh.x!=0.),md.mesh.x!=L))[0]
     44        posy=numpy.nonzero(logical_and_n(md.mesh.y==0.,md.mesh.x!=0.,md.mesh.x!=L))[0]    #Don't take the same nodes two times
     45        posy2=numpy.nonzero(logical_and_n(md.mesh.y==L,md.mesh.x!=0.,md.mesh.x!=L))[0]
    4546
    4647        md.diagnostic.vertex_pairing=numpy.vstack((numpy.hstack((posx.reshape(-1,1)+1,posx2.reshape(-1,1)+1)),numpy.hstack((posy.reshape(-1,1)+1,posy2.reshape(-1,1)+1))))
    4748
    4849        #Add spc on the corners
    49         pos=numpy.nonzero(numpy.logical_and(numpy.logical_and(numpy.logical_or(md.mesh.x==0.,md.mesh.x==L),numpy.logical_or(md.mesh.y==0.,md.mesh.y==L)),md.mesh.vertexonbed))
     50        pos=numpy.nonzero(logical_and_n(numpy.logical_or(md.mesh.x==0.,md.mesh.x==L),numpy.logical_or(md.mesh.y==0.,md.mesh.y==L),md.mesh.vertexonbed))
    5051        md.diagnostic.spcvx[pos]=0.
    5152        md.diagnostic.spcvy[pos]=0.
  • issm/trunk-jpl/test/NightlyRun/test1106.py

    r14134 r14212  
    88from solve import *
    99from MatlabFuncs import *
     10from PythonFuncs import *
    1011
    1112"""
     
    2526
    2627        #Add spc on the borders
    27         pos=numpy.nonzero(numpy.logical_or(numpy.logical_or(md.mesh.x==0.,md.mesh.x==numpy.max(md.mesh.x)),numpy.logical_or(md.mesh.y==0.,md.mesh.y==numpy.max(md.mesh.y))))
     28        pos=numpy.nonzero(logical_or_n(md.mesh.x==0.,md.mesh.x==numpy.max(md.mesh.x),md.mesh.y==0.,md.mesh.y==numpy.max(md.mesh.y)))
    2829        md.diagnostic.spcvx[pos]=0.
    2930        md.diagnostic.spcvy[pos]=0.
  • issm/trunk-jpl/test/NightlyRun/test1107.py

    r14134 r14212  
    99from solve import *
    1010from MatlabFuncs import *
     11from PythonFuncs import *
    1112
    1213"""
     
    4041        #Create MPCs to have periodic boundary conditions
    4142#       posx=find(md.mesh.x==0. & ~(md.mesh.y==0. & md.mesh.vertexonbed) & ~(md.mesh.y==L & md.mesh.vertexonbed));
    42         posx=numpy.nonzero(numpy.logical_and(md.mesh.x==0.,numpy.logical_and(numpy.logical_not(numpy.logical_and(md.mesh.y==0.,md.mesh.vertexonbed)),numpy.logical_not(numpy.logical_and(md.mesh.y==L,md.mesh.vertexonbed)))))[0]
     43        posx=numpy.nonzero(logical_and_n(md.mesh.x==0.,numpy.logical_not(numpy.logical_and(md.mesh.y==0.,md.mesh.vertexonbed)),numpy.logical_not(numpy.logical_and(md.mesh.y==L,md.mesh.vertexonbed))))[0]
    4344#       posx2=find(md.mesh.x==max(md.mesh.x) & ~(md.mesh.y==0. & md.mesh.vertexonbed) & ~(md.mesh.y==L & md.mesh.vertexonbed));
    44         posx2=numpy.nonzero(numpy.logical_and(md.mesh.x==numpy.max(md.mesh.x),numpy.logical_and(numpy.logical_not(numpy.logical_and(md.mesh.y==0.,md.mesh.vertexonbed)),numpy.logical_not(numpy.logical_and(md.mesh.y==L,md.mesh.vertexonbed)))))[0]
     45        posx2=numpy.nonzero(logical_and_n(md.mesh.x==numpy.max(md.mesh.x),numpy.logical_not(numpy.logical_and(md.mesh.y==0.,md.mesh.vertexonbed)),numpy.logical_not(numpy.logical_and(md.mesh.y==L,md.mesh.vertexonbed))))[0]
    4546
    46         posy=numpy.nonzero(numpy.logical_and(numpy.logical_and(md.mesh.y==0.,md.mesh.x!=0.),md.mesh.x!=numpy.max(md.mesh.x)))[0]    #Don't take the same nodes two times
    47         posy2=numpy.nonzero(numpy.logical_and(numpy.logical_and(md.mesh.y==numpy.max(md.mesh.y),md.mesh.x!=0.),md.mesh.x!=numpy.max(md.mesh.x)))[0]
     47        posy=numpy.nonzero(logical_and_n(md.mesh.y==0.,md.mesh.x!=0.,md.mesh.x!=numpy.max(md.mesh.x)))[0]    #Don't take the same nodes two times
     48        posy2=numpy.nonzero(logical_and_n(md.mesh.y==numpy.max(md.mesh.y),md.mesh.x!=0.,md.mesh.x!=numpy.max(md.mesh.x)))[0]
    4849
    4950        md.diagnostic.vertex_pairing=numpy.vstack((numpy.hstack((posx.reshape(-1,1)+1,posx2.reshape(-1,1)+1)),numpy.hstack((posy.reshape(-1,1)+1,posy2.reshape(-1,1)+1))))
    5051
    5152        #Add spc on the corners
    52         pos=numpy.nonzero(numpy.logical_and(numpy.logical_and(numpy.logical_or(md.mesh.x==0.,md.mesh.x==L),numpy.logical_or(md.mesh.y==0.,md.mesh.y==L)),md.mesh.vertexonbed))
     53        pos=numpy.nonzero(logical_and_n(numpy.logical_or(md.mesh.x==0.,md.mesh.x==L),numpy.logical_or(md.mesh.y==0.,md.mesh.y==L),md.mesh.vertexonbed))
    5354        md.diagnostic.spcvy[:]=0.
    5455        md.diagnostic.spcvx[pos]=0.
  • issm/trunk-jpl/test/NightlyRun/test1108.py

    r14134 r14212  
    88from solve import *
    99from MatlabFuncs import *
     10from PythonFuncs import *
    1011
    1112"""
     
    3334        md.diagnostic.spcvz=float('NaN')*numpy.ones((md.mesh.numberofvertices,1))
    3435       
    35         pos=numpy.nonzero(numpy.logical_and(md.mesh.vertexonbed,numpy.logical_and(numpy.logical_or(md.mesh.x==0.,md.mesh.x==numpy.max(md.mesh.x)),numpy.logical_or(md.mesh.y==0.,md.mesh.y==numpy.max(md.mesh.y)))))
     36        pos=numpy.nonzero(logical_and_n(md.mesh.vertexonbed,numpy.logical_or(md.mesh.x==0.,md.mesh.x==numpy.max(md.mesh.x)),numpy.logical_or(md.mesh.y==0.,md.mesh.y==numpy.max(md.mesh.y))))
    3637        md.diagnostic.spcvx[pos]=0.
    3738        md.diagnostic.spcvy[pos]=0.
     
    4243        posx2=numpy.nonzero(md.mesh.x==numpy.max(md.mesh.x))[0]
    4344
    44         posy=numpy.nonzero(numpy.logical_and(numpy.logical_and(md.mesh.y==0.,md.mesh.x!=0.),md.mesh.x!=numpy.max(md.mesh.x)))[0]    #Don't take the same nodes two times
    45         posy2=numpy.nonzero(numpy.logical_and(numpy.logical_and(md.mesh.y==numpy.max(md.mesh.y),md.mesh.x!=0.),md.mesh.x!=numpy.max(md.mesh.x)))[0]
     45        posy=numpy.nonzero(logical_and_n(md.mesh.y==0.,md.mesh.x!=0.,md.mesh.x!=numpy.max(md.mesh.x)))[0]    #Don't take the same nodes two times
     46        posy2=numpy.nonzero(logical_and_n(md.mesh.y==numpy.max(md.mesh.y),md.mesh.x!=0.,md.mesh.x!=numpy.max(md.mesh.x)))[0]
    4647
    4748        md.diagnostic.vertex_pairing=numpy.vstack((numpy.hstack((posx.reshape(-1,1)+1,posx2.reshape(-1,1)+1)),numpy.hstack((posy.reshape(-1,1)+1,posy2.reshape(-1,1)+1))))
     
    5859        md.diagnostic.spcvy=float('NaN')*numpy.ones((md.mesh.numberofvertices,1))
    5960        md.diagnostic.spcvz=float('NaN')*numpy.ones((md.mesh.numberofvertices,1))
    60         pos=numpy.nonzero(numpy.logical_or(numpy.logical_or(md.mesh.y==0.,md.mesh.x==0.),numpy.logical_or(md.mesh.x==numpy.max(md.mesh.x),md.mesh.y==numpy.max(md.mesh.y))))    #Don't take the same nodes two times
     61        pos=numpy.nonzero(logical_or_n(md.mesh.y==0.,md.mesh.x==0.,md.mesh.x==numpy.max(md.mesh.x),md.mesh.y==numpy.max(md.mesh.y)))    #Don't take the same nodes two times
    6162        md.diagnostic.spcvx[pos]=md.results.DiagnosticSolution.Vx[pos]
    6263        md.diagnostic.spcvy[pos]=md.results.DiagnosticSolution.Vy[pos]
Note: See TracChangeset for help on using the changeset viewer.