Skip to content

Commit

Permalink
update spot number calculation
Browse files Browse the repository at this point in the history
  • Loading branch information
JessicaS11 committed Oct 17, 2023
1 parent 1d53341 commit 332a923
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 17 deletions.
23 changes: 14 additions & 9 deletions icepyx/core/is2ref.py
Original file line number Diff line number Diff line change
Expand Up @@ -265,8 +265,11 @@ def _default_varlists(product):
return common_list


# dev goal: check and test this function
def gt2spot(gt, sc_orient):
warnings.warn(
"icepyx versions 0.8.0 and earlier used an incorrect spot number calculation.",
"As a result, computations depending on spot number may be incorrect and should be redone.",
)

assert gt in [
"gt1l",
Expand All @@ -280,39 +283,41 @@ def gt2spot(gt, sc_orient):
gr_num = np.uint8(gt[2])
gr_lr = gt[3]

# spacecraft oriented forward
if sc_orient == 1:
if gr_num == 1:
if gr_lr == "l":
spot = 2
spot = 6
elif gr_lr == "r":
spot = 1
spot = 5
elif gr_num == 2:
if gr_lr == "l":
spot = 4
elif gr_lr == "r":
spot = 3
elif gr_num == 3:
if gr_lr == "l":
spot = 6
spot = 2
elif gr_lr == "r":
spot = 5
spot = 1

# spacecraft oriented backward
elif sc_orient == 0:
if gr_num == 1:
if gr_lr == "l":
spot = 5
spot = 1
elif gr_lr == "r":
spot = 6
spot = 2
elif gr_num == 2:
if gr_lr == "l":
spot = 3
elif gr_lr == "r":
spot = 4
elif gr_num == 3:
if gr_lr == "l":
spot = 1
spot = 5
elif gr_lr == "r":
spot = 2
spot = 6

if "spot" not in locals():
raise ValueError("Could not compute the spot number.")
Expand Down
16 changes: 8 additions & 8 deletions icepyx/tests/test_is2ref.py
Original file line number Diff line number Diff line change
Expand Up @@ -556,12 +556,12 @@ def test_unsupported_default_varlist():
def test_gt2spot_sc_orient_1():
# gt1l
obs = is2ref.gt2spot("gt1l", 1)
expected = 2
expected = 6
assert obs == expected

# gt1r
obs = is2ref.gt2spot("gt1r", 1)
expected = 1
expected = 5
assert obs == expected

# gt2l
Expand All @@ -576,24 +576,24 @@ def test_gt2spot_sc_orient_1():

# gt3l
obs = is2ref.gt2spot("gt3l", 1)
expected = 6
expected = 2
assert obs == expected

# gt3r
obs = is2ref.gt2spot("gt3r", 1)
expected = 5
expected = 1
assert obs == expected


def test_gt2spot_sc_orient_0():
# gt1l
obs = is2ref.gt2spot("gt1l", 0)
expected = 5
expected = 1
assert obs == expected

# gt1r
obs = is2ref.gt2spot("gt1r", 0)
expected = 6
expected = 2
assert obs == expected

# gt2l
Expand All @@ -608,10 +608,10 @@ def test_gt2spot_sc_orient_0():

# gt3l
obs = is2ref.gt2spot("gt3l", 0)
expected = 1
expected = 5
assert obs == expected

# gt3r
obs = is2ref.gt2spot("gt3r", 0)
expected = 2
expected = 6
assert obs == expected

0 comments on commit 332a923

Please sign in to comment.