Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create arrays that represent the dimension of each grid axis #40

Merged
merged 3 commits into from
Apr 24, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion openpmd_validator/check_h5.py
Original file line number Diff line number Diff line change
Expand Up @@ -602,7 +602,9 @@ def check_meshes(f, iteration, v, extensionStates):
result_array += test_attr(field, v, "required",
"gridGlobalOffset", np.ndarray, [np.float32, np.float64])
result_array += test_attr(field, v, "recommended",
"gridUnitSI", np.float64)
"gridUnitSI", np.ndarray, np.float64)
result_array += test_attr(field, v, "required",
"gridUnitDimension", np.ndarray, np.float64)
result_array += test_attr(field, v, "required",
"dataOrder", np.string_)
result_array += test_attr(field, v, "required",
Expand Down
20 changes: 16 additions & 4 deletions openpmd_validator/createExamples_h5.py
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,11 @@ def write_rho_cylindrical(meshes, mode0, mode1):
rho.attrs["gridSpacing"] = np.array([1.0, 1.0], dtype=np.float32) # dr, dz
rho.attrs["gridGlobalOffset"] = np.array([0.0, 0.0], dtype=np.float32)
rho.attrs["position"] = np.array([0.0, 0.0], dtype=np.float32)
rho.attrs["gridUnitSI"] = np.float64(1.0)
rho.attrs["gridUnitSI"] = np.array([1.0, 1.0], dtype=np.float64)
# r: spatial (L), z: spatial (L)
rho.attrs["gridUnitDimension"] = \
np.array( [1.,0.,0.,0.,0.,0.,0.,
1.,0.,0.,0.,0.,0.,0.], dtype=np.float64 )
rho.attrs["dataOrder"] = np.string_("C")
rho.attrs["axisLabels"] = np.array([b"r",b"z"])

Expand Down Expand Up @@ -203,7 +207,11 @@ def write_b_2d_cartesian(meshes, data_ez):
B.attrs["geometry"] = np.string_("cartesian")
B.attrs["gridSpacing"] = np.array([1.0, 1.0], dtype=np.float32) # dx, dy
B.attrs["gridGlobalOffset"] = np.array([0.0, 0.0], dtype=np.float32)
B.attrs["gridUnitSI"] = np.float64(1.0)
B.attrs["gridUnitSI"] = np.array([1.0, 1.0], dtype=np.float64)
# x: spatial (L), y: spatial (L)
B.attrs["gridUnitDimension"] = \
np.array( [1.,0.,0.,0.,0.,0.,0.,
1.,0.,0.,0.,0.,0.,0.], dtype=np.float64 )
B.attrs["dataOrder"] = np.string_("C")
B.attrs["axisLabels"] = np.array([b"x",b"y"])
B.attrs["unitDimension"] = \
Expand Down Expand Up @@ -263,9 +271,13 @@ def write_e_2d_cartesian(meshes, data_ex, data_ey, data_ez ):

# Write the common metadata for the group
E.attrs["geometry"] = np.string_("cartesian")
E.attrs["gridSpacing"] = np.array([1.0, 1.0], dtype=np.float32) # dx, dy
E.attrs["gridSpacing"] = np.array([1.0, 1.0], dtype=np.float32) # dx, dy
E.attrs["gridGlobalOffset"] = np.array([0.0, 0.0], dtype=np.float32)
E.attrs["gridUnitSI"] = np.float64(1.0)
E.attrs["gridUnitSI"] = np.array([1.0, 1.0], dtype=np.float64 )
# x: spatial (L), y: spatial (L)
E.attrs["gridUnitDimension"] = \
np.array( [1.,0.,0.,0.,0.,0.,0.,
1.,0.,0.,0.,0.,0.,0.], dtype=np.float64 )
E.attrs["dataOrder"] = np.string_("C")
E.attrs["axisLabels"] = np.array([b"x",b"y"])
E.attrs["unitDimension"] = \
Expand Down