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

Load particle ensemble .csv files. More...

Public Member Functions

def __init__ (self, offset, file='data0000', npayload=1, components=3, delimiter=')
 
def makefilename (self)
 
def read (self)
 
def particle (self, index)
 

Public Attributes

 offset
 
 filenameout
 
 isLoaded
 
 components
 
 npayload
 
 delimiter
 
 data
 
 filename
 

Detailed Description

Load particle ensemble .csv files.

Definition at line 689 of file read.py.

Constructor & Destructor Documentation

◆ __init__()

def read.ensemble.__init__ (   self,
  offset,
  file = 'data0000',
  npayload = 1,
  components = 3,
  delimiter = ' 
)

Definition at line 691 of file read.py.

691  def __init__(self,offset,file='data0000',npayload=1,components=3,delimiter=','):
692  self.offset=offset
693  self.filenameout = file
694  self.isLoaded = False
695  self.components = components
696  self.npayload = npayload
697  self.delimiter = delimiter
698 
699  self.data=[]
700 
701  self.makefilename()
702  self.read()
703 
704 
def __init__(self, offset, file='data', headersize=256, nvars=8)
Definition: read.py:752

Member Function Documentation

◆ makefilename()

def read.ensemble.makefilename (   self)

Definition at line 705 of file read.py.

705  def makefilename(self):
706  self.filename = self.filenameout+'_ensemble'+str(self.offset).zfill(6)+'.csv'
707 
708 

◆ particle()

def read.ensemble.particle (   self,
  index 
)

Definition at line 743 of file read.py.

743  def particle(self,index):
744  for particle in self.data:
745  if particle['index'] == index :
746  return particle
747  return False
748 #=============================================================================

◆ read()

def read.ensemble.read (   self)

Definition at line 709 of file read.py.

709  def read(self):
710  x = pylabload(self.filename, comments='#', delimiter=self.delimiter)
711 
712  t_ = 0
713  dt_ = 1
714  x1_ = 2
715  u1_ = x1_+self.components
716  payload_ = u1_+self.components
717  ipe_ = payload_+self.npayload
718  iteration_ = ipe_+1
719  index_ = iteration_+1
720 
721  if x.shape[1] == index_+1 :
722 
723  for particle in x:
724  self.data.append({'t':particle[t_],
725  'dt':particle[dt_], 'x':np.array(particle[x1_:x1_+self.components]),
726  'u':np.array(particle[u1_:u1_+self.components]),
727  'payload':np.array(particle[payload_:payload_+self.npayload]),
728  'ipe':particle[ipe_].astype(np.int), 'iteration':particle[iteration_].astype(np.int), 'index':particle[index_].astype(np.int)})
729 
730  else:
731  print('File inconsistent, assuming iteration counter overflow')
732  for particle in x:
733  self.data.append({'t':particle[t_],
734  'dt':particle[dt_], 'x':np.array(particle[x1_:x1_+self.components]),
735  'u':np.array(particle[u1_:u1_+self.components]),
736  'payload':np.array(particle[payload_:payload_+self.npayload]),
737  'garbage':particle[ipe_].astype(np.int), 'index':particle[index_-1].astype(np.int)})
738 
739 
740  self.isLoaded = True
741 
742 
Definition: read.py:1

Member Data Documentation

◆ components

read.ensemble.components

Definition at line 695 of file read.py.

◆ data

read.ensemble.data

Definition at line 699 of file read.py.

◆ delimiter

read.ensemble.delimiter

Definition at line 697 of file read.py.

◆ filename

read.ensemble.filename

Definition at line 706 of file read.py.

◆ filenameout

read.ensemble.filenameout

Definition at line 693 of file read.py.

◆ isLoaded

read.ensemble.isLoaded

Definition at line 694 of file read.py.

◆ npayload

read.ensemble.npayload

Definition at line 696 of file read.py.

◆ offset

read.ensemble.offset

Definition at line 692 of file read.py.


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