예제 #1
0
   def castHistoryAtPoints(self,whatVARS,whatTIME,whatPOINTS):

      # ~~> Extract data
      # whatVARS: list of pairs variables:support delimited by ';' (/!\ support is ignored)
      vars = subsetVariablesSLF(whatVARS,self.VARNAMES)
      # whatTIME: list of frames or (times,) delimited by ';'
      t = parseArrayFrame(whatTIME,len(self.tags['cores']))
      # whatPOINTS: could be list delimited by ';', of:
      #    + points (x;y),
      #    + 2D points (x;y) bundled within (x;y)#n or (x;y)@d#n, delimited by ';'
      #      where n is a plan number and d is depth from that plane (or the surface by default)
      support2d = []; zps = []
      pAP = parseArrayPoint(whatPOINTS,self.NPLAN)
      for xyi,zpi in pAP:
         if type(xyi) == type(()): support2d.append( xysLocateMesh(xyi,self.IKLE2,self.MESHX,self.MESHY,self.tree,self.neighbours) )
         else: support2d.append( xyi )
         zps.append( zpi )
      support3d = zip(support2d,zps)
      # - support2d[i][0] is either the node or the triplet of nodes for each element including (x,y)
      # - support2d[i][1] is the plan or depth definition
      data = getValueHistorySLF(self.file,self.tags,t,support3d,self.NVAR,self.NPOIN3,self.NPLAN,vars)

      # ~~> Draw/Dump data
      return ('Time (s)',self.tags['times'][t]), \
         [('',[n.replace(' ','_').replace(',',';') for n in vars[1]],[(str(n[0])+':'+str(m)).replace(' ','').replace(',',';') for n in pAP for m in n[1]],data)]
예제 #2
0
    slfFile = options.args[2]
    if not path.exists(cliFile):
        print '... the provided slfFile does not seem to exist: ' + slfFile + '\n\n'
        sys.exit(1)
    slf = SELAFIN(slfFile)
    slf.setKDTree()
    slf.setMPLTri()

    print '   +> support extraction'
    # Extract triangles and weigths in 2D
    support2d = []
    ibar = 0
    pbar = ProgressBar(maxval=len(xys)).start()
    for xyi in xys:
        support2d.append(
            xysLocateMesh(xyi, slf.IKLE2, slf.MESHX, slf.MESHY, slf.tree,
                          slf.neighbours))
        ibar += 1
        pbar.update(ibar)
    pbar.finish()
    # Extract support in 3D
    support3d = zip(support2d, len(xys) * [range(slf.NPLAN)])

    # <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
    # ~~~~ writes BND header ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

    bndFile = options.args[3]
    bnd = SELAFIN('')
    bnd.fole = {}
    bnd.fole.update({'hook': open(bndFile, 'wb')})
    bnd.fole.update({'name': bndFile})
    bnd.fole.update({'endian': ">"})  # big endian
예제 #3
0
# <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
# ~~~~ slf existing res ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   slfFile = options.args[1]
   if not path.exists(slfFile):
      print '... the provided geoFile does not seem to exist: '+slfFile+'\n\n'
      sys.exit(1)
   slf = SELAFIN(slfFile)
   slf.setKDTree()
   slf.setMPLTri()

   print '   +> support extraction'
   # Extract triangles and weights in 2D
   support2d = []
   ibar = 0; pbar = ProgressBar(maxval=len(xys)).start()
   for xyi in xys:
      support2d.append(xysLocateMesh(xyi,slf.IKLE2,slf.MESHX,slf.MESHY,slf.tree,slf.neighbours))
      ibar+=1
      pbar.update(ibar)
   pbar.finish()
   # Extract support in 3D
   support3d = zip(support2d,len(xys)*[range(slf.NPLAN)])

# <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
# ~~~~ writes INI header ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

   iniFile = options.args[2]
   ini = SELAFIN('')
   ini.fole = {}
   ini.fole.update({ 'hook': open(iniFile,'wb') })
   ini.fole.update({ 'name': iniFile})
   ini.fole.update({ 'endian': ">" })     # big endian
