Skip to content

Commit

Permalink
Merge pull request #40 from RemiLehe/per_component_unitSI
Browse files Browse the repository at this point in the history
Create arrays that represent the dimension of each grid axis
  • Loading branch information
ax3l authored Apr 24, 2018
2 parents 51a55d1 + 4f5fee1 commit f382ac9
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 5 deletions.
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

0 comments on commit f382ac9

Please sign in to comment.