Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add pitch, attitude constraints and 2- and 3-star solutions #31

Merged
merged 34 commits into from
Aug 19, 2024
Merged
Changes from 1 commit
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
b2c4e54
Include healpix index in distances h5
taldcroft Jul 14, 2024
3bf3832
Support attitude and normal sun constraints
taldcroft Jul 15, 2024
522026b
Ignore notebooks in ruff
taldcroft Jul 17, 2024
ef494a5
Define min stars based on sky area
taldcroft Jul 17, 2024
cd48118
Ruff format
taldcroft Jul 18, 2024
46db7b3
Add pix1 (healpix index of other star in pair)
taldcroft Jul 23, 2024
fb29af6
More ruff
taldcroft Jul 29, 2024
2ab82a2
Ensure test stars are all on CCD
taldcroft Jul 29, 2024
8a1085f
Refactor attitude constraints into dataclass
taldcroft Jul 29, 2024
9b27822
Use constraints date for star proper motion + other tidy
taldcroft Jul 30, 2024
17e229e
Use faster approx code for healpixels within annulus
taldcroft Jul 30, 2024
32a1e09
Allow package level import
taldcroft Jul 31, 2024
e225948
Add get_stars_from_maude() function
taldcroft Jul 31, 2024
7a136d0
Add off_nom_roll_max constraint and fix other issues
taldcroft Jul 31, 2024
7d08009
Nominally working 2 and 3-star solutions
taldcroft Aug 2, 2024
463f398
More tweaks, mostly working for 2, 3 stars
taldcroft Aug 5, 2024
c975026
Fix silly bug in test_find_attitude
taldcroft Aug 5, 2024
ba15b9a
Logging improvements
taldcroft Aug 5, 2024
23b0868
Require only 2 stars to match AGASC ID exactly in testing
taldcroft Aug 5, 2024
ff3e3ae
Add test-find-attitude notebook
taldcroft Aug 5, 2024
3669205
Better logging control in testing notebook
taldcroft Aug 5, 2024
3205072
Replace normal_sun constraint with pitch constraint
taldcroft Aug 5, 2024
2a0b175
Default min_stars=3 even for attitude constraint
taldcroft Aug 5, 2024
195298f
More tweaks/fixes
taldcroft Aug 7, 2024
c2635e7
Change att/pitch_radius to att/pitch_err
taldcroft Aug 7, 2024
2a42865
Add slots arg to get_stars_from_maude
taldcroft Aug 7, 2024
6c8542c
Version of notebook to present to SSAWG
taldcroft Aug 7, 2024
9e3fa6d
Add tests of constraints
taldcroft Aug 7, 2024
b978fff
Add mag to summary, add test, fix test bug
taldcroft Aug 14, 2024
3f554da
Add find-attitude notebook
taldcroft Aug 14, 2024
df81a00
Minor fixes / tweaks
taldcroft Aug 14, 2024
4876460
Add min_stars and delta_mag to constraints; simplify min_stars logic
taldcroft Aug 15, 2024
41cd667
Ruff fixes
taldcroft Aug 15, 2024
db8f289
Documentation updates per review
taldcroft Aug 19, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Define min stars based on sky area
  • Loading branch information
taldcroft committed Jul 28, 2024
commit ef494a584cfd5d99fea8c2b3e12c125b4016b7e4
49 changes: 37 additions & 12 deletions find_attitude/find_attitude.py
Original file line number Diff line number Diff line change
@@ -240,7 +240,7 @@ def add_edge(graph, id0, id1, i0, i1, dist):
edge["i1"].append(i1)


def connected_agasc_ids(ap):
def connected_agasc_ids(ap, min_stars):
"""Return agacs_ids that occur at least 4 times.

Each occurrence indicates an edge containing that agasc_id node.
@@ -251,7 +251,7 @@ def connected_agasc_ids(ap):
agasc_ids = np.concatenate((ap["agasc_id0"], ap["agasc_id1"]))
c = Column(agasc_ids)
cg = c.group_by(c)
i_big_enough = np.flatnonzero(np.diff(cg.groups.indices) >= 3)
i_big_enough = np.flatnonzero(np.diff(cg.groups.indices) >= min_stars - 1)
out = set(cg.groups.keys[i_big_enough].tolist())

return out
@@ -280,6 +280,8 @@ def get_match_graph(aca_pairs, agasc_pairs, tolerance, healpix_indices=None):
mag0s = aca_pairs["mag0"]
mag1s = aca_pairs["mag1"]

min_stars = get_min_stars(healpix_indices)

logger.info("Starting get_match_graph")
gmatch = nx.Graph()
ap_list = []
@@ -307,12 +309,10 @@ def get_match_graph(aca_pairs, agasc_pairs, tolerance, healpix_indices=None):
ap_list.append(ap)
logger.debug(" Found {} matching pairs".format(len(ap)))

ap = vstack(
ap_list
) # Vertically stack the individual AGASC pairs tables into one big table
connected_ids = connected_agasc_ids(
ap
) # Find nodes with at least three connections
# Vertically stack the individual AGASC pairs tables into one big table
ap = vstack(ap_list)
# Find nodes with at least (min_stars - 1) connections
connected_ids = connected_agasc_ids(ap, min_stars)

agasc_id0 = ap["agasc_id0"]
agasc_id1 = ap["agasc_id1"]
@@ -333,6 +333,30 @@ def get_match_graph(aca_pairs, agasc_pairs, tolerance, healpix_indices=None):
return gmatch


def get_min_stars(healpix_indices):
"""Minimum number of stars required for an attitude solution.

This is somewhat arbitrary, but the number of healpix indices corresponds to sky
area and is a decent proxy for the number of stars that will be found in the
matching process.
"""
# Formula for number of pixels for nside
npix = get_agasc_pairs_attribute("healpix_nside") ** 2 * 12

if healpix_indices is None:
min_stars = 4
elif len(healpix_indices) < npix / 100:
# Typically where an estimated attitude is supplied
min_stars = 2
elif len(healpix_indices) < npix / 10:
# Typically for normal_sun=True
min_stars = 3
else:
min_stars = 4

return min_stars


def get_slot_id_candidates(graph, nodes):
"""Get list of candidates which map node AGASC ID to ACA star catalog index number.

@@ -644,11 +668,12 @@ def find_attitude_solutions(stars, tolerance=2.5, healpix_indices=None):

:returns: list of solutions, where each solution is a dict
"""
if len(stars) < 4:
min_stars = get_min_stars(healpix_indices)

if len(stars) < min_stars:
raise ValueError(
"need at least 4 stars for matching, only {} were provided".format(
len(stars)
)
f"need at least {min_stars} stars for matching,"
f" only {len(stars)} were provided"
)

agasc_id_star_maps = find_all_matching_agasc_ids(