Skip to Content.
Sympa Menu

opal - Re: [Opal] h5dump to output readable bunch input file

opal AT lists.psi.ch

Subject: The OPAL Discussion Forum

List archive

Re: [Opal] h5dump to output readable bunch input file


Chronological Thread 
  • From: Achim Gsell <achim.gsell AT psi.ch>
  • To: "Schneider, Sergej" <sergej.schneider AT helmholtz-berlin.de>
  • Cc: "opal AT lists.psi.ch" <opal AT lists.psi.ch>
  • Subject: Re: [Opal] h5dump to output readable bunch input file
  • Date: Fri, 5 Jul 2013 14:18:24 +0200
  • List-archive: <https://lists.web.psi.ch/pipermail/opal/>
  • List-id: The OPAL Discussion Forum <opal.lists.psi.ch>

Hi Sergej

On Jul 4, 2013, at 4:52 PM, "Schneider, Sergej"
<sergej.schneider AT helmholtz-berlin.de> wrote:

> Dear all,
>
> does anyone have some experience with the tool h5dump? I am struggling to
> get an output that suits the required format of the bunch input file for
> OPAL, which would be
>
> N
> x1 px1 y1 py1 z1 pz1
> ...
> xN pxN...
>
> For example, with the command "h5dump -d /Step#1/x ... -d /Step#1/pz -o
> out" I can get an output file with all the required information to read in
> a bunch but it's in the wrong format as it outputs the whole dataset x with
> all N particles before writing the next dataset:
>
> x1 ... xN ... pz1 ... pzN
>
> Does anyone know if it's possible to get out a file straight with the right
> format?

I don't think its possible with h5dump.

If you have Python and h5py it is pretty simple. The code snippet below gives
an idea how to implement such a converter:

#!/usr/bin/env python

import h5py

fname = 'degrader.h5'
step = '/Step#1/'

f = h5py.File (fname, 'r')

x = f[step + 'x']
px = f[step + 'px']
y = f[step + 'y']
py = f[step + 'py']
z = f[step + 'z']
pz = f[step + 'pz']

print x.len()
for i in xrange(x.len()):
print x[i], py[i], y[i], py[i], z[i], pz[i]



Cheers

Achim




Archive powered by MHonArc 2.6.19.

Top of Page