Skip to content

Commit

Permalink
Added `esis.flights.f1.optics.gratings.efficiencies.efficiency_vs_y()…
Browse files Browse the repository at this point in the history
…` function.
  • Loading branch information
byrdie committed Mar 22, 2024
1 parent c29fec7 commit 521ea13
Show file tree
Hide file tree
Showing 3 changed files with 64 additions and 0 deletions.
Git LFS file not shown
55 changes: 55 additions & 0 deletions esis/flights/f1/optics/gratings/efficiencies/_efficiencies.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
__all__ = [
"efficiency_vs_wavelength",
"efficiency_vs_x",
"efficiency_vs_y",
]

_directory_data = pathlib.Path(__file__).parent / "_data"
Expand Down Expand Up @@ -121,3 +122,57 @@ def efficiency_vs_x() -> (
),
outputs=efficiency,
)


def efficiency_vs_y() -> (
na.FunctionArray[na.TemporalSpectralPositionalVectorArray, na.ScalarArray]
):
"""
The total (coating + groove) efficiency of the ESIS diffraction gratings
as a function of :math:`y` position as measured by Eric Gullikson.
Examples
--------
Plot the efficiency vs :math:`y` position 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_y()
# Plot the measurements using matplotlib
fig, ax = plt.subplots()
na.plt.plot(
efficiency.inputs.position,
efficiency.outputs,
ax=ax,
label=efficiency.inputs.time.strftime("%Y-%m-%d"),
);
ax.set_xlabel(f"$y$ ({efficiency.inputs.position.unit:latex_inline})");
ax.set_ylabel(f"efficiency");
ax.legend();
"""

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

y = y << u.mm

y = na.ScalarArray(y, axes="grating_y")
efficiency = na.ScalarArray(efficiency, axes="grating_y")

return na.FunctionArray(
inputs=na.TemporalSpectralPositionalVectorArray(
time=time_measurement,
wavelength=63 * u.nm,
position=y,
),
outputs=efficiency,
)
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,9 @@ def test_efficiency_vs_x():
result = esis.flights.f1.optics.gratings.efficiencies.efficiency_vs_x()
assert np.all(result.inputs.position.unit.is_equivalent(u.mm))
assert np.all(result.outputs > -0.01)


def test_efficiency_vs_y():
result = esis.flights.f1.optics.gratings.efficiencies.efficiency_vs_y()
assert np.all(result.inputs.position.unit.is_equivalent(u.mm))
assert np.all(result.outputs > -0.01)

0 comments on commit 521ea13

Please sign in to comment.