From 9bbf8cb9a3073eca18681da9e3a61668f3ee8bf1 Mon Sep 17 00:00:00 2001 From: Roy Smart Date: Mon, 25 Mar 2024 00:05:19 -0600 Subject: [PATCH] Updating to use latest version of `optika.rulings`. --- esis/flights/f1/optics/models.py | 17 ++--------------- esis/flights/f2/optics/models.py | 11 ++++++++--- esis/optics/_models.py | 6 +++--- esis/optics/_tests/test_gratings.py | 6 +++++- esis/optics/_tests/test_models.py | 6 +++++- 5 files changed, 23 insertions(+), 23 deletions(-) diff --git a/esis/flights/f1/optics/models.py b/esis/flights/f1/optics/models.py index 6ce8c8e..382e7c4 100644 --- a/esis/flights/f1/optics/models.py +++ b/esis/flights/f1/optics/models.py @@ -161,21 +161,8 @@ def design_full( ), ), material=optika.materials.Mirror(), - rulings=optika.rulings.PolynomialSpacingRulings( - coefficients={ - 0: 1 / density_grating_rulings, - 1: na.UniformUncertainScalarArray( - nominal=-3.3849e-5 * (u.um / u.mm), - width=0.0512e-5 * (u.um / u.mm), - num_distribution=num_distribution, - ), - 2: na.UniformUncertainScalarArray( - nominal=-1.3625e-7 * (u.um / u.mm**2), - width=0.08558e-7 * (u.um / u.mm**2), - num_distribution=num_distribution, - ), - }, - diffraction_order=1, + rulings=esis.flights.f1.optics.gratings.rulings.ruling_design( + num_distribution=num_distribution, ), num_folds=num_folds, halfwidth_inner=13.02 * u.mm - width_grating_border_inner, diff --git a/esis/flights/f2/optics/models.py b/esis/flights/f2/optics/models.py index 0aca6ca..443c447 100644 --- a/esis/flights/f2/optics/models.py +++ b/esis/flights/f2/optics/models.py @@ -75,9 +75,14 @@ def design_proposed( num_distribution=num_distribution, ) - result.grating.rulings.coefficients[0].nominal = 1 / (2700 / u.mm) - result.grating.rulings.coefficients[1].nominal = -2.852e-5 * (u.um / u.mm) - result.grating.rulings.coefficients[2].nominal = -2.112e-7 * (u.um / u.mm**2) + c0 = 1 / (2700 / u.mm) + c1 = -2.852e-5 * (u.um / u.mm) + c2 = -2.112e-7 * (u.um / u.mm ** 2) + + result.grating.rulings.spacing.coefficients[0].nominal = c0 + result.grating.rulings.spacing.coefficients[1].nominal = c1 + result.grating.rulings.spacing.coefficients[2].nominal = c2 + result.grating.yaw = -3.65 * u.deg z_filter = result.grating.translation.z.nominal + 1291.012 * u.mm diff --git a/esis/optics/_models.py b/esis/optics/_models.py index f7f1ff2..5cf3744 100644 --- a/esis/optics/_models.py +++ b/esis/optics/_models.py @@ -76,7 +76,7 @@ def angle_grating_input(self) -> na.AbstractScalar: grating = self.grating.surface position = na.Cartesian3dVectorArray() * u.mm normal_surface = grating.sag.normal(position) - normal_rulings = grating.rulings.normal(position) + normal_rulings = grating.rulings.spacing_(position).normalized transformation = grating.transformation.inverse @ fs.transformation wire = np.moveaxis( a=fs.aperture.wire(), @@ -102,7 +102,7 @@ def angle_grating_output(self) -> na.AbstractScalar: grating = self.grating.surface position = na.Cartesian3dVectorArray() * u.mm normal_surface = grating.sag.normal(position) - normal_rulings = grating.rulings.normal(position) + normal_rulings = grating.rulings.spacing_(position).normalized transformation = grating.transformation.inverse @ detector.transformation wire = np.moveaxis( a=detector.aperture.wire(), @@ -120,7 +120,7 @@ def _wavelength_test_grid(self) -> na.AbstractScalar: position = na.Cartesian3dVectorArray() * u.mm grating = self.grating.surface m = grating.rulings.diffraction_order - d = grating.rulings.spacing(position) + d = grating.rulings.spacing_(position).length a = self.angle_grating_input b = self.angle_grating_output result = (np.sin(a) + np.sin(b)) * d / m diff --git a/esis/optics/_tests/test_gratings.py b/esis/optics/_tests/test_gratings.py index 32dfafe..e9f7e17 100644 --- a/esis/optics/_tests/test_gratings.py +++ b/esis/optics/_tests/test_gratings.py @@ -131,7 +131,11 @@ def test_surface( manufacturing_number="ABCD", sag=optika.sags.SphericalSag(500 * u.mm), material=optika.materials.Mirror(), - rulings=optika.rulings.ConstantDensityRulings(5000 / u.mm), + rulings=optika.rulings.SawtoothRulings( + spacing=5000 / u.mm, + depth=10 * u.nm, + diffraction_order=1, + ), num_folds=8, halfwidth_inner=10 * u.mm, halfwidth_outer=15 * u.mm, diff --git a/esis/optics/_tests/test_models.py b/esis/optics/_tests/test_models.py index 3ac1219..5b280dd 100644 --- a/esis/optics/_tests/test_models.py +++ b/esis/optics/_tests/test_models.py @@ -111,7 +111,11 @@ def test_system(self, a: esis.optics.abc.AbstractOpticsModel): manufacturing_number="123abc", sag=optika.sags.SphericalSag(radius=500 * u.mm), material=optika.materials.Mirror(), - rulings=optika.rulings.ConstantDensityRulings(5000 / u.mm), + rulings=optika.rulings.SawtoothRulings( + spacing=1 * u.um, + depth=10 * u.nm, + diffraction_order=1, + ), num_folds=8, halfwidth_inner=15 * u.mm, halfwidth_outer=10 * u.mm,