Changeset 13470


Ignore:
Timestamp:
09/27/12 14:46:49 (12 years ago)
Author:
jschierm
Message:

CHG: More changes relating to python 1-d vectors vs. 2-d arrays (plus some cleanup).

Location:
issm/trunk-jpl/src/m
Files:
1 added
5 edited

Legend:

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

    r13467 r13470  
    2626                        raise IOError("SetIceShelfBC error message: ice front file '%s' not found." % icefrontfile)
    2727                [nodeinsideicefront,dum]=ContourToMesh(md.mesh.elements,md.mesh.x.reshape(-1,1),md.mesh.y.reshape(-1,1),icefrontfile,'node',2)
    28                 nodeonicefront=numpy.logical_and(md.mesh.vertexonboundary,nodeinsideicefront).astype(float)
     28                nodeonicefront=numpy.logical_and(md.mesh.vertexonboundary,nodeinsideicefront.reshape(-1)).astype(float)
    2929        else:
    30                 nodeonicefront=numpy.zeros((md.mesh.numberofvertices,1))
     30                nodeonicefront=numpy.zeros((md.mesh.numberofvertices))
    3131
    3232#       pos=find(md.mesh.vertexonboundary & ~nodeonicefront);
    33         pos=[i for i,(vob,noif) in enumerate(zip(md.mesh.vertexonboundary,nodeonicefront)) if vob and not noif]
    34         md.diagnostic.spcvx=float('NaN')*numpy.ones((md.mesh.numberofvertices,1))
    35         md.diagnostic.spcvy=float('NaN')*numpy.ones((md.mesh.numberofvertices,1))
    36         md.diagnostic.spcvz=float('NaN')*numpy.ones((md.mesh.numberofvertices,1))
     33        pos=numpy.nonzero(numpy.logical_and(md.mesh.vertexonboundary,numpy.logical_not(nodeonicefront)))[0]
     34        md.diagnostic.spcvx=float('nan')*numpy.ones((md.mesh.numberofvertices,1))
     35        md.diagnostic.spcvy=float('nan')*numpy.ones((md.mesh.numberofvertices,1))
     36        md.diagnostic.spcvz=float('nan')*numpy.ones((md.mesh.numberofvertices,1))
    3737        md.diagnostic.spcvx[pos]=0
    3838        md.diagnostic.spcvy[pos]=0
    3939        md.diagnostic.spcvz[pos]=0
    40         md.diagnostic.referential=float('NaN')*numpy.ones((md.mesh.numberofvertices,6))
     40        md.diagnostic.referential=float('nan')*numpy.ones((md.mesh.numberofvertices,6))
    4141
    4242        #Dirichlet Values
    4343        if isinstance(md.inversion.vx_obs,numpy.ndarray) and numpy.size(md.inversion.vx_obs,axis=0)==md.mesh.numberofvertices and isinstance(md.inversion.vy_obs,numpy.ndarray) and numpy.size(md.inversion.vy_obs,axis=0)==md.mesh.numberofvertices:
    44                 print '      boundary conditions for diagnostic model: spc set as observed velocities'
     44                print "      boundary conditions for diagnostic model: spc set as observed velocities"
    4545                md.diagnostic.spcvx[pos]=md.inversion.vx_obs[pos]
    4646                md.diagnostic.spcvy[pos]=md.inversion.vy_obs[pos]
    4747        else:
    48                 print '      boundary conditions for diagnostic model: spc set as zero'
     48                print "      boundary conditions for diagnostic model: spc set as zero"
    4949
    5050        #segment on Ice Front
    5151        #segment on Neumann (Ice Front)
    5252#       pos=find(nodeonicefront(md.mesh.segments(:,1)) | nodeonicefront(md.mesh.segments(:,2)));
    53         pos=[i for i,(noif1,noif2) in enumerate(zip(nodeonicefront[md.mesh.segments[:,0].astype('int')-1],nodeonicefront[md.mesh.segments[:,1].astype('int')-1])) if noif1 or noif2]
     53        pos=numpy.nonzero(numpy.logical_or(nodeonicefront[md.mesh.segments[:,0].astype(int)-1],nodeonicefront[md.mesh.segments[:,1].astype(int)-1]))[0]
    5454        if   md.mesh.dimension==2:
    5555                pressureload=md.mesh.segments[pos,:]
     
    6060                for i in xrange(1,md.mesh.numberoflayers):
    6161#                       pressureload=[pressureload ;pressureload_layer1(:,1:4)+(i-1)*md.mesh.numberofvertices2d pressureload_layer1(:,5)+(i-1)*md.mesh.numberofelements2d ];
    62                         pressureload=numpy.vstack((pressureload,numpy.hstack((pressureload_layer1[:,0:3]+(i-1)*md.mesh.numberofvertices2d,pressureload_layer1[:,4]+(i-1)*md.mesh.numberofelements2d))))
     62                        pressureload=numpy.vstack((pressureload,numpy.hstack((pressureload_layer1[:,0:4]+(i-1)*md.mesh.numberofvertices2d,pressureload_layer1[:,4]+(i-1)*md.mesh.numberofelements2d))))
    6363
    6464        #Add water or air enum depending on the element
    6565#       pressureload=[pressureload 1*md.mask.elementonfloatingice(pressureload(:,end))];
    66         pressureload=numpy.hstack((pressureload,1*md.mask.elementonfloatingice[pressureload[:,-1].astype('int')-1].reshape((-1,1))))
     66        pressureload=numpy.hstack((pressureload,1.*md.mask.elementonfloatingice[pressureload[:,-1].astype('int')-1].reshape(-1,1)))
    6767
    6868        #plug onto model
     
    7272        if numpy.all(numpy.isnan(md.surfaceforcings.precipitation)) and (md.surfaceforcings.ispdd==1):
    7373                md.surfaceforcings.precipitation=numpy.zeros((md.mesh.numberofvertices,1))
    74                 print '      no surfaceforcings.precipitation specified: values set as zero'
     74                print "      no surfaceforcings.precipitation specified: values set as zero"
    7575        if numpy.all(numpy.isnan(md.surfaceforcings.mass_balance)) and (md.surfaceforcings.ispdd==0):
    7676                md.surfaceforcings.mass_balance=numpy.zeros((md.mesh.numberofvertices,1))
    77                 print '      no surfaceforcings.mass_balance specified: values set as zero'
     77                print "      no surfaceforcings.mass_balance specified: values set as zero"
    7878        if numpy.all(numpy.isnan(md.basalforcings.melting_rate)):
    7979                md.basalforcings.melting_rate=numpy.zeros((md.mesh.numberofvertices,1))
    80                 print '      no basalforcings.melting_rate specified: values set as zero'
     80                print "      no basalforcings.melting_rate specified: values set as zero"
    8181        if numpy.all(numpy.isnan(md.balancethickness.thickening_rate)):
    8282                md.balancethickness.thickening_rate=numpy.zeros((md.mesh.numberofvertices,1))
    83                 print '      no balancethickness.thickening_rate specified: values set as zero'
     83                print "      no balancethickness.thickening_rate specified: values set as zero"
    8484
    85         md.prognostic.spcthickness=float('NaN')*numpy.ones((md.mesh.numberofvertices,1))
    86         md.balancethickness.spcthickness=float('NaN')*numpy.ones((md.mesh.numberofvertices,1))
     85        md.prognostic.spcthickness=float('nan')*numpy.ones((md.mesh.numberofvertices,1))
     86        md.balancethickness.spcthickness=float('nan')*numpy.ones((md.mesh.numberofvertices,1))
    8787
    88         if numpy.size(md.initialization.temperature)==md.mesh.numberofvertices:
    89                 md.thermal.spctemperature=float('NaN')*numpy.ones((md.mesh.numberofvertices,1))
     88        if isinstance(md.initialization.temperature,numpy.ndarray) and numpy.size(md.initialization.temperature,axis=0)==md.mesh.numberofvertices:
     89                md.thermal.spctemperature=float('nan')*numpy.ones((md.mesh.numberofvertices,1))
    9090#               pos=find(md.mesh.vertexonsurface); md.thermal.spctemperature(pos)=md.initialization.temperature(pos); %impose observed temperature on surface
    91                 pos=[i for i,vos in enumerate(md.mesh.vertexonsurface) if vos]
    92                 md.thermal.spctemperature[pos]=md.initialization.temperature[pos]    # impose observed temperature on surface
    93                 if not numpy.size(md.basalforcings.geothermalflux)==md.mesh.numberofvertices:
     91                pos=numpy.nonzero(md.mesh.vertexonsurface)[0]
     92                md.thermal.spctemperature[pos]=md.initialization.temperature[pos]    #impose observed temperature on surface
     93                if not isinstance(md.basalforcings.geothermalflux,numpy.ndarray) or not numpy.size(md.basalforcings.geothermalflux,axis=0)==md.mesh.numberofvertices:
    9494                        md.basalforcings.geothermalflux=numpy.zeros((md.mesh.numberofvertices,1))
    9595        else:
    96                 print '      no thermal boundary conditions created: no observed temperature found'
     96                print "      no thermal boundary conditions created: no observed temperature found"
    9797
    9898        return md
  • issm/trunk-jpl/src/m/boundaryconditions/SetMarineIceSheetBC.m

    r13076 r13470  
    5353
    5454md.hydrology.spcwatercolumn=zeros(md.mesh.numberofvertices,2);
    55 pos=find(md.mesh.vertexonboundary); 
     55pos=find(md.mesh.vertexonboundary);
    5656md.hydrology.spcwatercolumn(pos,1)=1;
    5757
     
    101101        if (length(md.basalforcings.geothermalflux)~=md.mesh.numberofvertices),
    102102                md.basalforcings.geothermalflux=zeros(md.mesh.numberofvertices,1);
    103                 md.basalforcings.geothermalflux(find(md.mask.vertexongroundedice))=50*10^-3; %50mW/m2
     103                md.basalforcings.geothermalflux(find(md.mask.vertexongroundedice))=50.*10.^-3; %50mW/m2
    104104        end
    105105else
  • issm/trunk-jpl/src/m/classes/model/model.py

    r13462 r13470  
    167167                print ("model not consistent: %s" % string)
    168168                self.private.isconsistent=False
     169                return self
    169170        # }}}
    170171
  • issm/trunk-jpl/src/m/geometry/FlagElements.py

    r13449 r13470  
    4141                                if len(region)>3 and not strcmp(region[-4:],'.exp'):
    4242                                        raise IOError("Error: File 'region' not found!" % region)
    43                                 raise RuntimeError("FlagElements -- basinzoom not yet converted.")
     43                                raise RuntimeError("FlagElements.py calling basinzoom.py is not complete.")
    4444                                xlim,ylim=basinzoom('basin',region)
    4545                                flag_nodes=numpy.logical_and(numpy.logical_and(md.mesh.x<xlim[1],md.mesh.x>xlim[0]),numpy.logical_and(md.mesh.y<ylim[1],md.mesh.y>ylim[0])).astype(float)
     
    4747                        else:
    4848                                #ok, flag elements
    49                                 [flag,fnone]=ContourToMesh(md.mesh.elements[:,0:3],md.mesh.x.reshape(-1,1),md.mesh.y.reshape(-1,1),region,'element',1)
     49                                [flag,dum]=ContourToMesh(md.mesh.elements[:,0:3],md.mesh.x.reshape(-1,1),md.mesh.y.reshape(-1,1),region,'element',1)
    5050
    5151                if invert:
  • issm/trunk-jpl/src/m/mesh/bamg.py

    r13436 r13470  
    121121
    122122                                elif numpy.any(numpy.logical_not(flags)):
    123                                         raise RuntimeError("bamg.m for rifts is not complete.")
     123                                        raise RuntimeError("bamg.py for rifts is not complete.")
    124124                                        #We LOTS of work to do
    125125                                        print("Rift tip outside of or on the domain has been detected and is being processed...")
     
    347347def processgeometry(geom,tol,outline):    # {{{
    348348
    349         raise RuntimeError("bamg.m/processgeometry is not complete.")
     349        raise RuntimeError("bamg.py/processgeometry is not complete.")
    350350        #Deal with edges
    351351        print("Checking Edge crossing...")
Note: See TracChangeset for help on using the changeset viewer.