Fom#

lumopt2.fom.fom.Fom(sim_results: FieldResults | PortResults | list, fct: callable = None)#

Factory function that returns either a FieldFom or PortFom instance.

Inspects the types in sim_results and instantiates the appropriate subclass. All monitors must be of the same type.

Parameters:
sim_resultsFieldResults or PortResults or list of those

One or more monitor result objects.

fctcallable(), optional

User-supplied scalar function of the monitor values. If None, a sensible default is used: mean() for field-based monitors and PNorm() (with default parameters) for port-based monitors.

Returns:
FieldFom or PortFom

Appropriate FOM subclass instance.

Raises:
ValueError

If sim_results is empty.

ValueError

If sim_results contains objects that are neither FieldResults nor PortResults.

ValueError

If monitors are of mixed types (some field, some port).