Skip to content

Commit

Permalink
fix spot number calculation (#458)
Browse files Browse the repository at this point in the history
---------

Co-authored-by: GitHub Action <[email protected]>
  • Loading branch information
JessicaS11 and jpswinski committed Jan 5, 2024
1 parent 578c669 commit 0591de2
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 20 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
6 changes: 3 additions & 3 deletions icepyx/core/visualization.py
Original file line number Diff line number Diff line change
Expand Up @@ -334,9 +334,9 @@ def request_OA_data(self, paras) -> da.array:
"""

warnings.warn(
"NOTICE: visualizations requiring the OpenAltimetry API are currently (October 2023) ",
"unavailable while hosting of OpenAltimetry transitions from UCSD to NSIDC.",
"A ticket has been issued to restore programmatic API access.",
"NOTICE: visualizations requiring the OpenAltimetry API are currently (October 2023) "
"unavailable while hosting of OpenAltimetry transitions from UCSD to NSIDC."
"A ticket has been issued to restore programmatic API access."
)

base_url = "http://openaltimetry.earthdatacloud.nasa.gov/data/api/icesat2"
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 0591de2

Please sign in to comment.