예제 #4
0
   def get3D(self,typl,what):
      obj = self.object[what['file']]

      if 'SELAFIN' in typl.upper() or \
         'slf' in typl.lower():
         ftype,fsize = obj.file['float']

         # TODO: range of plans and resample within a 2d and a 3d box.
         if what['type'].split(':')[1] == 'i-surface':

            # ~~> Extract data
            IKLE2 = obj.IKLE2
            IKLE3 = obj.IKLE3
            MESHX = np.tile(obj.MESHX,obj.NPLAN)
            MESHY = np.tile(obj.MESHY,obj.NPLAN)
            IKLE4 = IKLE3
            MESHZ = obj.castVMeshAtLevels(what["time"],what["extract"])[3].ravel()
            tree = obj.tree
            tria = obj.neighbours

            # ~~> Possible re-sampling
            if what["sample"] != '':
               support2d = []
               # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
               # ~~> Spatial 2D
               supMESHX = MESHX[0:obj.NPOIN2]; supMESHY = MESHY[0:obj.NPOIN2]
               MESHX = []; MESHY = []
               IKLE4 = []; support2d = []
               grids,plans = whatSample(what["sample"],[(min(supMESHX),min(supMESHY)),(max(supMESHX),max(supMESHY)),[0,obj.NPLAN]])
               if len(plans) < 2:
                  print '... you have to have more than one plan in '+what["sample"]+' for the smapling of a 3d volume'
                  sys.exit(1)
               for dimx,dimy,x,y in grids:
                  for xyi in np.dstack((x,y))[0]:
                     support2d.append( xysLocateMesh(xyi,IKLE2,supMESHX,supMESHY,tree,tria) )
                  IKLE4.extend((
                     [ i+j*dimx+k*dimx*dimy,i+1+j*dimx+k*dimx*dimy,i+1+(j+1)*dimx+k*dimx*dimy,i+(j+1)*dimx+k*dimx*dimy,
                     i+j*dimx+(k+1)*dimx*dimy,i+1+j*dimx+(k+1)*dimx*dimy,i+1+(j+1)*dimx+(k+1)*dimx*dimy,i+(j+1)*dimx+(k+1)*dimx*dimy ]
                     for k in range(len(plans)-1) for j in range(dimy-1) for i in range(dimx-1) ))
                  MESHX.extend(( x for k in range(len(plans)) ))
                  MESHY.extend(( y for k in range(len(plans)) ))
               IKLE4 = np.asarray(IKLE4)
               MESHX = np.asarray(MESHX)
               MESHY = np.asarray(MESHY)
               # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
               # ~~> Vertical component
               if fsize == 4: data = np.zeros((len(plans),len(support2d)),dtype=np.float32)
               else: data = np.zeros((len(plans),len(support2d)),dtype=np.float64)
               for ipt in range(len(support2d)):
                  ln,bn = support2d[ipt]
                  for inod in range(len(bn)):  # /!\ node could be outside domain
                     for iplan in range(len(plans)):
                        if ln[inod] >=0: data[iplan][ipt] += bn[inod]*MESHZ[iplan][ln[inod]]
               MESHZ = data.ravel()

            # ~~> Loop on variables
            for var in what["vars"].split(';'):
               v,vtype = var.split(':')

               # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
               # ~~> Extract variable data for only one time frame and one plane
               VARSORS = obj.castValues(v,what['time'])
               # ~~> Draw/Dump (multiple options possible)
               if "wire" in vtype or "grid" in vtype:
                  self.obdata[what["xref"]] = Values({'type':what['type'],
                     'unit':'wire', 'support':np.dstack((MESHX[IKLE4],MESHY[IKLE4],MESHZ[IKLE4])),
                     'function':'none', 'values':[] })
                  return self.obdata[what["xref"]]
               if "mesh" in vtype:
                  self.obdata[what["xref"]] = Values({'type':what['type'],
                     'unit':'wire', 'support':np.dstack((MESHX[IKLE4],MESHY[IKLE4],MESHZ[IKLE4])),
                     'function':'none', 'values':[] })
                  return self.obdata[what["xref"]]
               if "map" in vtype or "label" in vtype or "contour" in vtype:
                  self.obdata[what["xref"]] = Values({'type':what['type'],
                     'unit':'map', 'support':(MESHX,MESHY,MESHZ,IKLE4),
                     'function':'none', 'values':VARSORS })
                  return self.obdata[what["xref"]]
               elif "arrow" in vtype or "vector" in vtype or "angle" in vtype or "streamline" in vtype:
                  self.obdata[what["xref"]] = Values({'type':what['type'],
                     'unit':'vector', 'support':(MESHX,MESHY,MESHZ,IKLE4),
                     'function':'none', 'values':VARSORS })
                  return self.obdata[what["xref"]]
               else: print '... do not know how to draw this SELAFIN type: ' + vtype

         elif what['type'].split(':')[1] == 'p-section':

            # ~~> Extract data
            IKLE3,MESHX,MESHY,zpo = obj.castHMeshAtLevels(what['extract'])
            if obj.NDP2 == 4: IKLE3 = splitQuad2Triangle(IKLE3)
            IKLE4 = IKLE3
            vars,vtypes = whatVarsSLF(what['vars'],obj.VARNAMES)
            tree = obj.tree
            tria = obj.neighbours

            MESHZ = obj.castVMeshAtLevels(what["time"],what["extract"])[3].ravel()

            # ~~> Possible re-sampling
            support2d = []
            if what["sample"] != '':
               supMESHX = MESHX; supMESHY = MESHY
               MESHX = []; MESHY = []
               IKLE4 = []
               grids,n = whatSample(what["sample"],[(min(supMESHX),min(supMESHY)),(max(supMESHX),max(supMESHY))])
               for dimx,dimy,x,y in grids:
                  for xyi in np.dstack((x,y))[0]:
                     support2d.append( xysLocateMesh(xyi,IKLE3,supMESHX,supMESHY,tree,tria) )
                  IKLE4.extend(([ i+j*dimx,i+1+j*dimx,i+1+(j+1)*dimx,i+(j+1)*dimx ] for j in range(dimy-1) for i in range(dimx-1) ))
                  MESHX.extend(x)
                  MESHY.extend(y)
               IKLE4 = np.asarray(IKLE4)
               IKLE3 = splitQuad2Triangle(IKLE4)
               MESHX = np.asarray(MESHX)
               MESHY = np.asarray(MESHY)

            # ~~> Loop on variables
            for var in what["vars"].split(';'):
               v,vtype = var.split(':')

               # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
               # ~~> Extract variable data for only one time frame and one plane
               VARSORS = obj.castHValueAtLevels(v,what['time'],what['extract'])
               # ~~> Re-sampling
               if support2d != []:
                  if fsize == 4: data = np.zeros((len(vars[0]),len(support2d)),dtype=np.float32)
                  else: data = np.zeros((len(vars[0]),len(support2d)),dtype=np.float64)
                  for ivar in range(len(vars[0])):
                     for ipt in range(len(support2d)):
                        ln,bn = support2d[ipt]
                        data[ivar][ipt] = 0.0
                        for inod in range(len(bn)):                  # /!\ node could be outside domain
                           if ln[inod] >=0: data[ivar][ipt] += bn[inod]*VARSORS[ivar][ln[inod]]
                  VARSORS = data
                  supMESHZ = MESHZ
                  if fsize == 4: MESHZ = np.zeros(len(support2d),dtype=np.float32)
                  else: MESHZ = np.zeros(len(support2d),dtype=np.float64)
                  for ipt in range(len(support2d)):
                     ln,bn = support2d[ipt]
                     MESHZ[ipt] = 0.0
                     for inod in range(len(bn)):                  # /!\ node could be outside domain
                        if ln[inod] >=0: MESHZ[ipt] += bn[inod]*supMESHZ[ln[inod]]
               # ~~> Draw/Dump (multiple options possible)
               if "map" in vtype or "label" in vtype:
                  self.obdata[what["xref"]] = Values({'type':what['type'],
                     'unit':'map', 'support':(MESHX,MESHY,MESHZ,IKLE3),
                     'function':'none', 'values':VARSORS })
                  return self.obdata[what["xref"]]
                  # return (MESHX,MESHY,MESHZ,IKLE3),VARSORS
               elif "arrow" in vtype or "vector" in vtype or "angle" in vtype:
                  self.obdata[what["xref"]] = Values({'type':what['type'],
                     'unit':'vector', 'support':(MESHX,MESHY,MESHZ,IKLE3),
                     'function':'none', 'values':VARSORS })
                  return self.obdata[what["xref"]]
                  # return (MESHX,MESHY,MESHZ,IKLE3),VARSORS
               else: print '... do not know how to draw this SELAFIN type: ' + vtype

         elif what['type'].split(':')[1] == 'v-section':

            # ~~> Extract data
            IKLE4,MESHX,MESHY,MESHZ, support3d = obj.castVMeshAtPolyline_Plane(what["time"],what["extract"])

            # split each quad into triangles
            IKLE3 = splitQuad2Triangle(IKLE4)
            vars,vtypes = whatVarsSLF(what['vars'],obj.VARNAMES)
            time = whatTimeSLF(what['time'],obj.tags['cores'])
            tree = getKDTree(MESHX,MESHZ,IKLE3)
            tria = getMPLTri(MESHX,MESHZ,IKLE3)[0]
            data = getValuePolylineSLF(obj.file,obj.tags,time,support3d,obj.NVAR,obj.NPOIN3,obj.NPLAN,vars)

            # ~~> Possible sampling of the data
            # No resampling yet

            # ~~> Loop on variables
            for v,vtype in zip(vars,vtypes):

               VARSORS = []
               for ivar in range(len(vars[0])): VARSORS.append( np.ravel(data[ivar][0].T) )

               # ~~> Re-sampling
               # No resampling yet

               # ~~> Draw/Dump (multiple options possible)
               if "map" in vtype or "label" in vtype:
                  self.obdata[what["xref"]] = Values({'type':what['type'],
                     'unit':'map', 'support':(MESHX,MESHY,MESHZ,IKLE3),
                     'function':'none', 'values':VARSORS })
                  return self.obdata[what["xref"]]
                  # return (MESHX,MESHZ,IKLE3),VARSORS
               if "arrow" in vtype or "vector" in vtype or "angle" in vtype:
                  self.obdata[what["xref"]] = Values({'type':what['type'],
                     'unit':'vector', 'support':(MESHX,MESHY,MESHZ,IKLE3),
                     'function':'none', 'values':VARSORS })
                  return self.obdata[what["xref"]]
                  # return (MESHX,MESHZ,IKLE3),VARSORS

         elif what['type'].split(':')[1] == '':

            # ~~> Extract data
            IKLE3 = obj.IKLE3
            MESHX = obj.MESHX
            MESHY = obj.MESHY
            if obj.NDP2 == 4: IKLE3 = splitQuad2Triangle(IKLE3)
            IKLE4 = IKLE3
            vars,vtypes = whatVarsSLF(what['vars'],obj.VARNAMES)
            tree = obj.tree
            tria = obj.neighbours

            # ~~> Possible re-sampling
            support2d = []
            #if what["sample"] != '':
            #   supMESHX = MESHX; supMESHY = MESHY
            #   MESHX = []; MESHY = []
            #   IKLE4 = []; support2d = []
            #   grids,n = whatSample(what["sample"],[(min(supMESHX),min(supMESHY)),(max(supMESHX),max(supMESHY))])
            #   for dimx,dimy,x,y in grids:
            #      for xyi in np.dstack((x,y))[0]:
            #         support2d.append( xysLocateMesh(xyi,IKLE3,supMESHX,supMESHY,tree,tria) )
            #      IKLE4.extend(([ i+j*dimx,i+1+j*dimx,i+1+(j+1)*dimx,i+(j+1)*dimx ] for j in range(dimy-1) for i in range(dimx-1) ))
            #      MESHX.extend(x)
            #      MESHY.extend(y)
            #   IKLE4 = np.asarray(IKLE4)
            #   IKLE3 = splitQuad2Triangle(IKLE4)
            #   MESHX = np.asarray(MESHX)
            #   MESHY = np.asarray(MESHY)

            # ~~> Loop on variables
            for var in what["vars"].split(';'):
               v,vtype = var.split(':')

               # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
               # ~~> Extract variable data for only one plane
               VARSORS = obj.castValues(v,what['time'])
               # ~~> Re-sampling
               if support2d != []:
                  if fsize == 4: data = np.zeros(VARSORS.shape,dtype=np.float32)
                  else: data = np.zeros(VARSORS.shape,dtype=np.float64)
                  for itime in range(len(VARSORS)):
                     for ivar in range(len(vars[0])):
                        for ipt in range(len(support2d)):
                           ln,bn = support2d[ipt]
                           for inod in range(len(bn)):                  # /!\ node could be outside domain
                              if ln[inod] >=0: data[itime][ivar][ipt] += bn[inod]*VARSORS[itime][ivar][ln[inod]]
                  VARSORS = data
               # ~~> Draw/Dump (multiple options possible)
               if "wire" in vtype or "grid" in vtype:
                  self.obdata[what["xref"]] = Values({'type':what['type'],
                     'unit':'wire', 'support':np.dstack((MESHX[IKLE4],MESHY[IKLE4])),
                     'function':'none', 'values':[] })
                  return self.obdata[what["xref"]]
                  # return np.dstack((MESHX[IKLE4],MESHY[IKLE4]))
               if "mesh" in vtype:
                  self.obdata[what["xref"]] = Values({'type':what['type'],
                     'unit':'wire', 'support':np.dstack((MESHX[IKLE3],MESHY[IKLE3])),
                     'function':'none', 'values':[] })
                  return self.obdata[what["xref"]]
                  # return np.dstack((MESHX[IKLE3],MESHY[IKLE3]))
               if "map" in vtype or "label" in vtype:
                  self.obdata[what["xref"]] = Values({'type':what['type'],
                     'unit':'map', 'support':(MESHX,MESHY,IKLE3),
                     'function':'none', 'values':VARSORS })
                  return self.obdata[what["xref"]]
                  # return (MESHX,MESHY,IKLE3),VARSORS
               elif "arrow" in vtype or "vector" in vtype or "angle" in vtype:
                  self.obdata[what["xref"]] = Values({'type':what['type'],
                     'unit':'vector', 'support':(MESHX,MESHY,IKLE3),
                     'function':'none', 'values':VARSORS })
                  return self.obdata[what["xref"]]
                  # return (MESHX,MESHY,IKLE3),VARSORS
               else: print '... do not know how to draw this SELAFIN type: ' + vtype

         # ~~> unknown
         else: # TODO: raise exception
            print '... do not know how to do this type of extraction: ' + what['type'].split(':')[1]

      # ~~> unknown
      else: # TODO: raise exception
         print '... do not know how to extract from this format: ' + typl
