Skip to content

Commit

Permalink
Added optika.metrology.SlopeErrorParameters class.
Browse files Browse the repository at this point in the history
  • Loading branch information
byrdie committed Oct 16, 2023
1 parent a30acdc commit f6fe055
Show file tree
Hide file tree
Showing 4 changed files with 70 additions and 0 deletions.
1 change: 1 addition & 0 deletions optika/metrology/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from ._slope_error import *
38 changes: 38 additions & 0 deletions optika/metrology/_slope_error.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import abc
import dataclasses
import astropy.units as u
import named_arrays as na
import optika.mixins

__all__ = [
"AbstractSlopeErrorParameters",
"SlopeErrorParameters",
]


@dataclasses.dataclass(eq=False, repr=False)
class AbstractSlopeErrorParameters(
optika.mixins.Printable,
):
"""collection of parameters used to compute the slope error"""

@property
@abc.abstractmethod
def kernel_size(self) -> na.ScalarLike:
"""
size of the boxcar kernel that is convolved with the wavefront error
before measuring the slope
"""

@property
@abc.abstractmethod
def step_size(self) -> na.ScalarLike:
"""the horizontal distance to use when measuring the slope"""


@dataclasses.dataclass(eq=False, repr=False)
class SlopeErrorParameters(
AbstractSlopeErrorParameters,
):
kernel_size: na.ScalarLike = 0 * u.mm
step_size: na.ScalarLike = 0 * u.mm
Empty file.
31 changes: 31 additions & 0 deletions optika/metrology/_tests/test_slope_error.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import pytest
import abc
import numpy as np
import astropy.units as u
import named_arrays as na
import optika


class AbstractTestAbstractSlopeErrorParameters(abc.ABC):
def test_kernel_size(self, a: optika.metrology.AbstractSlopeErrorParameters):
assert np.issubdtype(na.get_dtype(a.kernel_size), float)
assert na.unit_normalized(a.kernel_size).is_equivalent(u.mm)

def test_step_size(self, a: optika.metrology.AbstractSlopeErrorParameters):
assert np.issubdtype(na.get_dtype(a.step_size), float)
assert na.unit_normalized(a.step_size).is_equivalent(u.mm)


@pytest.mark.parametrize(
argnames="a",
argvalues=[
optika.metrology.SlopeErrorParameters(
kernel_size=2 * u.mm,
step_size=4 * u.mm,
)
],
)
class TestSlopeErrorParameters(
AbstractTestAbstractSlopeErrorParameters,
):
pass

0 comments on commit f6fe055

Please sign in to comment.