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

Load 1D comma separated list from a cut. More...

Public Member Functions

def __init__ (self, offset, get=1, file='data', dir=1, coord=0., silent=0)
 
def makefilename (self)
 
def getHeader (self)
 
def getAll (self)
 
def getData (self)
 

Public Attributes

 silent
 
 offset
 
 filenameout
 
 coord
 
 dir
 
 isLoaded
 
 filename
 
 header
 
 file
 

Detailed Description

Load 1D comma separated list from a cut.

Definition at line 531 of file read.py.

Constructor & Destructor Documentation

◆ __init__()

def read.loadcsv.__init__ (   self,
  offset,
  get = 1,
  file = 'data',
  dir = 1,
  coord = 0.,
  silent = 0 
)

Definition at line 532 of file read.py.

532  def __init__(self,offset,get=1,file='data',dir=1,coord=0.,silent=0):
533  self.silent = silent
534  self.offset=offset
535  self.filenameout = file
536  self.coord = coord
537  self.dir = dir
538  self.isLoaded = False
539  self.makefilename()
540 
541  if (self.silent == 0): print('========================================')
542  if (self.silent == 0): print('loading file %s' % (self.filename))
543 
544  if get != None:
545  self.getAll()
546 
547 
def __init__(self, offset, file='data', headersize=256, nvars=8)
Definition: read.py:752

Member Function Documentation

◆ getAll()

def read.loadcsv.getAll (   self)

Definition at line 570 of file read.py.

570  def getAll(self):
571  t0 = default_timer()
572  self.file = open(self.filename, 'r')
573  if (self.silent == 0): print('========== Initializing ... ============')
574  self.getHeader()
575  self.getData()
576  self.file.close()
577  tdata = default_timer()
578  if (self.silent == 0): print('Reading data time= %f sec' % (tdata-t0))
579 
580 
default_timer
Definition: read.py:14

◆ getData()

def read.loadcsv.getData (   self)

Definition at line 581 of file read.py.

581  def getData(self):
582  i=0
583  for var in self.header:
584  exec("self.%s = pylabload(self.filename,usecols=[i],skiprows=1, delimiter=',')" % (var))
585  i=i+1
586  exec("self.ncells = len(self.%s)" % (self.getHeader()[0]))
587 
588 #=============================================================================

◆ getHeader()

def read.loadcsv.getHeader (   self)

Definition at line 562 of file read.py.

562  def getHeader(self):
563  self.file.seek(0)
564  self.header=self.file.readline().split(',')
565  self.header[-1]=self.header[-1].rstrip('\n')
566 
567  return self.header
568 
569 

◆ makefilename()

def read.loadcsv.makefilename (   self)

Definition at line 548 of file read.py.

548  def makefilename(self):
549  number='%+.2e' % self.coord
550  if self.coord >= 0. and abs(self.coord) >1.:
551  self.filename = self.filenameout+'_d'+str(self.dir)+'_x+'+'0.'+number[1]+number[3]+'D+'+str(int(np.log10(abs(self.coord)))+1).zfill(2)+'_n'+str(self.offset).zfill(4)+'.csv'
552  if self.coord < 0. and abs(self.coord) >1.:
553  self.filename = self.filenameout+'_d'+str(self.dir)+'_x-'+'0.'+number[1]+number[3]+'D+'+str(int(np.log10(abs(self.coord)))+1).zfill(2)+'_n'+str(self.offset).zfill(4)+'.csv'
554  if self.coord > 0. and abs(self.coord) <=1.:
555  self.filename = self.filenameout+'_d'+str(self.dir)+'_x+'+'0.'+number[1]+number[3]+'D+'+str(int(np.log10(abs(self.coord)))).zfill(2)+'_n'+str(self.offset).zfill(4)+'.csv'
556  if self.coord < 0. and abs(self.coord) <=1.:
557  self.filename = self.filenameout+'_d'+str(self.dir)+'_x-'+'0.'+number[1]+number[3]+'D+'+str(int(np.log10(abs(self.coord)))).zfill(2)+'_n'+str(self.offset).zfill(4)+'.csv'
558  if self.coord == 0.:
559  self.filename = self.filenameout+'_d'+str(self.dir)+'_x+'+'0.'+number[1]+number[3]+'D+'+str(0).zfill(2)+'_n'+str(self.offset).zfill(4)+'.csv'
560 
561 

Member Data Documentation

◆ coord

read.loadcsv.coord

Definition at line 536 of file read.py.

◆ dir

read.loadcsv.dir

Definition at line 537 of file read.py.

◆ file

read.loadcsv.file

Definition at line 572 of file read.py.

◆ filename

read.loadcsv.filename

Definition at line 551 of file read.py.

◆ filenameout

read.loadcsv.filenameout

Definition at line 535 of file read.py.

◆ header

read.loadcsv.header

Definition at line 564 of file read.py.

◆ isLoaded

read.loadcsv.isLoaded

Definition at line 538 of file read.py.

◆ offset

read.loadcsv.offset

Definition at line 534 of file read.py.

◆ silent

read.loadcsv.silent

Definition at line 533 of file read.py.


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