Skip to content

Commit

Permalink
Converted optika.sensors.IdealImagingSensor to ImagingSensor. (#63)
Browse files Browse the repository at this point in the history
  • Loading branch information
byrdie authored Jul 20, 2024
1 parent f2f85f1 commit 35a41cb
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 14 deletions.
2 changes: 1 addition & 1 deletion optika/_tests/test_systems.py
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ def test_rayfunction_default(self, a: optika.systems.AbstractSequentialSystem):
),
]

_sensor = optika.sensors.IdealImagingSensor(
_sensor = optika.sensors.ImagingSensor(
name="sensor",
width_pixel=15 * u.um,
num_pixel=na.Cartesian2dVectorArray(2048, 1024),
Expand Down
4 changes: 2 additions & 2 deletions optika/sensors/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
)
from ._sensors import (
AbstractImagingSensor,
IdealImagingSensor,
ImagingSensor,
AbstractCCD,
)

Expand All @@ -43,6 +43,6 @@
"E2VCCD97Material",
"E2VCCDAIAMaterial",
"AbstractImagingSensor",
"IdealImagingSensor",
"ImagingSensor",
"AbstractCCD",
]
25 changes: 17 additions & 8 deletions optika/sensors/_sensors.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@
import astropy.units as u
import named_arrays as na
import optika
from . import AbstractImagingSensorMaterial
from . import AbstractImagingSensorMaterial, IdealImagingSensorMaterial

__all__ = [
"AbstractImagingSensor",
"IdealImagingSensor",
"ImagingSensor",
"AbstractCCD",
]

Expand Down Expand Up @@ -145,11 +145,12 @@ def readout(


@dataclasses.dataclass(eq=False, repr=False)
class IdealImagingSensor(
class ImagingSensor(
AbstractImagingSensor,
):
"""
An idealized imaging sensor with perfect efficiency and no noise sources.
An arbitrary imaging sensor described by a pixel grid and a light-sensitive
material.
"""

name: None | str = None
Expand All @@ -170,6 +171,14 @@ class IdealImagingSensor(
timedelta_exposure: u.Quantity | na.AbstractScalar = 0 * u.s
"""The exposure time of the sensor."""

material: AbstractImagingSensorMaterial = None
"""
A model of the light-sensitive material composing this sensor.
If :obj:`None` (the default), :class:`optika.sensors.IdealImagingSensor`
will be used.
"""

aperture_mechanical: optika.apertures.RectangularAperture = None
"""The shape of the physical substrate supporting the sensor."""

Expand All @@ -185,6 +194,10 @@ class IdealImagingSensor(
kwargs_plot: None | dict = None
"""Extra keyword arguments to pass to :meth:`plot`"""

def __post_init__(self) -> None:
if self.material is None:
self.material = IdealImagingSensorMaterial()

@property
def shape(self) -> dict[str, int]:
return na.broadcast_shapes(
Expand All @@ -195,10 +208,6 @@ def shape(self) -> dict[str, int]:
optika.shape(self.transformation),
)

@property
def material(self) -> optika.materials.AbstractMaterial:
return optika.sensors.IdealImagingSensorMaterial()


class AbstractCCD(
AbstractImagingSensor[MaterialT],
Expand Down
4 changes: 2 additions & 2 deletions optika/sensors/_tests/test_sensors.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ def test_readout(
@pytest.mark.parametrize(
argnames="a",
argvalues=[
optika.sensors.IdealImagingSensor(
optika.sensors.ImagingSensor(
name="test sensor",
width_pixel=15 * u.um,
axis_pixel=na.Cartesian2dVectorArray("detector_x", "detector_y"),
Expand All @@ -63,7 +63,7 @@ def test_readout(
),
],
)
class TestIdealImagingSensor(
class TestImagingSensor(
AbstractTestAbstractImagingSensor,
):
pass
2 changes: 1 addition & 1 deletion optika/systems.py
Original file line number Diff line number Diff line change
Expand Up @@ -771,7 +771,7 @@ class SequentialSystem(
)
# define the imaging sensor surface
sensor = optika.sensors.IdealImagingSensor(
sensor = optika.sensors.ImagingSensor(
name="sensor",
width_pixel=5 * u.um,
num_pixel=na.Cartesian2dVectorArray(1024, 2048),
Expand Down

0 comments on commit 35a41cb

Please sign in to comment.