From 80c371e4257ba11055ed6446256e48c3fce7785e Mon Sep 17 00:00:00 2001 From: Jean Connelly Date: Tue, 15 Mar 2022 18:08:46 -0400 Subject: [PATCH] Handle pitch at 180 --- Ska/Sun/sun.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/Ska/Sun/sun.py b/Ska/Sun/sun.py index 95ec95c..ba83518 100755 --- a/Ska/Sun/sun.py +++ b/Ska/Sun/sun.py @@ -15,7 +15,12 @@ def load_roll_table(): - return Table.read(Path(__file__).parent / 'data' / 'pitch_roll.fits.gz') + dat = Table.read(Path(__file__).parent / 'data' / 'pitch_roll.fits.gz') + + # Add a terminating row to the data such that for pitch at or greater + # than 180 the allowed roll deviation is defined as 0. + dat.add_row({'pitch': 180, 'rolldev': 0}) + return dat ROLL_TABLE = LazyVal(load_roll_table) @@ -28,6 +33,9 @@ def allowed_rolldev(pitch): """ idx0 = np.searchsorted(ROLL_TABLE.val['pitch'], pitch, side='left') idx1 = np.searchsorted(ROLL_TABLE.val['pitch'], pitch, side='right') + idx_max = len(ROLL_TABLE.val) - 1 + idx0 = np.clip(idx0, 0, idx_max) + idx1 = np.clip(idx1, 0, idx_max) # These need some bound checking at the edges val0 = ROLL_TABLE.val['rolldev'][idx0] val1 = ROLL_TABLE.val['rolldev'][idx1]