fouriax.OpticalLayer#

class OpticalLayer#

Bases: ABC

Base interface for field-to-field optical transformations.

Subclasses must implement forward(), which receives a Field and returns a transformed Field with the same grid and spectrum (unless the layer explicitly changes them).

Override validate_for() to add layer-specific compatibility checks (e.g. domain or polarisation requirements). Override parameters() to expose trainable or configurable values used during gradient-based optimisation.

__init__()#

Methods

__init__()

forward(field)

Apply this layer's optical transformation to field.

parameters()

Return trainable or configurable layer parameters.

validate_for(field)

Check that field is compatible with this layer.

abstractmethod forward(field)#

Apply this layer’s optical transformation to field.

Parameters:

field (Field) – Input optical field to transform.

Returns:

Transformed field. Subclasses should preserve batch axes, wavelength axes, and metadata unless the layer explicitly changes them.

Return type:

Field

validate_for(field)#

Check that field is compatible with this layer.

The default implementation validates the field itself. Subclasses should call super().validate_for(field) and add any layer-specific checks such as domain, polarization, or shape requirements.

Parameters:

field (Field)

Return type:

None

parameters()#

Return trainable or configurable layer parameters.

Returns an empty dict by default. Subclasses override this to expose arrays that should be updated during optimisation.

Return type:

dict[str, Array]