Skip to content

Commit

Permalink
Use single date for agasc1p8 promotion (#333)
Browse files Browse the repository at this point in the history
Use single date for agasc1p8 promotion and set date_start_agasc1p8 to the AUG0524B loads starting time
  • Loading branch information
javierggt authored Aug 22, 2024
1 parent e2bd456 commit 72bba92
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 41 deletions.
34 changes: 7 additions & 27 deletions kadi/commands/observations.py
Original file line number Diff line number Diff line change
Expand Up @@ -151,37 +151,17 @@ def set_star_ids(aca: dict) -> None:
"""
from kadi.config import conf

date = aca["meta"]["date"]
if date < conf.date_start_agasc1p8_earliest:
# Always 1p7 before 2024-July-21 (before JUL2224 loads)
versions = ["1p7"]
elif date < conf.date_start_agasc1p8_latest:
# Could be 1p8 or 1p7 within 30 days later (uncertainty in promotion date)
versions = ["1p8", "1p7"]
else:
# Always 1p8 after 30 days after JUL2224
versions = ["1p8"]
version = "1p7" if aca["meta"]["date"] < conf.date_start_agasc1p8 else "1p8"

# Try allowed versions and stop on first success. If no success then issue warning.
# Try the AGASC version for that date. If no success then issue warning.
# Be aware that _set_star_ids works in place so the try/except is not atomic so the
# ``aca`` dict can be partially updated. This is not expected to be an issue in
# practice, and a warning is issue in any case.
err_star_id = None
for version in versions:
try:
agasc_file = agasc.get_agasc_filename(version=version)
except FileNotFoundError:
logger.warning(f"AGASC {version} file not found")
continue
try:
_set_star_ids(aca, agasc_file)
except StarIdentificationFailed as err:
err_star_id = err
else:
break
else:
# All versions failed, issue warning
logger.warning(str(err_star_id))
agasc_file = agasc.get_agasc_filename(version=version)
try:
_set_star_ids(aca, agasc_file)
except StarIdentificationFailed as err:
logger.warning(str(err))


def _set_star_ids(aca: dict, agasc_file: str) -> None:
Expand Down
11 changes: 5 additions & 6 deletions kadi/commands/tests/test_commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -841,14 +841,14 @@ def test_get_starcats_each_year(year):
assert np.all(starcat["id"][ok] != -999)


def test_get_starcat_agasc1p8_then_1p7():
def test_get_starcat_only_agasc1p7():
"""
For obsid 2576, try AGASC 1.8 then fall back to 1.7 and show successful star
For obsids 3829 and 2576, try AGASC 1.7 only and show successful star
identification.
"""
with (
conf.set_temp("cache_starcats", False),
conf.set_temp("date_start_agasc1p8_earliest", "1994:001"),
conf.set_temp("date_start_agasc1p8", "2003:001"),
):
starcat = get_starcats(
"2002:365:18:00:00", "2002:365:19:00:00", scenario="flight"
Expand All @@ -865,10 +865,9 @@ def test_get_starcat_only_agasc1p8():
"""
with (
conf.set_temp("cache_starcats", False),
conf.set_temp("date_start_agasc1p8_earliest", "1994:001"),
conf.set_temp("date_start_agasc1p8_latest", "1994:002"),
conf.set_temp("date_start_agasc1p8", "1994:001"),
):
# Force AGASC 1.7 and show that star identification fails
# Force AGASC 1.8 and show that star identification fails
with ska_helpers.utils.set_log_level(kadi.logger, "CRITICAL"):
starcats = get_starcats(
"2002:365:16:00:00", "2002:365:19:00:00", scenario="flight"
Expand Down
11 changes: 3 additions & 8 deletions kadi/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,14 +68,9 @@ class Conf(ConfigNamespace):
False, "Include In-work command events that are not yet approved."
)

date_start_agasc1p8_earliest = ConfigItem(
"2024:210", # 2024-July-28
"Start date (earliest) for using AGASC 1.8 catalog.",
)

date_start_agasc1p8_latest = ConfigItem(
"2024:233", # 2024-July-28 + 23 days
"Start date (latest) for using AGASC 1.8 catalog.",
date_start_agasc1p8 = ConfigItem(
"2024:217:21:59:00", # 2024-08-04, start of AUG0524B loads
"Start date for using AGASC 1.8 catalog.",
)


Expand Down

0 comments on commit 72bba92

Please sign in to comment.