Field Exports
FieldExportPayload is the public
field-export data type for postprocess field data. Access it through
PostprocessRecord.fields or load it
with SolveResult.load_cartesian_fields. Use it to select fields, inspect
derivative fields, transform values, and create dictionary or xarray results. Use its
intensity attribute to export the squared norm as real scalar field data. See Data
Exporting for these formats.
An unselected field export includes all available fields. Its xarray export has a
field_index dimension and coordinate. After select(index), the xarray export has no field_index
dimension or coordinate. The selection contains one field.
- class jcmsuite.results.FieldExportPayload(mapping, *, source=None, derivative_name=None, selected_index=None, transforms=())[source]
Select, transform, and export field data.
- Parameters:
mapping (Mapping[object, object]) – Dictionary that contains field values and grid coordinates.
source (Source, optional) – Source file or storage origin associated with the field export.
derivative_name (str | None, optional) – Name of the selected field derivative.
selected_index (int | None, optional) – Position of the selected field. If omitted, include all fields.
transforms (tuple[str, ...], optional) – Mathematical changes to apply to field values. Use transform(…) instead of setting this option.
- __contains__(key)
Return whether the complete public view contains
key.- Parameters:
key (object) – Field-data name to find in the complete public view.
- Returns:
True if the key is available; otherwise, False.
- Return type:
bool
- __getitem__(key)
Select a derivative or read one dictionary value.
If this object came from .derivatives, a string selects one derivative. Otherwise, key selects a value from the field dictionary.
- Parameters:
key (object) – Derivative name or dictionary key.
- Returns:
Selected derivative, or the value for the dictionary key.
- Return type:
FieldExportPayload | object
- Raises:
TypeError – If a derivative selection does not use a string name.
KeyError – If the derivative name or dictionary key is not available.
- __iter__()
Iterate field-data names in the complete public view.
- Returns:
Field-data names in the complete public view.
- Return type:
Iterator[object]
- __len__()
Return the number of field-data names in the complete public view.
- Returns:
Number of field-data names in the complete public view.
- Return type:
int
- keys()
Return the solver parameter names available for derivative selection.
On the field’s derivative collection, the names select first derivatives. After selecting a first derivative, call its
derivatives.keys()to list available second-derivative directions. These are solver parameter names, not Torch project keys.- Returns:
Available derivative names in source-file order, or an empty tuple if the current selection provides no derivative lookup.
- Return type:
tuple[str, …]
- select(index=None)
Select one field by position.
- Parameters:
index (int | None, optional) – Field position to select. If omitted, select all fields.
- Returns:
New field selection. The original object does not change.
- Return type:
- Raises:
IndexError – If the selected position is not available.
- to_dict()
Return the selected field data as a dictionary.
- Returns:
Selected coordinates, field values, and derivatives.
- Return type:
Mapping[object, object]
- to_xarray()
Return the selected field data as an xarray DataTree.
The root node contains the selected base field or derivative. Other derivatives are in child nodes. If the field export has an explicit selection, the xarray export has no
field_indexdimension or coordinate. If the field export is unselected, the xarray export retainsfield_indexfor all available fields.- Returns:
Selected field data and coordinates.
- Return type:
xarray.DataTree
- Raises:
ValueError – If the selection contains no field data.
- transform(name)[source]
Apply a mathematical change to the field values.
- Parameters:
name ({"abs", "real", "imag", "phase"}) – Change to apply. “abs” gives the magnitude. “real” and “imag” give the real and imaginary parts. “phase” gives the phase angle in radians.
- Returns:
New field data with the change applied. The original object does not change.
- Return type:
Notes
The transformed view does not expose
derivatives. The available solver derivatives describe the bare field, not the transformed field.
- property base
Return only the base fields.
- Returns:
New field selection that excludes derivatives.
- Return type:
- property derivatives
Return all available field derivatives.
- Returns:
New selection that contains the available derivatives.
- Return type:
- Raises:
UnsupportedExportError – If the current view applies a field transformation or represents field intensity.
- property indices
Return the positions of the selected fields in source-file order.
- Returns:
Selected field positions.
- Return type:
tuple[int, …]
- property intensity
Return the squared-norm intensity field view.
- Returns:
Non-transformable view with real scalar field values.
- Return type:
- property source
Return the source file or storage origin.
- Returns:
Source file, storage origin, or None if unknown.
- Return type:
Source
- class jcmsuite.results.IntensityFieldExportPayload(mapping, *, source=None, derivative_name=None, selected_index=None)[source]
Navigate and export squared-norm field intensity.
Access this view through FieldExportPayload.intensity. For a scalar field, the view exports the squared absolute value. For a vector field, the view exports the sum of squared absolute component values. The xarray export is real-valued and has no component dimension.
The view supports base-field and field selection. It does not support transform(…) or derivatives because its values are transformed field data.
- __contains__(key)
Return whether the complete public view contains
key.- Parameters:
key (object) – Field-data name to find in the complete public view.
- Returns:
True if the key is available; otherwise, False.
- Return type:
bool
- __getitem__(key)
Select a derivative or read one dictionary value.
If this object came from .derivatives, a string selects one derivative. Otherwise, key selects a value from the field dictionary.
- Parameters:
key (object) – Derivative name or dictionary key.
- Returns:
Selected derivative, or the value for the dictionary key.
- Return type:
FieldExportPayload | object
- Raises:
TypeError – If a derivative selection does not use a string name.
KeyError – If the derivative name or dictionary key is not available.
- __iter__()
Iterate field-data names in the complete public view.
- Returns:
Field-data names in the complete public view.
- Return type:
Iterator[object]
- __len__()
Return the number of field-data names in the complete public view.
- Returns:
Number of field-data names in the complete public view.
- Return type:
int
- keys()
Return the solver parameter names available for derivative selection.
On the field’s derivative collection, the names select first derivatives. After selecting a first derivative, call its
derivatives.keys()to list available second-derivative directions. These are solver parameter names, not Torch project keys.- Returns:
Available derivative names in source-file order, or an empty tuple if the current selection provides no derivative lookup.
- Return type:
tuple[str, …]
- select(index=None)
Select one field by position.
- Parameters:
index (int | None, optional) – Field position to select. If omitted, select all fields.
- Returns:
New field selection. The original object does not change.
- Return type:
- Raises:
IndexError – If the selected position is not available.
- to_dict()
Return the selected field data as a dictionary.
- Returns:
Selected coordinates, field values, and derivatives.
- Return type:
Mapping[object, object]
- to_xarray()
Return the selected field data as an xarray DataTree.
The root node contains the selected base field or derivative. Other derivatives are in child nodes. If the field export has an explicit selection, the xarray export has no
field_indexdimension or coordinate. If the field export is unselected, the xarray export retainsfield_indexfor all available fields.- Returns:
Selected field data and coordinates.
- Return type:
xarray.DataTree
- Raises:
ValueError – If the selection contains no field data.
- property base
Return only the base fields.
- Returns:
New field selection that excludes derivatives.
- Return type:
- property indices
Return the positions of the selected fields in source-file order.
- Returns:
Selected field positions.
- Return type:
tuple[int, …]
- property source
Return the source file or storage origin.
- Returns:
Source file, storage origin, or None if unknown.
- Return type:
Source
Batch Field Exports
BatchFieldExportPayload applies the
same operations to available entries in a batch through
BatchPostprocessRecord.fields.
The batch export retains each original batch_index value. Its intensity property
returns a BatchIntensityFieldExportPayload. This payload exports squared-norm
intensity for each available batch entry and retains original batch indices.
- class jcmsuite.results.BatchFieldExportPayload(records, postprocess_index)[source]
Store and export transformable field data for a batch.
- __getitem__(name)
Select one derivative by name from all available batch entries.
- Parameters:
name (str) – Derivative name.
- Returns:
New batch field selection for the derivative.
- Return type:
- Raises:
TypeError – If name is not a string.
KeyError – If the derivative is not available.
- keys()
Return the available derivative names in source-file order.
- Returns:
Derivative names from the first available batch entry.
- Return type:
tuple[str, …]
- select(index=None)
Select one field position from all available batch entries.
If index is None, select all field positions.
- Parameters:
index (int | None, optional) – Field position. None selects all fields.
- Returns:
New batch field selection.
- Return type:
- Raises:
IndexError – If the field position is not available.
- to_dict()
Return one field dictionary for each available batch entry.
- Returns:
Field dictionaries indexed by their original batch positions.
- Return type:
Mapping[object, object]
- to_xarray()
Return the batch field data as an xarray DataTree.
The root node contains the selected fields. Derivatives are in child nodes. batch_index contains the original batch positions.
- Returns:
Batch field data with validity and padding information.
- Return type:
xarray.DataTree
- Raises:
InvalidConfigurationError – If no field data is available or the field shapes cannot be combined.
- transform(name)[source]
Apply a mathematical change to all selected field values.
- Parameters:
name ({"abs", "real", "imag", "phase"}) – Mathematical change to apply.
- Returns:
New batch field data with the change applied.
- Return type:
- Raises:
ValueError – If name is not supported.
- property base
Return only the base fields from available batch entries.
- Returns:
New batch field selection that excludes derivatives.
- Return type:
- property derivatives
Return all field derivatives from available batch entries.
- Returns:
New batch selection that contains available derivatives.
- Return type:
- property indices
Return the positions of the selected fields in source-file order.
- Returns:
Selected field positions from the first available batch entry.
- Return type:
tuple[int, …]
- property intensity
Return the squared-norm intensity view for available fields.
- Returns:
Non-transformable field-intensity view. The view retains batch entry identity, availability information, and field navigation.
- Return type:
- property sources
Return one source file for each batch entry.
An unavailable source file is None. The order matches the current batch entries.
- Returns:
Source files in batched project keys order.
- Return type:
tuple[Path | None, …]
- class jcmsuite.results.BatchIntensityFieldExportPayload(records, postprocess_index)[source]
Store and export squared-norm field intensity across a batch.
BatchFieldExportPayload.intensityreturns this payload. Each available entry contains real-valued intensity fields, identified by its original batch index. The payload supports base-field and field-position selection, dictionary export, and xarray export. It does not support further intensity or field transforms. Solver derivative access is not available for intensity values.Do not construct this payload directly.
- __getitem__(name)
Select one derivative by name from all available batch entries.
- Parameters:
name (str) – Derivative name.
- Returns:
New batch field selection for the derivative.
- Return type:
- Raises:
TypeError – If name is not a string.
KeyError – If the derivative is not available.
- select(index=None)
Select one field position from all available batch entries.
If index is None, select all field positions.
- Parameters:
index (int | None, optional) – Field position. None selects all fields.
- Returns:
New batch field selection.
- Return type:
- Raises:
IndexError – If the field position is not available.
- to_dict()
Return one field dictionary for each available batch entry.
- Returns:
Field dictionaries indexed by their original batch positions.
- Return type:
Mapping[object, object]
- to_xarray()
Return the batch field data as an xarray DataTree.
The root node contains the selected fields. Derivatives are in child nodes. batch_index contains the original batch positions.
- Returns:
Batch field data with validity and padding information.
- Return type:
xarray.DataTree
- Raises:
InvalidConfigurationError – If no field data is available or the field shapes cannot be combined.
- property base
Return only the base fields from available batch entries.
- Returns:
New batch field selection that excludes derivatives.
- Return type:
- property indices
Return the positions of the selected fields in source-file order.
- Returns:
Selected field positions from the first available batch entry.
- Return type:
tuple[int, …]
- property sources
Return one source file for each batch entry.
An unavailable source file is None. The order matches the current batch entries.
- Returns:
Source files in batched project keys order.
- Return type:
tuple[Path | None, …]