Skip to content

Commit

Permalink
add scalar charge and mass information to vsim dumpreader
Browse files Browse the repository at this point in the history
  • Loading branch information
skuschel committed Dec 7, 2014
1 parent ac58217 commit 39d95ab
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions postpic/datareader/vsimhdf5.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,6 @@ def __getitem__(self, key):
return None

def timestep(self):
''' returns the timestem 0.5*DX/c '''
temp = self["compGridGlobal"]
NX = temp.attrs["vsNumCells"][0]
xl = temp.attrs["vsLowerBounds"][0]
Expand Down Expand Up @@ -125,15 +124,24 @@ def getSpecies(self, species, attrib):
'''
Returns one of the attributes out of (x,y,z,px,py,pz,weight,ID) of
this particle species.
Valid Scalar attributes are (mass, charge).
returning None means that this particle property wasnt dumped.
Note that this is different from returning an empty list!
'''
# x, y, z, px, py, pz same as in sdf. weigt and ID not included.
attrib = _const.axesidentify[attrib]
attrib = {0: 0, 1: 1, 2: 2, 3: 3, 4: 4, 5: 5, 9: 6, 10: 7}[attrib]
attrib = _const.attribidentify[attrib]
try:
return np.float64(self[species])[:, attrib]
except:
attrib = {0: 0, 1: 1, 2: 2, 3: 3, 4: 4, 5: 5, 9: 'numPtclsInMacro',
11: 'charge', 12: 'mass'}[attrib]
if isinstance(attrib, int):
ret = np.float64(self[species])[:, attrib]
# VSim dumps gamma*v = p/m0, so multiply by mass if px, or pz requested
if attrib > 2:
ret = ret * self.getSpecies(species, 'mass')
return ret
else:
return np.float64(self[species].attrs[attrib])
except(KeyError):
return None

def getderived(self):
Expand Down

0 comments on commit 39d95ab

Please sign in to comment.