Skip to content

Commit

Permalink
Changed the behavior of `optika.systems.AbstractSequentialSystem.obje…
Browse files Browse the repository at this point in the history
…ct_is_at_infinity` to consider surfaces with no aperture at infinity. (#96)
  • Loading branch information
byrdie authored Oct 12, 2024
1 parent d9d00c5 commit d408891
Showing 1 changed file with 20 additions and 16 deletions.
36 changes: 20 additions & 16 deletions optika/systems.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ class AbstractSequentialSystem(

@property
@abc.abstractmethod
def object(self) -> None | optika.surfaces.AbstractSurface:
def object(self) -> optika.surfaces.AbstractSurface:
"""
The external object being imaged or illuminated by this system.
Expand All @@ -77,21 +77,21 @@ def object(self) -> None | optika.surfaces.AbstractSurface:

@property
def object_is_at_infinity(self) -> bool:
obj = self.object
if obj is not None:
aperture_obj = obj.aperture
if aperture_obj is not None:
unit_obj = na.unit_normalized(aperture_obj.bound_lower)
if unit_obj.is_equivalent(u.mm):
result = False
elif unit_obj.is_equivalent(u.dimensionless_unscaled):
result = True
else: # pragma: nocover
raise ValueError(
f"Unrecognized unit for object aperture, {unit_obj}"
)
else:
"""
A boolean flag indicating if the object is at infinity.
If :attr:`object` doesn't have an aperture,
it is assumed that the object is at infinity.
"""
aperture_obj = self.object.aperture
if aperture_obj is not None:
unit_obj = na.unit_normalized(aperture_obj.bound_lower)
if unit_obj.is_equivalent(u.mm):
result = False
elif unit_obj.is_equivalent(u.dimensionless_unscaled):
result = True
else: # pragma: nocover
raise ValueError(f"Unrecognized unit for object aperture, {unit_obj}")
else:
result = True
return result
Expand Down Expand Up @@ -1338,7 +1338,7 @@ class SequentialSystem(
"""
The external object being imaged or illuminated by this system.
If :obj:`None`, the external object is assumed to be at infinity.
If :obj:`None`, the object is assumed to be an empty surface at the origin.
"""

sensor: optika.sensors.AbstractImagingSensor = None
Expand Down Expand Up @@ -1379,6 +1379,10 @@ class SequentialSystem(
Additional keyword arguments used by default in :meth:`plot`.
"""

def __post_init__(self):
if self.object is None:
self.object = optika.surfaces.Surface()

@property
def shape(self) -> dict[str, int]:
return na.broadcast_shapes(
Expand Down

0 comments on commit d408891

Please sign in to comment.