Load binary particles data.
More...
Load binary particles data.
Definition at line 590 of file read.py.
◆ __init__()
def read.particles.__init__ |
( |
|
self, |
|
|
|
offset, |
|
|
|
file = 'data' , |
|
|
|
components = 3 |
|
) |
| |
Definition at line 592 of file read.py.
592 def __init__(self,offset,file='data',components=3):
594 self.filenameout = file
595 self.isLoaded =
False 596 self.components = components
599 self.mynparticles = 0
def __init__(self, offset, file='data', headersize=256, nvars=8)
◆ closefile()
def read.particles.closefile |
( |
|
self | ) |
|
Definition at line 616 of file read.py.
618 self.isLoaded =
False
◆ get_sorted()
def read.particles.get_sorted |
( |
|
self, |
|
|
|
i |
|
) |
| |
Definition at line 675 of file read.py.
675 def get_sorted(self,i):
678 except AttributeError:
679 self.index=np.array(self.nparticles)
681 for particle
in self.data:
682 index.append(particle[
'index'])
683 index=np.array(index)
684 self.sorted=index.argsort()
685 return self.sorted[i-1]
◆ makefilename()
def read.particles.makefilename |
( |
|
self | ) |
|
Definition at line 607 of file read.py.
607 def makefilename(self):
608 self.filename = self.filenameout+
'_particles'+str(self.offset).zfill(4)+
'.dat'
◆ openfile()
def read.particles.openfile |
( |
|
self | ) |
|
Definition at line 611 of file read.py.
612 self.file = open(self.filename,
'rb')
◆ particle()
def read.particles.particle |
( |
|
self, |
|
|
|
index |
|
) |
| |
Definition at line 668 of file read.py.
668 def particle(self,index):
669 for particle
in self.data:
670 if particle[
'index'] == index :
◆ read()
def read.particles.read |
( |
|
self | ) |
|
Definition at line 662 of file read.py.
664 while (self.mynparticles < self.nparticles):
665 self.read_next_particle()
◆ read_next_particle()
def read.particles.read_next_particle |
( |
|
self | ) |
|
Definition at line 628 of file read.py.
628 def read_next_particle(self):
629 x = np.empty(self.components)
630 u = np.empty(self.components)
631 payload = np.empty(self.npayload)
633 (index,) = struct.unpack(
'i',self.file.
read(4))
635 (ifollow,) = struct.unpack(
'i',self.file.
read(4))
641 (q,) = struct.unpack(
'd',self.file.
read(8))
642 (m,) = struct.unpack(
'd',self.file.
read(8))
643 (t,) = struct.unpack(
'd',self.file.
read(8))
644 (dt,) = struct.unpack(
'd',self.file.
read(8))
646 for icomp
in range(self.components):
647 (x[icomp],) = struct.unpack(
'd',self.file.
read(8))
649 for icomp
in range(self.components):
650 (u[icomp],) = struct.unpack(
'd',self.file.
read(8))
652 for ipayload
in range(self.npayload):
653 (payload[ipayload],) = struct.unpack(
'd',self.file.
read(8))
655 self.data.append({
'index':index,
'q':q,
656 'follow':follow,
'm':m,
't':t,
657 'dt':dt,
'x':x,
'u':u, 'payload':payload})
659 self.mynparticles= self.mynparticles + 1
◆ readheader()
def read.particles.readheader |
( |
|
self | ) |
|
Definition at line 621 of file read.py.
621 def readheader(self):
623 (self.nparticles,) = struct.unpack(
'i',self.file.
read(4))
624 (self.itparticles,) = struct.unpack(
'i',self.file.
read(4))
625 (self.npayload,) = struct.unpack(
'i',self.file.
read(4))
◆ components
read.particles.components |
◆ data
◆ file
◆ filename
◆ filenameout
read.particles.filenameout |
◆ index
◆ isLoaded
◆ mynparticles
read.particles.mynparticles |
◆ offset
◆ sorted
The documentation for this class was generated from the following file: