Field Export Postprocess

See the Field Exports reference for signatures and parameter descriptions.

Basic Field Operations

The PostprocessRecord contains the field export. You can use the record for basic exports. See the Field Exports reference for the complete method signatures and supported projections.

The field-export status is reported by is_field_export().

field_record = results.postprocesses[2]

print(field_record.is_field_export())
# True

print(field_record)
# PostprocessRecord(
#   source_file: /home/.../fieldbag_cartesian.jcm
#   title: fieldbag_cartesian
#   status: available
#   preview:
#     view: complete
#     indices: (0, 1)
#     coordinates: X=(200, 200), Y=(200, 200)
#     field_shape: (200, 200, 3)
#     derivatives: ()
#     transforms: ()
# )

Access the field export through field_record.fields. The fields attribute returns the field data for this postprocess.

fields = field_record.fields

print(fields)
# FieldExportPayload(
#   view: complete
#   indices: (0, 1)
#   coordinates: X=(200, 200), Y=(200, 200)
#   field_shape: (200, 200, 3)
#   derivatives: ()
#   transforms: ()
# )

Field exports support non-empty combinations of Cartesian coordinates X, Y, and Z, and polar coordinates R, Theta, and Phi. Dictionary and xarray exports retain the original coordinate names. They do not convert polar coordinates to Cartesian coordinates. Singleton coordinates from squeezed data are removed as dimensions. Use the full loader format to retain them.

The project has two sources, so two field indices are available. The available positions are returned by indices.

print(fields.indices)
# (0, 1)

Select the first field index with select(). The method returns a selection with that field only.

selected_field = fields.select(0)

print(selected_field)
# FieldExportPayload(
#   view: complete
#   indices: (0,)
#   coordinates: X=(200, 200), Y=(200, 200)
#   field_shape: (200, 200, 3)
#   derivatives: ()
#   transforms: ()
# )

An unselected xarray export has a field_index dimension and coordinate for all available fields. An explicitly selected export has neither.

Use transform() to transform field values.

phase_base = selected_field.transform("phase")

print(phase_base)
# FieldExportPayload(
#   view: complete
#   indices: (0,)
#   coordinates: X=(200, 200), Y=(200, 200)
#   field_shape: (200, 200, 3)
#   derivatives: ()
#   transforms: ('phase',)
# )

You can chain transformations.

abs_phase_base = phase_base.transform("abs")

print(abs_phase_base)
# FieldExportPayload(
#   view: complete
#   indices: (0,)
#   coordinates: X=(200, 200), Y=(200, 200)
#   field_shape: (200, 200, 3)
#   derivatives: ()
#   transforms: ('phase', 'abs')
# )

Intensity

The intensity view returns the squared norm. For a scalar field, this is its squared absolute value. For a vector field, this is the sum of squared absolute component values. The xarray export is real-valued and has no component dimension.

intensity = fields.intensity.base.select(0)
intensity_tree = intensity.to_xarray()

The intensity view supports base access and field selection, but not further transforms: it already contains derived scalar data.

For batched project keys, use BatchPostprocessRecord.fields. The export retains batch_index and availability information.

batch_intensity = batch_results.postprocesses[2].fields.intensity.base.select(0)
batch_intensity_tree = batch_intensity.to_xarray()