@@ -95,7 +95,7 @@ Each file's *root* group (path `/`) must at least contain the attributes:
9595 present standard (e.g. fields on an unstructured mesh),
9696 this can be done be storing this data within a path that * is not*
9797 of the form given by ` basePath ` (e.g. ` /extra_data ` ). In this
98- way, the openPMD parsing tools will not parse this additional data.
98+ way, the openPMD parsing tools will not parse this additional data.
9999
100100The following attribute is * optional* in each each file's * root* group
101101(path ` / ` ) and indicates if a file also follows an openPMD extension
@@ -256,6 +256,9 @@ time step.
256256 This is needed at the iteration level, since the time step
257257 may vary from iteration to iteration in certain codes.
258258
259+ In addition, the following attribute is * recommended* (see the section
260+ on Unit Systems and Dimensionality, further below):
261+
259262 - ` timeUnitSI `
260263 - type: * (float64 / REAL8)*
261264 - description: a conversation factor to convert ` time ` and ` dt ` to ` seconds `
@@ -423,6 +426,9 @@ meshes):
423426
424427 - example: ` (0.0, 100.0, 0.0) ` or ` (0.5, 0.5, 0.5) `
425428
429+ In addition, the following attribute is * recommended* (see the section
430+ on Unit Systems and Dimensionality, further below):
431+
426432 - ` gridUnitSI `
427433 - type: * (float64 / REAL8)*
428434 - description: unit-conversion factor to multiply each value in
@@ -502,7 +508,8 @@ def is_const_component(record_component):
502508
503509def get_component (group , component_name ):
504510 record_component = group[component_name]
505- unitSI = record_component.attrs[" unitSI" ]
511+ # `default` handles the case where conversion to SI is not provided
512+ unitSI = record_component.attrs.get(" unitSI" , default = 1 .)
506513
507514 if is_const_component(record_component):
508515 return record_component.attrs[" value" ], unitSI
@@ -584,19 +591,34 @@ patch order:
584591Unit Systems and Dimensionality
585592-------------------------------
586593
587- While this standard does not impose any unit system on the data that is stored
588- itself, it still requires a common interface to convert one unit system to
589- another.
590-
591- To allow scaling data without reformatting it during the write process we
592- provide a unit conversation factor, often called ` unitSI ` in the document,
593- to transform it to a corresponding quantity in the International System of
594- Units (SI).
594+ All datasets and attributes can be written in arbitrary units, in openPMD.
595+ Typically, this will be the unit system adopted internally by the
596+ software that writes openPMD (e.g. the unit system adopted internally
597+ by a physics simulation code), in order to avoid a reduction in performance
598+ associated with unit conversion during the write process.
599+
600+ However, for each dataset and attribute, it is ** very strongly** recommended to
601+ provide the conversion factor from the chosen unit system to the International
602+ System of Units (SI). (See the description of the attributes ` timeUnitSI ` ,
603+ ` gridUnitSI ` and ` unitSI ` , in the present document.) This allows
604+ the reading softwares to convert the datasets to units that any user can
605+ understand, without requiring them to know the chosen unit system.
606+
607+ In some exceptional cases, the software that produces the openPMD data may
608+ not have a well-defined conversion to the SI system. (This is the case for
609+ instance for plasma simulation codes where quantities are scaled with respect to
610+ a given plasma density, and where this density could have any value.)
611+ In this case, the attributes ` timeUnitSI ` , ` gridUnitSI ` and ` unitSI ` can
612+ be omitted. However, note that, in this case, the reading softwares will
613+ not be able to tell the user in which units the data is, and this will require
614+ the user to have in-depth knowledge of the chosen unit system.
615+ ** Therefore, unless there is a very good reason to omit the conversion factors
616+ to the SI system, it is very strongly recommended to include them.**
595617
596618For each ` mesh ` or ` particle ` ` record ` and their ` components ` the following
597- attributes must be added :
619+ attributes are defined :
598620
599- ### Required for each ` Record Component `
621+ ### Recommended for each ` Record Component `
600622
601623Reminder: for scalar records the ` record ` itself is also the ` component ` .
602624
@@ -649,20 +671,6 @@ Reminder: for scalar records the `record` itself is also the `component`.
649671 is e.g. 1.e-5, ` timeOffset ` would be 0.5e-5 for the magnetic
650672 field and 0. for the electric field.
651673
652- ### Advice to Implementors
653-
654- For the special case of simulations, there can be the situation that a certain
655- process scales independently of a given fixed reference quantity that
656- can be expressed in SI, e.g., the growth rate of a plasma instability can
657- scale over various orders of magnitudes solely with the plasma frequency
658- and the basic constants such as mass/charge of the simulated particles.
659-
660- In such a case, picking a * reference density* to determine the ` unitSI `
661- factors is required to provide a fallback for compatibility.
662-
663- For human readable output, it is * recommended* to add the actual string
664- of the unit in the corresponding ` comment ` attribute.
665-
666674
667675Constant Record Components
668676--------------------------
0 commit comments