BHAC Python tools
Public Member Functions | Public Attributes | List of all members
read.loadvti Class Reference

Loader class for vti data. More...

Inheritance diagram for read.loadvti:
read.load

Public Member Functions

def __init__ (self, offset, get=1, file='data', mirrorPlane=None, silent=0, rotateX=0, rotateY=0, rotateZ=0, scaleX=1, scaleY=1, scaleZ=1)
 
def getNdim (self)
 
def getX (self)
 
def getY (self)
 
def getZ (self)
 
def getVars (self)
 
def getAll (self)
 
- Public Member Functions inherited from read.load
def __init__ (self, offset, get=1, file='data', type='vtu', mirrorPlane=None, rotateX=0, rotateY=0, rotateZ=0, scaleX=1, scaleY=1, scaleZ=1, silent=0)
 
def getTime (self)
 
def getVar (self, varname)
 
def getData (self)
 
def getPointData (self)
 
def getVars (self)
 
def getVarnames (self)
 
def getBounds (self)
 
def getVert (self, icell)
 
def getPointList (self)
 
def getCenterPoints (self)
 
def getSurface (self)
 
def getPieces (self, nBWidth, nBHeight, nIgnore)
 
def showValues (self, icell)
 
def getIcellByPoint (self, x, y)
 
def getPoints (self)
 
def mirror (self)
 
def reflectVar (self, var)
 
def getNdim (self)
 
def getAll (self)
 

Public Attributes

 offset
 
 filenameout
 
 isLoaded
 
 mirrorPlane
 
 silent
 
 rotateX
 
 rotateY
 
 rotateZ
 
 scaleX
 
 scaleY
 
 scaleZ
 
 filename
 
 datareader
 
 ndim
 
 dx
 
 nx
 
 x
 
 dy
 
 ny
 
 y
 
 dz
 
 nz
 
 z
 
- Public Attributes inherited from read.load
 offset
 
 filenameout
 
 type
 
 isLoaded
 
 mirrorPlane
 
 silent
 
 rotateX
 
 rotateY
 
 rotateZ
 
 scaleX
 
 scaleY
 
 scaleZ
 
 filename
 
 datareader
 
 time
 
 data
 
 ncells
 
 pointdata
 
 xlist
 
 ylist
 
 centerpoints
 
 surface
 
 xBlockList
 
 yBlockList
 
 points
 
 ndim
 

Additional Inherited Members

- Static Public Attributes inherited from read.load
 tend = default_timer()
 self.nblocks = self.data.GetMaximumNumberOfPieces() self.data.SetUpdateNumberOfPieces(self.nblocks) self.xBlockList=[] self.yBlockList=[] More...
 

Detailed Description

Loader class for vti data.

Definition at line 431 of file read.py.

Constructor & Destructor Documentation

◆ __init__()

def read.loadvti.__init__ (   self,
  offset,
  get = 1,
  file = 'data',
  mirrorPlane = None,
  silent = 0,
  rotateX = 0,
  rotateY = 0,
  rotateZ = 0,
  scaleX = 1,
  scaleY = 1,
  scaleZ = 1 
)

Definition at line 434 of file read.py.

434  scaleX=1,scaleY=1,scaleZ=1):
435  self.offset=offset
436  self.filenameout = file
437  self.isLoaded = False
438  self.mirrorPlane=mirrorPlane
439  self.silent = silent
440 
441  self.rotateX = rotateX
442  self.rotateY = rotateY
443  self.rotateZ = rotateZ
444 
445  self.scaleX = scaleX
446  self.scaleY = scaleY
447  self.scaleZ = scaleZ
448 
449  self.filename=''.join([self.filenameout,repr(offset).zfill(4),'.vti'])
450  self.datareader = v.vtkXMLImageDataReader()
451 
452  if (self.silent == 0): print('========================================')
453  if (self.silent == 0): print('loading file %s' % (self.filename))
454 
455  if get != None:
456  self.getAll()
457 

Member Function Documentation

◆ getAll()

def read.loadvti.getAll (   self)

Definition at line 499 of file read.py.

499  def getAll(self):
500  t0 = default_timer()
501 
502  self.getData()
503  tdata = default_timer()
504  if (self.silent == 0): print('Reading data time= %f sec' % (tdata-t0))
505 
506  self.getNdim()
507 
508  self.getX()
509  self.getY()
510  self.getZ()
511 
512  if self.mirrorPlane != None:
513  if (self.silent == 0): print('========== Mirror about plane ',self.mirrorPlane,' ... ============')
514  self.mirror()
515 
516 
517  if (self.silent == 0): print('========== Initializing ... ============')
518 
519 
520  self.getVars()
521  tvars = default_timer()
522  if (self.silent == 0): print('Getting vars time= %f sec' % (tvars-tdata))
523 
524  self.getTime()
525 
526  tend = default_timer()
527  if (self.silent == 0): print('========== Finished loading %d cells in %f sec, have a nice day! ===========' % (self.ncells, (tend-t0) ))
528 
529 #=============================================================================
default_timer
Definition: read.py:14