예제 #5
0
   def get2D(self,typl,what):
      obj = self.object[what['file']]

      # /!\ WACLEO: Temporary fix because TOMAWAC's IOs names are not yet standard TELEMAC
      if 'WACLEO' in typl.upper() or \
         'SELAFIN' in typl.upper() or \
         'slf' in typl.lower():
         ftype,fsize = obj.file['float']

         if what['type'].split(':')[1] == 'v-section':

            # ~~> Extract data
            IKLE4,MESHX,MESHZ, support3d = obj.castVMeshAtPolyline(what["time"],what["extract"])
            # split each quad into triangles
            IKLE3 = splitQuad2Triangle(IKLE4)
            vars,vtypes = whatVarsSLF(what['vars'],obj.VARNAMES)
            time = whatTimeSLF(what['time'],obj.tags['cores'])
            tree = getKDTree(MESHX,MESHZ,IKLE3)
            tria = getMPLTri(MESHX,MESHZ,IKLE3)[0]
            data = getValuePolylineSLF(obj.file,obj.tags,time,support3d,obj.NVAR,obj.NPOIN3,obj.NPLAN,vars)

            # ~~> Possible sampling of the data
            if what["sample"] != '':
               supMESHX = MESHX; supMESHZ = MESHZ
               MESHX = []; MESHZ = []
               IKLE4 = []; support2d = []
               grids,n = whatSample(what["sample"],[(min(supMESHX),min(supMESHZ)),(max(supMESHX),max(supMESHZ))])
               for dimx,dimy,x,y in grids:
                  for xyi in np.dstack((x,y))[0]:
                     support2d.append( xysLocateMesh(xyi,IKLE3,supMESHX,supMESHZ,tree,tria) )
                  IKLE4.extend(([ i+j*dimx,i+1+j*dimx,i+1+(j+1)*dimx,i+(j+1)*dimx ] for j in range(dimy-1) for i in range(dimx-1) ))
                  MESHX.extend(x)
                  MESHZ.extend(y)
               IKLE4 = np.asarray(IKLE4)
               IKLE3 = splitQuad2Triangle(IKLE4)
               MESHX = np.asarray(MESHX)
               MESHZ = np.asarray(MESHZ)

            # ~~> Loop on variables
            for v,vtype in zip(vars,vtypes):

               VARSORS = []
               for ivar in range(len(vars[0])): VARSORS.append( np.ravel(data[ivar][0].T) )

               # ~~> Re-sampling
               if what["sample"] != '':
                  if fsize == 4: data = np.zeros((len(vars[0]),len(support2d)),dtype=np.float32)
                  else: data = np.zeros((len(vars[0]),len(support2d)),dtype=np.float64)
                  for ivar in range(len(vars[0])):
                     for ipt in range(len(support2d)):
                        ln,bn = support2d[ipt]
                        data[ivar][ipt] = 0.0
                        for inod in range(len(bn)):                  # /!\ node could be outside domain
                           if ln[inod] >=0: data[ivar][ipt] += bn[inod]*VARSORS[ivar][ln[inod]]
                  VARSORS = data

               # ~~> Draw/Dump (multiple options possible)
               if "wire" in vtype or "grid" in vtype:
                  self.obdata[what["xref"]] = Values({'type':what['type'],
                     'unit':'wire', 'support':np.dstack((MESHX[IKLE4],MESHZ[IKLE4])),
                     'function':'none', 'values':[] })
                  return self.obdata[what["xref"]]
                  # return np.dstack((MESHX[IKLE4],MESHZ[IKLE4]))
               if "mesh" in vtype:
                  self.obdata[what["xref"]] = Values({'type':what['type'],
                     'unit':'wire', 'support':np.dstack((MESHX[IKLE3],MESHZ[IKLE3])),
                     'function':'none', 'values':[] })
                  return self.obdata[what["xref"]]
                  # return np.dstack((MESHX[IKLE3],MESHZ[IKLE3]))
               if "map" in vtype or "label" in vtype:
                  self.obdata[what["xref"]] = Values({'type':what['type'],
                     'unit':'map', 'support':(MESHX,MESHZ,IKLE3),
                     'function':'none', 'values':VARSORS })
                  return self.obdata[what["xref"]]
                  # return (MESHX,MESHZ,IKLE3),VARSORS
               if "arrow" in vtype or "vector" in vtype or "angle" in vtype:
                  self.obdata[what["xref"]] = Values({'type':what['type'],
                     'unit':'vector', 'support':(MESHX,MESHZ,IKLE3),
                     'function':'none', 'values':VARSORS })
                  return self.obdata[what["xref"]]
                  # return (MESHX,MESHZ,IKLE3),VARSORS

         elif what['type'].split(':')[1] == 'p-section':

            # ~~> Extract data
            IKLE3,MESHX,MESHY, zpo = obj.castHMeshAtLevels(what['extract'])
            if obj.NDP2 == 4: IKLE3 = splitQuad2Triangle(IKLE3)
            IKLE4 = IKLE3
            vars,vtypes = whatVarsSLF(what['vars'],obj.VARNAMES)
            tree = obj.tree
            tria = obj.neighbours

            # ~~> Possible re-sampling
            support2d = []
            if what["sample"] != '':
               supMESHX = MESHX; supMESHY = MESHY
               MESHX = []; MESHY = []
               IKLE4 = []; support2d = []
               grids,n = whatSample(what["sample"],[(min(supMESHX),min(supMESHY)),(max(supMESHX),max(supMESHY))])
               for dimx,dimy,x,y in grids:
                  for xyi in np.dstack((x,y))[0]:
                     support2d.append( xysLocateMesh(xyi,IKLE3,supMESHX,supMESHY,tree,tria) )
                  IKLE4.extend(([ i+j*dimx,i+1+j*dimx,i+1+(j+1)*dimx,i+(j+1)*dimx ] for j in range(dimy-1) for i in range(dimx-1) ))
                  MESHX.extend(x)
                  MESHY.extend(y)
               IKLE4 = np.asarray(IKLE4)
               IKLE3 = splitQuad2Triangle(IKLE4)
               MESHX = np.asarray(MESHX)
               MESHY = np.asarray(MESHY)

            # ~~> Loop on variables
            for var in what["vars"].split(';'):
               v,vtype = var.split(':')

               # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
               # ~~> Extract variable data for only one time frame and one plane
               VARSORS = obj.castHValueAtLevels(v,what['time'],what['extract'])
               # ~~> Re-sampling
               if support2d != []:
                  if fsize == 4: data = np.zeros((len(vars[0]),len(support2d)),dtype=np.float32)
                  else: data = np.zeros((len(vars[0]),len(support2d)),dtype=np.float64)
                  for ivar in range(len(vars[0])):
                     for ipt in range(len(support2d)):
                        ln,bn = support2d[ipt]
                        data[ivar][ipt] = 0.0
                        for inod in range(len(bn)):                  # /!\ node could be outside domain
                           if ln[inod] >=0: data[ivar][ipt] += bn[inod]*VARSORS[ivar][ln[inod]]
                  VARSORS = data
               # ~~> Draw/Dump (multiple options possible)
               if "wire" in vtype or "grid" in vtype:
                  self.obdata[what["xref"]] = Values({'type':what['type'],
                     'unit':'wire', 'support':np.dstack((MESHX[IKLE4],MESHY[IKLE4])),
                     'function':'none', 'values':[] })
                  return self.obdata[what["xref"]]
                  # return np.dstack((MESHX[IKLE4],MESHY[IKLE4]))
               if "mesh" in vtype:
                  self.obdata[what["xref"]] = Values({'type':what['type'],
                     'unit':'wire', 'support':np.dstack((MESHX[IKLE3],MESHY[IKLE3])),
                     'function':'none', 'values':[] })
                  return self.obdata[what["xref"]]
                  # return np.dstack((MESHX[IKLE3],MESHY[IKLE3]))
               if "map" in vtype or "label" in vtype:
                  self.obdata[what["xref"]] = Values({'type':what['type'],
                     'unit':'map', 'support':(MESHX,MESHY,IKLE3),
                     'function':'none', 'values':VARSORS })
                  return self.obdata[what["xref"]]
                  # return (MESHX,MESHY,IKLE3),VARSORS
               elif "arrow" in vtype or "vector" in vtype or "angle" in vtype:
                  self.obdata[what["xref"]] = Values({'type':what['type'],
                     'unit':'vector', 'support':(MESHX,MESHY,IKLE3),
                     'function':'none', 'values':VARSORS })
                  return self.obdata[what["xref"]]
                  # return (MESHX,MESHY,IKLE3),VARSORS
               else: print '... do not know how to draw this SELAFIN type: ' + vtype

         elif what['type'].split(':')[1] == '':

            # ~~> Extract data
            IKLE3 = obj.IKLE3
            MESHX = obj.MESHX
            MESHY = obj.MESHY
            if obj.NDP2 == 4: IKLE3 = splitQuad2Triangle(IKLE3)
            IKLE4 = IKLE3
            vars,vtypes = whatVarsSLF(what['vars'],obj.VARNAMES)
            tree = obj.tree
            tria = obj.neighbours

            # ~~> Possible re-sampling
            support2d = []
            if what["sample"] != '':
               supMESHX = MESHX; supMESHY = MESHY
               MESHX = []; MESHY = []
               IKLE4 = []; support2d = []
               grids,n = whatSample(what["sample"],[(min(supMESHX),min(supMESHY)),(max(supMESHX),max(supMESHY))])
               for dimx,dimy,x,y in grids:
                  for xyi in np.dstack((x,y))[0]:
                     support2d.append( xysLocateMesh(xyi,IKLE3,supMESHX,supMESHY,tree,tria) )
                  IKLE4.extend(([ i+j*dimx,i+1+j*dimx,i+1+(j+1)*dimx,i+(j+1)*dimx ] for j in range(dimy-1) for i in range(dimx-1) ))
                  MESHX.extend(x)
                  MESHY.extend(y)
               IKLE4 = np.asarray(IKLE4)
               IKLE3 = splitQuad2Triangle(IKLE4)
               MESHX = np.asarray(MESHX)
               MESHY = np.asarray(MESHY)

            # ~~> Loop on variables
            varNames = []
            for var in what["vars"].split(';'):
               v,vtype = var.split(':')
               # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
               # ~~> Extract variable data for only one plane
               VARSORS = obj.castValues(v,what['time'])
               # Get value of the timestep
               time = obj.tags['times'][whatTimeSLF(what['time'],obj.tags['cores'])]
               if v == '':
                  varNames = obj.VARNAMES
               else:
                  varNames.append(v)
               # ~~> Re-sampling
               if support2d != []:
                  if fsize == 4: data = np.zeros(VARSORS.shape,dtype=np.float32)
                  else: data = np.zeros(VARSORS.shape,dtype=np.float64)
                  for itime in range(len(VARSORS)):
                     for ivar in range(len(vars[0])):
                        for ipt in range(len(support2d)):
                           ln,bn = support2d[ipt]
                           for inod in range(len(bn)):                  # /!\ node could be outside domain
                              if ln[inod] >=0: data[itime][ivar][ipt] += bn[inod]*VARSORS[itime][ivar][ln[inod]]
                  VARSORS = data
               # ~~> Draw/Dump (multiple options possible)
               if "wire" in vtype or "grid" in vtype:
                  self.obdata[what["xref"]] = Values({'type':what['type'],
                     'unit':'wire', 'support':np.dstack((MESHX[IKLE4],MESHY[IKLE4])),
                     'function':'none', 'values':[] })
                  return self.obdata[what["xref"]]
                  # return np.dstack((MESHX[IKLE4],MESHY[IKLE4]))
               if "mesh" in vtype:
                  self.obdata[what["xref"]] = Values({'type':what['type'],
                     'unit':'wire', 'support':np.dstack((MESHX[IKLE3],MESHY[IKLE3])),
                     'function':'none', 'values':[] })
                  return self.obdata[what["xref"]]
                  # return np.dstack((MESHX[IKLE3],MESHY[IKLE3]))
               if "map" in vtype or "label" in vtype:
                  self.obdata[what["xref"]] = Values({'type':what['type'],
                     'unit':'map', 'support':(MESHX,MESHY,IKLE3),
                     'function':'none', 'values':VARSORS,'names':varNames,
                     'time':time})
                  return self.obdata[what["xref"]]
                  # return (MESHX,MESHY,IKLE3),VARSORS
               elif "arrow" in vtype or "vector" in vtype or "angle" in vtype:
                  self.obdata[what["xref"]] = Values({'type':what['type'],
                     'unit':'vector', 'support':(MESHX,MESHY,IKLE3),
                     'function':'none', 'values':VARSORS })
                  return self.obdata[what["xref"]]
                  # return (MESHX,MESHY,IKLE3),VARSORS
               else: print '... do not know how to draw this SELAFIN type: ' + vtype
          

         # ~~> unkonwn
         else: # TODO: raise exception
            print '... do not know how to do this type of extraction: ' + what['type'].split(':')[1]

      # ~~> unkonwn
      else: # TODO: raise exception
         print '... do not know how to extract from this format: ' + typl