source: issm/oecreview/Archive/13393-13976/ISSM-13469-13470.diff@ 14312

Last change on this file since 14312 was 13980, checked in by Mathieu Morlighem, 12 years ago

preparing oecreview for 13393-13976'

File size: 17.5 KB
  • ../trunk-jpl/src/m/geometry/FlagElements.py

     
    4040                        if not os.path.exists(region):
    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)
    4646                                flag=numpy.prod(flag_nodes[md.mesh.elements],axis=1)
    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:
    5252                        flag=numpy.logical_not(flag)
  • ../trunk-jpl/src/m/mesh/bamg.py

     
    120120                                        raise RuntimeError("one rift has all its points outside of the domain outline")
    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...")
    126126                                        """
     
    346346
    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...")
    352352        i=0
  • ../trunk-jpl/src/m/classes/model/model.py

     
    166166        def checkmessage(self,string):    # {{{
    167167                print ("model not consistent: %s" % string)
    168168                self.private.isconsistent=False
     169                return self
    169170        # }}}
    170171
    171172        def extrude(md,*args):    # {{{
  • ../trunk-jpl/src/m/boundaryconditions/SetMarineIceSheetBC.m

     
    5252end
    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
    5858%segment on Neumann (Ice Front)
     
    100100        pos=find(md.mesh.vertexonsurface); md.thermal.spctemperature(pos)=md.initialization.temperature(pos); %impose observed temperature on surface
    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
    106106        disp('      no thermal boundary conditions created: no observed temperature found');
  • ../trunk-jpl/src/m/boundaryconditions/SetIceShelfBC.py

     
    2525                if not os.path.exists(icefrontfile):
    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,:]
    5656        elif md.mesh.dimension==3:
     
    5959                pressureload=numpy.zeros((0,5))
    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
    6969        md.diagnostic.icefront=pressureload
     
    7171        #Create zeros basalforcings and surfaceforcings
    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
    9999
  • ../trunk-jpl/src/m/boundaryconditions/SetMarineIceSheetBC.py

     
     1import os
     2import numpy
     3from ContourToMesh import *
     4
     5def SetMarineIceSheetBC(md,icefrontfile=''):
     6        """
     7        SETICEMARINESHEETBC - Create the boundary conditions for diagnostic and thermal models for a  Marine Ice Sheet with Ice Front
     8
     9           Neumann BC are used on the ice front (an ARGUS contour around the ice front
     10           can be given in input, or it will be deduced as onfloatingice & onboundary)
     11           Dirichlet BC are used elsewhere for diagnostic
     12
     13           Usage:
     14              md=SetMarineIceSheetBC(md,icefrontfile)
     15              md=SetMarineIceSheetBC(md)
     16
     17           Example:
     18              md=SetMarineIceSheetBC(md,'Front.exp')
     19              md=SetMarineIceSheetBC(md)
     20
     21           See also: SETICESHELFBC, SETMARINEICESHEETBC
     22        """
     23
     24        #node on Dirichlet (boundary and ~icefront)
     25        if icefrontfile:
     26                #User provided Front.exp, use it
     27                if not os.path.exists(icefrontfile):
     28                        raise IOError("SetMarineIceSheetBC error message: ice front file '%s' not found." % icefrontfile)
     29                [nodeinsideicefront,dum]=ContourToMesh(md.mesh.elements,md.mesh.x.reshape(-1,1),md.mesh.y.reshape(-1,1),icefrontfile,'node',2)
     30                vertexonicefront=numpy.logical_and(md.mesh.vertexonboundary,nodeinsideicefront.reshape(-1)).astype(float)
     31        else:
     32                #Guess where the ice front is
     33                vertexonfloatingice=numpy.zeros((md.mesh.numberofvertices))
     34                vertexonfloatingice[md.mesh.elements[numpy.nonzero(md.mask.elementonfloatingice),:].astype(int)-1]=1
     35                vertexonicefront=numpy.logical_and(md.mesh.vertexonboundary,vertexonfloatingice).astype(float)
     36
     37#       pos=find(md.mesh.vertexonboundary & ~vertexonicefront);
     38        pos=numpy.nonzero(numpy.logical_and(md.mesh.vertexonboundary,numpy.logical_not(vertexonicefront)))[0]
     39        if not numpy.size(pos):
     40                print("SetMarineIceSheetBC warning: ice front all around the glacier, no dirichlet found. Dirichlet must be added manually.")
     41
     42        md.diagnostic.spcvx=float('nan')*numpy.ones((md.mesh.numberofvertices,1))
     43        md.diagnostic.spcvy=float('nan')*numpy.ones((md.mesh.numberofvertices,1))
     44        md.diagnostic.spcvz=float('nan')*numpy.ones((md.mesh.numberofvertices,1))
     45        md.diagnostic.spcvx[pos]=0
     46        md.diagnostic.spcvy[pos]=0
     47        md.diagnostic.spcvz[pos]=0
     48        md.diagnostic.referential=float('nan')*numpy.ones((md.mesh.numberofvertices,6))
     49
     50        #Dirichlet Values
     51        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:
     52                print("      boundary conditions for diagnostic model: spc set as observed velocities")
     53                md.diagnostic.spcvx[pos]=md.inversion.vx_obs[pos]
     54                md.diagnostic.spcvy[pos]=md.inversion.vy_obs[pos]
     55        else:
     56                print("      boundary conditions for diagnostic model: spc set as zero")
     57
     58        md.hydrology.spcwatercolumn=numpy.zeros((md.mesh.numberofvertices,2))
     59        pos=numpy.nonzero(md.mesh.vertexonboundary)[0]
     60        md.hydrology.spcwatercolumn[pos,0]=1
     61
     62        #segment on Neumann (Ice Front)
     63#       pos=find(vertexonicefront(md.mesh.segments(:,1)) | vertexonicefront(md.mesh.segments(:,2)));
     64        pos=numpy.nonzero(numpy.logical_or(vertexonicefront[md.mesh.segments[:,0].astype(int)-1],vertexonicefront[md.mesh.segments[:,1].astype(int)-1]))[0]
     65        if   md.mesh.dimension==2:
     66                pressureload=md.mesh.segments[pos,:]
     67        elif md.mesh.dimension==3:
     68#               pressureload_layer1=[md.mesh.segments(pos,1:2)  md.mesh.segments(pos,2)+md.mesh.numberofvertices2d  md.mesh.segments(pos,1)+md.mesh.numberofvertices2d  md.mesh.segments(pos,3)];
     69                pressureload_layer1=numpy.hstack((md.mesh.segments[pos,0:2],md.mesh.segments[pos,1]+md.mesh.numberofvertices2d,md.mesh.segments[pos,0]+md.mesh.numberofvertices2d,md.mesh.segments[pos,2]))
     70                pressureload=numpy.zeros((0,5))
     71                for i in xrange(1,md.mesh.numberoflayers):
     72#                       pressureload=[pressureload ;pressureload_layer1(:,1:4)+(i-1)*md.mesh.numberofvertices2d pressureload_layer1(:,5)+(i-1)*md.mesh.numberofelements2d ];
     73                        pressureload=numpy.vstack((pressureload,numpy.hstack((pressureload_layer1[:,0:4]+(i-1)*md.mesh.numberofvertices2d,pressureload_layer1[:,4]+(i-1)*md.mesh.numberofelements2d))))
     74
     75        #Add water or air enum depending on the element
     76#       pressureload=[pressureload 1*md.mask.elementonfloatingice(pressureload(:,end))+ 0*md.mask.elementongroundedice(pressureload(:,end))];
     77        pressureload=numpy.hstack((pressureload,1.*md.mask.elementonfloatingice[pressureload[:,-1].astype('int')-1].reshape(-1,1)+0.*md.mask.elementongroundedice[pressureload[:,-1].astype('int')-1].reshape(-1,1)))
     78
     79        #plug onto model
     80        md.diagnostic.icefront=pressureload
     81
     82        #Create zeros basalforcings and surfaceforcings
     83        if numpy.all(numpy.isnan(md.surfaceforcings.precipitation)) and (md.surfaceforcings.ispdd==1):
     84                md.surfaceforcings.precipitation=numpy.zeros((md.mesh.numberofvertices,1))
     85                print("      no surfaceforcings.precipitation specified: values set as zero")
     86        if numpy.all(numpy.isnan(md.surfaceforcings.mass_balance)) and (md.surfaceforcings.ispdd==0):
     87                md.surfaceforcings.mass_balance=numpy.zeros((md.mesh.numberofvertices,1))
     88                print("      no surfaceforcings.mass_balance specified: values set as zero")
     89        if numpy.all(numpy.isnan(md.basalforcings.melting_rate)):
     90                md.basalforcings.melting_rate=numpy.zeros((md.mesh.numberofvertices,1))
     91                print("      no basalforcings.melting_rate specified: values set as zero")
     92        if numpy.all(numpy.isnan(md.balancethickness.thickening_rate)):
     93                md.balancethickness.thickening_rate=numpy.zeros((md.mesh.numberofvertices,1))
     94                print("      no balancethickness.thickening_rate specified: values set as zero")
     95
     96        md.prognostic.spcthickness=float('nan')*numpy.ones((md.mesh.numberofvertices,1))
     97        md.balancethickness.spcthickness=float('nan')*numpy.ones((md.mesh.numberofvertices,1))
     98
     99        if isinstance(md.initialization.temperature,numpy.ndarray) and numpy.size(md.initialization.temperature,axis=0)==md.mesh.numberofvertices:
     100                md.thermal.spctemperature=float('nan')*numpy.ones((md.mesh.numberofvertices,1))
     101#               pos=find(md.mesh.vertexonsurface); md.thermal.spctemperature(pos)=md.initialization.temperature(pos); %impose observed temperature on surface
     102                pos=numpy.nonzero(md.mesh.vertexonsurface)[0]
     103                md.thermal.spctemperature[pos]=md.initialization.temperature[pos]    #impose observed temperature on surface
     104                if not isinstance(md.basalforcings.geothermalflux,numpy.ndarray) or not numpy.size(md.basalforcings.geothermalflux,axis=0)==md.mesh.numberofvertices:
     105                        md.basalforcings.geothermalflux=numpy.zeros((md.mesh.numberofvertices,1))
     106                        md.basalforcings.geothermalflux[numpy.nonzero(md.mask.vertexongroundedice)]=50.*10.**-3; #50mW/m2
     107        else:
     108                print("      no thermal boundary conditions created: no observed temperature found");
     109
     110        return md
     111
Note: See TracBrowser for help on using the repository browser.