◆ getNdim()

def read.loadvti.getNdim (   self)

Definition at line 458 of file read.py.

458  def getNdim(self):
459  self.ndim = 3
460  if self.data.GetExtent()[1] - self.data.GetExtent()[0] == 0.:
461  self.ndim=self.ndim - 1
462  if self.data.GetExtent()[3] - self.data.GetExtent()[2] == 0.:
463  self.ndim=self.ndim - 1
464  if self.data.GetExtent()[5] - self.data.GetExtent()[4] == 0.:
465  self.ndim=self.ndim - 1
466  return self.ndim
467 

◆ getVars()

def read.loadvti.getVars (   self)

Definition at line 484 of file read.py.

484  def getVars(self):
485  nvars= self.data.GetCellData().GetNumberOfArrays()
486  for i in range(nvars):
487  varname = self.data.GetCellData().GetArrayName(i)
488  if (self.silent == 0): print("Assigning variable:", varname)
489  # vtk_values = self.pointdata.GetPointData().GetArray(varname)
490  vtk_values = self.data.GetCellData().GetArray(varname)
491  if self.getNdim() == 1:
492  exec("self.%s = ah.vtk2array(vtk_values)[0:self.ncells].reshape((self.nx),order='F')" % (varname))
493  if self.getNdim() == 2:
494  exec("self.%s = ah.vtk2array(vtk_values)[0:self.ncells].reshape((self.nx,self.ny),order='F')" % (varname))
495  if self.getNdim() == 3:
496  exec("self.%s = ah.vtk2array(vtk_values)[0:self.ncells].reshape((self.nx,self.ny,self.nz),order='F')" % (varname))
497 
498 

◆ getX()

def read.loadvti.getX (   self)

Definition at line 468 of file read.py.

468  def getX(self):
469  self.dx=self.data.GetSpacing()[0]
470  self.nx=self.data.GetExtent()[1]-self.data.GetExtent()[0]
471  self.x=self.data.GetOrigin()[0] + np.arange(self.data.GetExtent()[0],self.data.GetExtent()[1])*self.dx+self.dx/2.
472 

◆ getY()

def read.loadvti.getY (   self)

Definition at line 473 of file read.py.

473  def getY(self):
474  self.dy=self.data.GetSpacing()[1]
475  self.ny=self.data.GetExtent()[3]-self.data.GetExtent()[2]
476  self.y=self.data.GetOrigin()[1] + np.arange(self.data.GetExtent()[2],self.data.GetExtent()[3])*self.dy+self.dy/2.
477 

◆ getZ()

def read.loadvti.getZ (   self)

Definition at line 478 of file read.py.

478  def getZ(self):
479  self.dz=self.data.GetSpacing()[2]
480  self.nz=self.data.GetExtent()[5]-self.data.GetExtent()[4]
481  self.z=self.data.GetOrigin()[2] + np.arange(self.data.GetExtent()[4],self.data.GetExtent()[5])*self.dz+self.dz/2.
482 
483 

Member Data Documentation

◆ datareader

read.loadvti.datareader

Definition at line 450 of file read.py.

◆ dx

read.loadvti.dx

Definition at line 469 of file read.py.

◆ dy

read.loadvti.dy

Definition at line 474 of file read.py.

◆ dz

read.loadvti.dz

Definition at line 479 of file read.py.

◆ filename

read.loadvti.filename

Definition at line 449 of file read.py.

◆ filenameout

read.loadvti.filenameout

Definition at line 436 of file read.py.

◆ isLoaded

read.loadvti.isLoaded

Definition at line 437 of file read.py.

◆ mirrorPlane

read.loadvti.mirrorPlane

Definition at line 438 of file read.py.

◆ ndim

read.loadvti.ndim

Definition at line 459 of file read.py.

◆ nx

read.loadvti.nx

Definition at line 470 of file read.py.

◆ ny

read.loadvti.ny

Definition at line 475 of file read.py.

◆ nz

read.loadvti.nz

Definition at line 480 of file read.py.

◆ offset

read.loadvti.offset

Definition at line 435 of file read.py.

◆ rotateX

read.loadvti.rotateX

Definition at line 441 of file read.py.

◆ rotateY

read.loadvti.rotateY

Definition at line 442 of file read.py.

◆ rotateZ

read.loadvti.rotateZ

Definition at line 443 of file read.py.

◆ scaleX

read.loadvti.scaleX

Definition at line 445 of file read.py.

◆ scaleY

read.loadvti.scaleY

Definition at line 446 of file read.py.

◆ scaleZ

read.loadvti.scaleZ

Definition at line 447 of file read.py.

◆ silent

read.loadvti.silent

Definition at line 439 of file read.py.

◆ x

read.loadvti.x

Definition at line 471 of file read.py.

◆ y

read.loadvti.y

Definition at line 476 of file read.py.

◆ z

read.loadvti.z

Definition at line 481 of file read.py.


The documentation for this class was generated from the following file: