Skip to content

Commit

Permalink
Add ACACatalog.agasc_file attribute for AGASC provenance
Browse files Browse the repository at this point in the history
  • Loading branch information
taldcroft committed Oct 2, 2023
1 parent d10f857 commit 36ba927
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 0 deletions.
4 changes: 4 additions & 0 deletions proseco/catalog.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,10 @@ def _get_aca_catalog(**kwargs):
# Get stars (typically from AGASC) and do not filter for stars near
# the ACA FOV. This leaves the full radial selection available for
# later roll optimization. Use aca.stars or aca.acqs.stars from here.
# Set the agasc_file MetaAttribute if it is available in the stars table meta.
aca.set_stars(filter_near_fov=False)
if "agasc_file" in aca.stars.meta:
aca.agasc_file = aca.stars.meta["agasc_file"]

aca.log("Starting get_acq_catalog")
aca.acqs = get_acq_catalog(stars=aca.stars, **kwargs)
Expand Down Expand Up @@ -302,6 +305,7 @@ class ACATable(ACACatalogTable):
optimize = MetaAttribute(default=True)
call_args = MetaAttribute(default={})
version = MetaAttribute()
agasc_file = MetaAttribute(is_kwarg=False)

# For validation with get_aca_catalog(obsid), store the starcheck
# catalog in the ACATable meta.
Expand Down
2 changes: 2 additions & 0 deletions proseco/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -1305,6 +1305,8 @@ def empty(cls, att=(0, 0, 0)):
:returns: StarsTable of stars (empty)
"""
stars = cls.from_agasc(att, radius=-1)
# Remove "agasc_file" meta key since it does not apply for a synthetic table.
del stars.meta["agasc_file"]
stars.att = att

return stars
Expand Down
4 changes: 4 additions & 0 deletions proseco/tests/test_catalog.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ def test_get_aca_catalog_20603(proseco_agasc_1p7):
aca.fids.plot()

assert aca.dark_date == "2018:100"
assert Path(aca.agasc_file).name == "proseco_agasc_1p7.h5"


@pytest.mark.skipif(not HAS_SC_ARCHIVE, reason="Test requires starcheck archive")
Expand Down Expand Up @@ -274,6 +275,9 @@ def test_pickle():
stars.add_fake_constellation(mag=10.0, n_stars=5)
aca = get_aca_catalog(stars=stars, dark=DARK40, raise_exc=True, **STD_INFO)

# Fake stars do not have an agasc_file attribute
assert "agasc_file" not in aca.stars.meta

aca2 = pickle.loads(pickle.dumps(aca))

assert repr(aca) == repr(aca2)
Expand Down

0 comments on commit 36ba927

Please sign in to comment.