-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added
optika.metrology.RoughnessParameters
class.
- Loading branch information
Showing
3 changed files
with
69 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
from ._slope_error import * | ||
from ._roughness import * |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |