Ejemplo n.º 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)]
Ejemplo n.º 2
0
   def draw(self,type,what,fig):
      
      if 'sortie' in type.lower():
         # ~~> Load data
         sortie = getFileContent(what['file'])
         # ~~> Extract data
         data = getValueHistorySortie(sortie,what['vars'])
         # ~~> Deco
         # ~~> Draw data
         drawHistoryLines(plt,data,deco)

      elif 'SELAFIN' in type.upper():
         # ~~> Load data
         slf = SELAFIN(what['file'])

         if what['type'] == 'history':
            # ~~> Extract data
            vars = subsetVariablesSLF(what["vars"],slf.VARNAMES)
            support = xyLocateMeshSLF(what["extract"],slf.NELEM3,slf.IKLE,slf.MESHX,slf.MESHY)
            data = getValueHistorySLF(slf.file,slf.tags,what['time'],support,slf.TITLE,slf.NVAR,slf.NPOIN3,vars)
            # ~~> Deco
            if what.has_key('roi'):
               if what['roi'] != []: deco['roi'] = what['roi']
            # ~~> Draw data
            drawHistoryLines(plt,data,deco)
            
         elif what['type'] == 'v-section':
            # ~~> Extract data
            vars = subsetVariablesSLF(what["vars"],slf.VARNAMES)
            support = crossLocateMeshSLF(what["extract"],slf.NELEM3,slf.IKLE,slf.MESHX,slf.MESHY)
            data = getValuePolylineSLF(slf.file,slf.tags,what['time'],support,slf.TITLE,slf.NVAR,slf.NPOIN3,vars)
            # ~~> Deco
            deco['roi'] = [ [np.min(slf.MESHX),np.min(slf.MESHY)], [np.max(slf.MESHX),np.max(slf.MESHY)] ]
            if what.has_key('roi'):
               if what['roi'] != []: deco['roi'] = what['roi']
            # ~~> Draw data
            drawPolylineLines(plt,data,deco)

         else: print '... do not know how to draw this type: ' + what['type']

      else:
         print '... do not know how to draw this format: ' + type
Ejemplo n.º 3
0
    print '   +> setting variables'
    # TIME and DATE extraction
    bndDATES = slf.DATETIME
    bndTIMES = slf.tags['times']
    bnd.tags['times'] = slf.tags['times']
    # VARIABLE extraction
    vars = subsetVariablesSLF(
        "ELEVATION Z: ;VELOCITY U: ;VELOCITY V: ;SALINITY: ;TEMPERATURE: ",
        slf.VARNAMES)

    # Read / Write data, one time step at a time to support large files
    print '   +> reading / writing variables'
    pbar = ProgressBar(maxval=len(slf.tags['times'])).start()
    zeros = np.zeros((bnd.NPOIN3, 1), dtype=np.float)
    for t in range(len(slf.tags['times'])):
        data = getValueHistorySLF(slf.file, slf.tags, [t], support3d, slf.NVAR,
                                  slf.NPOIN3, slf.NPLAN, vars)
        # special case for TEMPERATURE and SALINITY
        data[3] = np.maximum(data[3], zeros)
        data[4] = np.maximum(data[4], zeros)
        d = np.reshape(
            np.transpose(
                np.reshape(np.ravel(data), (bnd.NVAR, bnd.NPOIN2, bnd.NPLAN)),
                (0, 2, 1)), (bnd.NVAR, bnd.NPOIN3))
        #for ipoin in range(bnd.NPOIN2):
        #   for iplan in range(bnd.NPLAN-1,0,-1):
        #      for ivar in range(bnd.NVAR)[1:]:  # except for Z
        #         if bat[BOR[ipoin]-1] > d[0][ipoin+(iplan-1)*bnd.NPOIN2]:
        #            d[ivar][ipoin+(iplan-1)*bnd.NPOIN2] = d[ivar][ipoin+iplan*bnd.NPOIN2]
        #      if d[3][ipoin+(iplan-1)*bnd.NPOIN2] < 28.0:
        #         d[3][ipoin+(iplan-1)*bnd.NPOIN2] = max(d[3][ipoin+iplan*bnd.NPOIN2],28.0)
        bnd.appendCoreTimeSLF(t)