Skip to content

Commit

Permalink
Added `esis.flights.f1.optics.gratings.efficiencies.efficiency_vs_ang…
Browse files Browse the repository at this point in the history
…le_3deg()` function.
  • Loading branch information
byrdie committed Mar 22, 2024
1 parent e06b34d commit 76d7575
Show file tree
Hide file tree
Showing 3 changed files with 68 additions and 0 deletions.
Git LFS file not shown
59 changes: 59 additions & 0 deletions esis/flights/f1/optics/gratings/efficiencies/_efficiencies.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
"efficiency_vs_x",
"efficiency_vs_y",
"efficiency_vs_angle_0deg",
"efficiency_vs_angle_3deg",
]

_directory_data = pathlib.Path(__file__).parent / "_data"
Expand Down Expand Up @@ -235,3 +236,61 @@ def efficiency_vs_angle_0deg() -> (
),
outputs=efficiency,
)


def efficiency_vs_angle_3deg() -> (
na.FunctionArray[na.TemporalSpectralDirectionalVectorArray, na.ScalarArray]
):
"""
The total (coating + groove) efficiency of the ESIS diffraction gratings
as a function of output angle as measured by Eric Gullikson at an input
angle of 3 degrees.
Examples
--------
Plot the efficiency vs output angle measurements using matplotlib.
.. jupyter-execute::
import matplotlib.pyplot as plt
import named_arrays as na
from esis.flights.f1.optics import gratings
# Load the efficiency measurements
efficiency = gratings.efficiencies.efficiency_vs_angle_3deg()
# Plot the measurements using matplotlib
fig, ax = plt.subplots()
na.plt.plot(
efficiency.inputs.direction.output,
efficiency.outputs,
ax=ax,
label=efficiency.inputs.direction.input,
);
ax.set_xlabel(f"output angle ({efficiency.inputs.direction.input.unit:latex_inline})");
ax.set_ylabel(f"efficiency");
ax.legend();
"""

angle, efficiency = np.loadtxt(
fname=_directory_data / "mul063281.txt",
unpack=True,
skiprows=1,
)

angle = angle << u.deg

angle = na.ScalarArray(angle, axes="grating_output_angle")
efficiency = na.ScalarArray(efficiency, axes="grating_output_angle")

return na.FunctionArray(
inputs=na.TemporalSpectralDirectionalVectorArray(
time=time_measurement,
wavelength=63 * u.nm,
direction=na.InputOutputVectorArray(
input=3 * u.deg,
output=angle,
),
),
outputs=efficiency,
)
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,9 @@ def test_efficiency_vs_angle_0deg():
result = esis.flights.f1.optics.gratings.efficiencies.efficiency_vs_angle_0deg()
assert np.all(result.inputs.direction.input.unit.is_equivalent(u.deg))
assert np.all(result.outputs > -0.01)


def test_efficiency_vs_angle_3deg():
result = esis.flights.f1.optics.gratings.efficiencies.efficiency_vs_angle_3deg()
assert np.all(result.inputs.direction.input.unit.is_equivalent(u.deg))
assert np.all(result.outputs > -0.01)

0 comments on commit 76d7575

Please sign in to comment.