|
| 1 | +import abc |
| 2 | +import dataclasses |
| 3 | +import numpy as np |
| 4 | +import astropy.units as u |
| 5 | +import named_arrays as na |
| 6 | +import optika |
| 7 | + |
| 8 | +__all__ = [ |
| 9 | + "FieldStop", |
| 10 | +] |
| 11 | + |
| 12 | + |
| 13 | +@dataclasses.dataclass(eq=False, repr=False) |
| 14 | +class AbstractFieldStop( |
| 15 | + optika.mixins.Printable, |
| 16 | + optika.mixins.Translatable, |
| 17 | +): |
| 18 | + """ |
| 19 | + An interface describing the field stop of the instrument. |
| 20 | + """ |
| 21 | + |
| 22 | + @property |
| 23 | + @abc.abstractmethod |
| 24 | + def num_folds(self) -> int: |
| 25 | + """ |
| 26 | + The order of the rotational symmetry of the optical system. |
| 27 | + """ |
| 28 | + |
| 29 | + @property |
| 30 | + def num_sides(self) -> int: |
| 31 | + """ |
| 32 | + The number of sides of the field stop's aperture. |
| 33 | + """ |
| 34 | + return self.num_folds |
| 35 | + |
| 36 | + @property |
| 37 | + @abc.abstractmethod |
| 38 | + def radius_clear(self) -> u.Quantity | na.AbstractScalar: |
| 39 | + """ |
| 40 | + The distance from the center to a vertex of the clear aperture. |
| 41 | + """ |
| 42 | + |
| 43 | + @property |
| 44 | + def width_clear(self) -> u.Quantity: |
| 45 | + """ |
| 46 | + The width of the clear aperture from edge to edge. |
| 47 | + """ |
| 48 | + return 2 * self.radius_clear * np.cos(360 * u.deg / self.num_sides / 2) |
| 49 | + |
| 50 | + @property |
| 51 | + @abc.abstractmethod |
| 52 | + def radius_mechanical(self) -> u.Quantity | na.AbstractScalar: |
| 53 | + """ |
| 54 | + The radius of the exterior edge of the field stop. |
| 55 | + """ |
| 56 | + |
| 57 | + @property |
| 58 | + def surface(self) -> optika.surfaces.Surface: |
| 59 | + """ |
| 60 | + Represent this object as an :mod:`optika` surface. |
| 61 | + """ |
| 62 | + return optika.surfaces.Surface( |
| 63 | + name="field stop", |
| 64 | + aperture=optika.apertures.RegularPolygonalAperture( |
| 65 | + radius=self.radius_clear, |
| 66 | + num_vertices=self.num_sides, |
| 67 | + ), |
| 68 | + aperture_mechanical=optika.apertures.CircularAperture( |
| 69 | + radius=self.radius_mechanical, |
| 70 | + ), |
| 71 | + is_field_stop=True, |
| 72 | + transformation=self.transformation, |
| 73 | + ) |
| 74 | + |
| 75 | + |
| 76 | +@dataclasses.dataclass(eq=False, repr=False) |
| 77 | +class FieldStop( |
| 78 | + AbstractFieldStop, |
| 79 | +): |
| 80 | + """ |
| 81 | + A model of the field stop of the instrument. |
| 82 | +
|
| 83 | + This element restricts the field of view of the spectrograph to simplify |
| 84 | + the inversion process. |
| 85 | + """ |
| 86 | + |
| 87 | + num_folds: int = 0 |
| 88 | + """ |
| 89 | + The order of the rotational symmetry of the optical system. |
| 90 | + """ |
| 91 | + |
| 92 | + radius_clear: u.Quantity | na.AbstractScalar = 0 * u.mm |
| 93 | + """ |
| 94 | + The distance from the center to a vertex of the clear aperture. |
| 95 | + """ |
| 96 | + |
| 97 | + radius_mechanical: u.Quantity | na.AbstractScalar = 0 * u.mm |
| 98 | + """ |
| 99 | + The radius of the exterior edge of the field stop. |
| 100 | + """ |
| 101 | + |
| 102 | + translation: u.Quantity | na.AbstractCartesian3dVectorArray = 0 * u.mm |
| 103 | + """ |
| 104 | + A transformation which can arbitrarily translate this object. |
| 105 | + """ |
0 commit comments