Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
postpic
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
LabAstro
postpic
Commits
bdbafd65
Unverified
Commit
bdbafd65
authored
Apr 14, 2024
by
Stephan Kuschel
Committed by
GitHub
Apr 14, 2024
Browse files
Options
Downloads
Plain Diff
Merge pull request #279 from sjgrimm/dev2
various smilei reader bugfixes
parents
3eb08c60
8545d4cb
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
postpic/datareader/smileih5.py
+41
-6
41 additions, 6 deletions
postpic/datareader/smileih5.py
with
41 additions
and
6 deletions
postpic/datareader/smileih5.py
+
41
−
6
View file @
bdbafd65
...
@@ -47,14 +47,19 @@ def _generateh5indexfile(indexfile, fnames):
...
@@ -47,14 +47,19 @@ def _generateh5indexfile(indexfile, fnames):
# indexfile already exists. do not recreate
# indexfile already exists. do not recreate
return
return
dirname
=
os
.
path
.
dirname
(
fnames
[
0
])
indexfile
=
os
.
path
.
join
(
dirname
,
indexfile
)
def
visitf
(
key
):
def
visitf
(
key
):
# key is a string
# key is a string
# only link if key points to a dataset. Do not link groups
if
key
.
endswith
(
'
latest_IDs
'
):
if
isinstance
(
hf
[
key
],
h5py
.
_hl
.
dataset
.
Dataset
):
return
# only link if key points to a dataset. Generally do not link groups.
# However single scalars (identified by ´value in hf[key].attrs´)
# maybe a group and must be linked as well.
if
isinstance
(
hf
[
key
],
h5py
.
_hl
.
dataset
.
Dataset
)
or
"
value
"
in
hf
[
key
].
attrs
:
ih
[
key
]
=
h5py
.
ExternalLink
(
fname
,
key
)
ih
[
key
]
=
h5py
.
ExternalLink
(
fname
,
key
)
elif
isinstance
(
hf
[
key
],
h5py
.
_hl
.
group
.
Group
)
and
key
not
in
ih
:
ih
.
create_group
(
key
)
for
attr
in
hf
[
key
].
attrs
:
ih
[
key
].
attrs
[
attr
]
=
hf
[
key
].
attrs
[
attr
]
with
h5py
.
File
(
indexfile
,
'
w
'
)
as
ih
:
with
h5py
.
File
(
indexfile
,
'
w
'
)
as
ih
:
for
fname
in
fnames
:
for
fname
in
fnames
:
...
@@ -306,6 +311,36 @@ class SmileiReader(OpenPMDreader):
...
@@ -306,6 +311,36 @@ class SmileiReader(OpenPMDreader):
'
Bx
'
,
'
By
'
,
'
Bz
'
,
'
Br
'
,
'
Bl
'
,
'
Bt
'
,
'
Bx
'
,
'
By
'
,
'
Bz
'
,
'
Br
'
,
'
Bl
'
,
'
Bt
'
,
'
Jx
'
,
'
Jy
'
,
'
Jz
'
,
'
Jr
'
,
'
Jl
'
,
'
Jt
'
,
'
Rho
'
]
'
Jx
'
,
'
Jy
'
,
'
Jz
'
,
'
Jr
'
,
'
Jl
'
,
'
Jt
'
,
'
Rho
'
]
def
getSpecies
(
self
,
species
,
attrib
):
"""
Returns one of the attributes out of (x,y,z,px,py,pz,weight,ID,mass,charge) of
this particle species.
"""
attribid
=
helper
.
attribidentify
[
attrib
]
options
=
{
9
:
'
particles/{}/weight
'
,
0
:
'
particles/{}/position/x
'
,
1
:
'
particles/{}/position/y
'
,
2
:
'
particles/{}/position/z
'
,
3
:
'
particles/{}/momentum/x
'
,
4
:
'
particles/{}/momentum/y
'
,
5
:
'
particles/{}/momentum/z
'
,
10
:
'
particles/{}/id
'
,
11
:
'
particles/{}/mass
'
,
12
:
'
particles/{}/charge
'
}
optionsoffset
=
{
0
:
'
particles/{}/positionOffset/x
'
,
1
:
'
particles/{}/positionOffset/y
'
,
2
:
'
particles/{}/positionOffset/z
'
}
key
=
options
[
attribid
]
offsetkey
=
optionsoffset
.
get
(
attribid
)
try
:
data
=
self
.
data
(
key
.
format
(
species
))
if
offsetkey
is
not
None
:
data
+=
self
.
data
(
offsetkey
.
format
(
species
))
ret
=
np
.
asarray
(
data
,
dtype
=
np
.
float64
)
except
IndexError
:
raise
KeyError
return
ret
def
getderived
(
self
):
def
getderived
(
self
):
'''
'''
return all other fields dumped, except E and B.
return all other fields dumped, except E and B.
...
@@ -346,7 +381,7 @@ class SmileiSeries(Simulationreader_ifc):
...
@@ -346,7 +381,7 @@ class SmileiSeries(Simulationreader_ifc):
indexfile
=
_getindexfile
(
h5file
)
indexfile
=
_getindexfile
(
h5file
)
self
.
_h5
=
h5py
.
File
(
indexfile
,
'
r
'
)
self
.
_h5
=
h5py
.
File
(
indexfile
,
'
r
'
)
with
h5py
.
File
(
indexfile
,
'
r
'
)
as
h5
:
with
h5py
.
File
(
indexfile
,
'
r
'
)
as
h5
:
self
.
_dumpkeys
=
list
(
h5
[
'
data
'
].
keys
()
)
self
.
_dumpkeys
=
[
int
(
i
)
for
i
in
h5
[
'
data
'
].
keys
()
]
else
:
else
:
raise
IOError
(
'
{} does not exist.
'
.
format
(
h5file
))
raise
IOError
(
'
{} does not exist.
'
.
format
(
h5file
))
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment