aboutsummaryrefslogtreecommitdiff
path: root/Examples/Tests/Larmor/plot_particle_path.py
diff options
context:
space:
mode:
authorGravatar Tools <warpx@lbl.gov> 2019-09-11 10:06:14 -0700
committerGravatar Axel Huebl <axel.huebl@plasma.ninja> 2019-09-11 10:12:00 -0700
commitfd848331f2fd6af8c56a0027cc5f088286e347c4 (patch)
tree9f81ea5e8475ab5bd1e769d7865fc7fd492d06eb /Examples/Tests/Larmor/plot_particle_path.py
parentf182366aaf66a770715b144ac0a760a998f59ed4 (diff)
downloadWarpX-fd848331f2fd6af8c56a0027cc5f088286e347c4.tar.gz
WarpX-fd848331f2fd6af8c56a0027cc5f088286e347c4.tar.zst
WarpX-fd848331f2fd6af8c56a0027cc5f088286e347c4.zip
Source & Tools: No EOL Whitespaces
End-of-line (EOL) whitespaces are verbose and increase diffs and merge conflicts over time. Cleaned them up for the `Source/`, `Examples/` and `Tools/` directory with the following bash one-liner: ```bash find . -type f -not -path './.git*' \ -exec sed -i 's/[[:blank:]]*$//' {} \; ``` Committed as generic user so git does not credit the many lines to me: ```bash GIT_AUTHOR_NAME="Tools" GIT_AUTHOR_EMAIL="warpx@lbl.gov" \ git commit ```
Diffstat (limited to 'Examples/Tests/Larmor/plot_particle_path.py')
-rw-r--r--Examples/Tests/Larmor/plot_particle_path.py24
1 files changed, 12 insertions, 12 deletions
diff --git a/Examples/Tests/Larmor/plot_particle_path.py b/Examples/Tests/Larmor/plot_particle_path.py
index 0a9e965e7..ef52b4f4b 100644
--- a/Examples/Tests/Larmor/plot_particle_path.py
+++ b/Examples/Tests/Larmor/plot_particle_path.py
@@ -3,8 +3,8 @@ import numpy as np
class AMReXParticleHeader(object):
'''
- This class is designed to parse and store the information
- contained in an AMReX particle header file.
+ This class is designed to parse and store the information
+ contained in an AMReX particle header file.
Usage:
@@ -66,11 +66,11 @@ class AMReXParticleHeader(object):
entry = [int(val) for val in f.readline().strip().split()]
self.grids[level_num].append(tuple(entry))
-
+
def read_particle_data(fn, ptype="particle0"):
'''
- This function returns the particle data stored in a particular
+ This function returns the particle data stored in a particular
plot file and particle type. It returns two numpy arrays, the
first containing the particle integer data, and the second the
particle real data. For example, if a dataset has 3000 particles,
@@ -79,22 +79,22 @@ def read_particle_data(fn, ptype="particle0"):
with the shape (3000, 5).
Usage:
-
+
idata, rdata = read_particle_data("plt00000", "particle0")
'''
base_fn = fn + "/" + ptype
header = AMReXParticleHeader(base_fn + "/Header")
-
- idtype = "(%d,)i4" % header.num_int
+
+ idtype = "(%d,)i4" % header.num_int
if header.real_type == np.float64:
fdtype = "(%d,)f8" % header.num_real
elif header.real_type == np.float32:
fdtype = "(%d,)f4" % header.num_real
-
+
idata = np.empty((header.num_particles, header.num_int ))
rdata = np.empty((header.num_particles, header.num_real))
-
+
ip = 0
for lvl, level_grids in enumerate(header.grids):
for (which, count, where) in level_grids:
@@ -107,7 +107,7 @@ def read_particle_data(fn, ptype="particle0"):
floats = np.fromfile(f, dtype = fdtype, count=count)
idata[ip:ip+count] = ints
- rdata[ip:ip+count] = floats
+ rdata[ip:ip+count] = floats
ip += count
return idata, rdata
@@ -121,10 +121,10 @@ if __name__ == "__main__":
y0 = []
x1 = []
y1 = []
-
+
fn_list = glob.glob("plt?????")
fn_list.sort()
-
+
for fn in fn_list:
idata, rdata = read_particle_data(fn, ptype="particle0")
x0.append(rdata[0][0])