Skip to content

Commit

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

__all__ = [
"AbstractRoughnessParameters",
"RoughnessParameters",
]


@dataclasses.dataclass(eq=False, repr=False)
class AbstractRoughnessParameters(
optika.mixins.Printable,
):
"""collection of parameters used to compute the roughness of an optical surface"""

@property
@abc.abstractmethod
def period_min(self) -> na.ScalarLike:
"""
minimum period to consider when calculating roughness
"""

@property
@abc.abstractmethod
def period_max(self) -> na.ScalarLike:
"""maximum period to consider when calculating roughness"""


@dataclasses.dataclass(eq=False, repr=False)
class RoughnessParameters(
AbstractRoughnessParameters,
):
period_min: na.ScalarLike = 0 * u.mm
period_max: na.ScalarLike = 0 * u.mm
31 changes: 31 additions & 0 deletions optika/metrology/_tests/test_roughness.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 AbstractTestAbstractRoughnessParameters(abc.ABC):
def test_period_min(self, a: optika.metrology.AbstractRoughnessParameters):
assert np.issubdtype(na.get_dtype(a.period_min), float)
assert na.unit_normalized(a.period_min).is_equivalent(u.mm)

def test_period_max(self, a: optika.metrology.AbstractRoughnessParameters):
assert np.issubdtype(na.get_dtype(a.period_max), float)
assert na.unit_normalized(a.period_max).is_equivalent(u.mm)


@pytest.mark.parametrize(
argnames="a",
argvalues=[
optika.metrology.RoughnessParameters(
period_min=2 * u.mm,
period_max=4 * u.mm,
)
],
)
class TestRoughnessParameters(
AbstractTestAbstractRoughnessParameters,
):
pass

0 comments on commit f069d6f

Please sign in to comment.