Skip to content

Commit

Permalink
formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
laspsandoval committed Aug 5, 2024
1 parent 5f57aa8 commit e6165d0
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 31 deletions.
4 changes: 2 additions & 2 deletions imap_processing/tests/ultra/unit/test_ultra_l1b_extended.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ def test_get_front_x_position(
de_dataset["START_POS_TDC"].data,
)

assert xf == pytest.approx(df_filt["Xf"].astype("float"), 1e-3)
assert xf == pytest.approx(df_filt["Xf"].astype("float"), 1e-5)


def test_get_front_y_position(
Expand All @@ -39,4 +39,4 @@ def test_get_front_y_position(
de_dataset["START_TYPE"].data, df_filt.Yb.values.astype("float")
)

assert yf == pytest.approx(df_filt["Yf"].astype("float"), abs=1e-3)
assert yf == pytest.approx(df_filt["Yf"].astype("float"), abs=1e-5)
9 changes: 9 additions & 0 deletions imap_processing/ultra/l1b/l1b_extended_config.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
"""Extended Raw Events for ULTRA L1b Constants."""

# Constants in IMAP-Ultra Flight Software Specification document.
D_SLIT_FOIL = 3.39 # shortest distance from slit to foil (mm)
SLIT_Z = 44.89 # position of slit on Z axis (mm)
YF_ESTIMATE_LEFT = 40.0 # front position of particle for left shutter (mm)
YF_ESTIMATE_RIGHT = -40 # front position of particle for right shutter (mm)
N_ELEMENTS = 256 # number of elements in lookup table
TRIG_CONSTANT = 81.92 # trigonometric constant (mm)
47 changes: 18 additions & 29 deletions imap_processing/ultra/l1b/ultra_l1b_extended.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,14 @@

import numpy as np

from imap_processing.ultra.l1b.l1b_extended_config import (
D_SLIT_FOIL,
N_ELEMENTS,
SLIT_Z,
TRIG_CONSTANT,
YF_ESTIMATE_LEFT,
YF_ESTIMATE_RIGHT,
)
from imap_processing.ultra.l1b.lookup_utils import (
get_image_params,
get_y_adjust,
Expand Down Expand Up @@ -71,56 +79,37 @@ def get_front_y_position(
yf : np.array
Front y position in hundredths of a millimeter.
"""
# df in IMAP-Ultra Flight Software Specification document.
d_slit_foil = 3.39 # shortest distance from slit to foil (mm)
# z_ds in IMAP-Ultra Flight Software Specification document.
slit_z = 44.89 # position of slit on Z axis (mm)

# Determine start types
start_type_left = start_type == 1
start_type_right = start_type == 2
index_array = np.arange(len(start_type))
index_left = index_array[start_type_left]
index_right = index_array[start_type_right]
index_left = np.where(start_type == 1)
index_right = np.where(start_type == 2)

yf = np.zeros(len(start_type))
d = np.zeros(len(start_type))

# front position of particle for left shutter (mm)
yf_estimate_left = 40.0
# front position of particle for right shutter (mm)
yf_estimate_right = -40.0
# number of elements in lookup table (pg 38)
n_elements = 256
# trigonometric constant (mm) (pg 38)
trig_constant = 81.92

# Compute adjustments for left start type
dy_lut_left = np.floor(
(yf_estimate_left - yb[start_type_left] / 100) * n_elements / trig_constant
+ 0.5
(YF_ESTIMATE_LEFT - yb[index_left] / 100) * N_ELEMENTS / TRIG_CONSTANT + 0.5
)
# y adjustment in mm
y_adjust_left = get_y_adjust(dy_lut_left) / 100
# hundredths of a millimeter
yf[index_left] = (yf_estimate_left - y_adjust_left) * 100
yf[index_left] = (YF_ESTIMATE_LEFT - y_adjust_left) * 100
# distance adjustment in mm
distance_adjust_left = np.sqrt(2) * d_slit_foil - y_adjust_left
distance_adjust_left = np.sqrt(2) * D_SLIT_FOIL - y_adjust_left
# hundredths of a millimeter
d[index_left] = (slit_z - distance_adjust_left) * 100
d[index_left] = (SLIT_Z - distance_adjust_left) * 100

# Compute adjustments for right start type
dy_lut_right = np.floor(
(yb[start_type_right] / 100 - yf_estimate_right) * n_elements / trig_constant
+ 0.5
(yb[index_right] / 100 - YF_ESTIMATE_RIGHT) * N_ELEMENTS / TRIG_CONSTANT + 0.5
)
# y adjustment in mm
y_adjust_right = get_y_adjust(dy_lut_right) / 100
# hundredths of a millimeter
yf[index_right] = (yf_estimate_right + y_adjust_right) * 100
yf[index_right] = (YF_ESTIMATE_RIGHT + y_adjust_right) * 100
# distance adjustment in mm
distance_adjust_right = np.sqrt(2) * d_slit_foil - y_adjust_right
distance_adjust_right = np.sqrt(2) * D_SLIT_FOIL - y_adjust_right
# hundredths of a millimeter
d[index_right] = (slit_z - distance_adjust_right) * 100
d[index_right] = (SLIT_Z - distance_adjust_right) * 100

return d, yf

0 comments on commit e6165d0

Please sign in to comment.