Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Modified furst_optics.gratings.Grating to have a sag parameter instead of a radius parameter. #23

Merged
merged 10 commits into from
Sep 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions furst_optics/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
An idealized raytrace model of the FURST optical system.
"""

from . import typevars
from . import abc
from . import sources
from . import apertures
Expand All @@ -10,6 +11,7 @@
from . import detectors

__all__ = [
"typevars",
"abc",
"sources",
"apertures",
Expand Down
4 changes: 3 additions & 1 deletion furst_optics/gratings/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@
Models and measurements of the diffraction grating.
"""

from ._gratings import Grating
from ._gratings import (
Grating,
)

__all__ = [
"Grating",
Expand Down
23 changes: 17 additions & 6 deletions furst_optics/gratings/_gratings.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from typing import Generic
import dataclasses
import astropy.units as u
import named_arrays as na
Expand All @@ -16,6 +17,11 @@ class Grating(
optika.mixins.Pitchable,
optika.mixins.Translatable,
furst_optics.abc.AbstractRowlandComponent,
Generic[
furst_optics.typevars.SagT,
furst_optics.typevars.MaterialT,
furst_optics.typevars.RulingT,
],
):
"""
A model of the FURST diffraction grating.
Expand Down Expand Up @@ -48,7 +54,9 @@ class Grating(

# Define the grating model
grating = furst_optics.gratings.Grating(
radius=-2 * rowland_radius,
sag=optika.sags.SphericalSag(
radius=-2 * rowland_radius,
),
width_clear=na.Cartesian2dVectorArray(
x=1000 * u.mm,
y=20 * u.mm,
Expand Down Expand Up @@ -83,6 +91,11 @@ class Grating(
The human-readable name of this optic.
"""

sag: furst_optics.typevars.SagT = None
"""
The sag profile of the grating surface.
"""

radius: u.Quantity | na.AbstractScalar = 0 * u.mm
"""
The radius of curvature of the optical surface.
Expand All @@ -98,13 +111,13 @@ class Grating(
The height and width of the grating substrate.
"""

material: None | optika.materials.AbstractMaterial = None
material: furst_optics.typevars.MaterialT = None
"""
The coating material used to make the optic reflective
in the target spectral range.
"""

rulings: None | optika.rulings.AbstractRulings = None
rulings: furst_optics.typevars.RulingT = None
"""
A model of the grating ruling spacing and profile.
"""
Expand Down Expand Up @@ -150,9 +163,7 @@ class Grating(
def surface(self) -> optika.surfaces.Surface:
return optika.surfaces.Surface(
name=self.name,
sag=optika.sags.SphericalSag(
radius=self.radius,
),
sag=self.sag,
material=self.material,
aperture=optika.apertures.RectangularAperture(
half_width=self.width_clear / 2,
Expand Down
4 changes: 3 additions & 1 deletion furst_optics/gratings/_gratings_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@
argnames="a",
argvalues=[
furst_optics.gratings.Grating(
radius=1000 * u.mm,
sag=optika.sags.SphericalSag(
radius=1000 * u.mm,
),
width_clear=10 * u.mm,
width_mech=15 * u.mm,
material=optika.materials.Mirror(),
Expand Down
29 changes: 29 additions & 0 deletions furst_optics/typevars.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
"""
Type variables used by the generic types
in this project.
"""

from typing import TypeVar
import optika

__all__ = [
"SagT",
"MaterialT",
"RulingT",
]


#: Sag type variable.
#: Should be :obj:`None` or a subclass of
#: :class:`optika.sags.AbstractSag`
SagT = TypeVar("SagT", bound=None | optika.sags.AbstractSag)

#: Material type variable.
#: Should be :obj:`None` or a subclass of
#: :class:`optika.materials.AbstractMaterial`
MaterialT = TypeVar("MaterialT", bound=None | optika.materials.AbstractMaterial)

#: Ruling type variable.
#: Should be :obj:`None` or a subclass of
#: :class:`optika.rulings.AbstractRulings`
RulingT = TypeVar("RulingT", bound=None | optika.rulings.AbstractRulings)
Loading