Skip to content

Commit

Permalink
Merge pull request #705 from dirac-institute/remove_known_obj_check
Browse files Browse the repository at this point in the history
Move known_object counting out of core search
  • Loading branch information
jeremykubica authored Sep 12, 2024
2 parents 32fb22f + a1ef893 commit ab10e23
Show file tree
Hide file tree
Showing 4 changed files with 0 additions and 98 deletions.
17 changes: 0 additions & 17 deletions docs/source/user_manual/results_filtering.rst
Original file line number Diff line number Diff line change
Expand Up @@ -78,20 +78,3 @@ See Also
________

* `DBSCAN <https://scikit-learn.org/stable/modules/generated/sklearn.cluster.DBSCAN.html#sklearn.cluster.DBSCAN>`_

Known Object Matching
---------------------

Known object matching compares found trajectories against known objects from either SkyBot or the JPL Small Bodies API. Specifically, KBMOD uses the WCS in each FITS file to query the location on the sky that is covered by the image. The found trajectories are then compared against the known objects by checking their relative predicted positions in ``(ra, dec)`` at each timestep. Objects that are within the threshold for all timesteps are said to match. The number of known objects and matches are displayed.

Known object matching is included for debugging purposes to provide signals into whether there could be known objects in the images and KBMOD’s ability to extract them. All matching is approximate (e.g. KBMOD uses a linear trajectory model) and matching might not be comprehensive. All scientific studies should conduct their own matching analysis.

Relevant matching parameters include:

* ``known_obj_thresh`` - The matching threshold (in arcseconds) to use. If no threshold is provided (known_obj_thresh = None) then no matching is performed.
* ``known_obj_jpl`` - Use the JPL API instead of SkyBot.

Acknowledgements
----------------

The known object matching uses the `IMCCE's SkyBoT VO tool <https://vo.imcce.fr/webservices/skybot/>`_ (Berthier et. al. 2006) and JPL’s SSD (Solar System Dynamics) `API service <https://ssd.jpl.nasa.gov/>`_. If you use this functionality, please cite the above sources as appropriate.
11 changes: 0 additions & 11 deletions docs/source/user_manual/search_params.rst
Original file line number Diff line number Diff line change
Expand Up @@ -85,17 +85,6 @@ This document serves to provide a quick overview of the existing parameters and
| ``ind_output_files`` | True | Output results to a series of |
| | | individual files. |
+------------------------+-----------------------------+----------------------------------------+
| ``known_obj_obs`` | 3 | The minimum number of observations |
| | | needed to count a known object match. |
+------------------------+-----------------------------+----------------------------------------+
| ``known_obj_jpl`` | False | Use JPL's API (over ``SkyBot``) to |
| | | look up known objects |
| | | (if ``known_obj_thresh!=None``). |
+------------------------+-----------------------------+----------------------------------------+
| ``known_obj_thresh`` | None | The threshold, in arcseconds, used to |
| | | compare results to known objects from |
| | | JPL or SkyBot. |
+------------------------+-----------------------------+----------------------------------------+
| ``lh_level`` | 10.0 | The minimum computed likelihood for an |
| | | object to be accepted. |
+------------------------+-----------------------------+----------------------------------------+
Expand Down
3 changes: 0 additions & 3 deletions src/kbmod/configuration.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,6 @@ def __init__(self):
"gpu_filter": False,
"ind_output_files": True,
"im_filepath": None,
"known_obj_obs": 3,
"known_obj_thresh": None,
"known_obj_jpl": False,
"lh_level": 10.0,
"max_lh": 1000.0,
"mom_lims": [35.5, 35.5, 2.0, 0.3, 0.3],
Expand Down
67 changes: 0 additions & 67 deletions src/kbmod/run_search.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import os
import time

import koffi
import numpy as np

import kbmod.search as kb
Expand Down Expand Up @@ -270,12 +269,6 @@ def run_search(self, config, stack, trj_generator=None):
if config["save_all_stamps"]:
append_all_stamps(keep, stack, config["stamp_radius"])

# TODO - Re-enable the known object counting once we have a way to pass
# A WCS into the WorkUnit.
# Count how many known objects we found.
# if config["known_obj_thresh"]:
# _count_known_matches(keep, search)

# Save the results and the configuration information used.
logger.info(f"Found {len(keep)} potential trajectories.")
if config["res_filepath"] is not None and config["ind_output_files"]:
Expand Down Expand Up @@ -326,63 +319,3 @@ def run_search_from_work_unit(self, work):

# Run the search.
return self.run_search(work.config, work.im_stack)

def _count_known_matches(self, result_list, search):
"""Look up the known objects that overlap the images and count how many
are found among the results.
Parameters
----------
result_list : ``kbmod.ResultList``
The result objects found by the search.
search : ``kbmod.search.StackSearch``
A StackSearch object containing information about the search.
"""
# Get the image metadata
im_filepath = config["im_filepath"]
filenames = sorted(os.listdir(im_filepath))
image_list = [os.path.join(im_filepath, im_name) for im_name in filenames]
metadata = koffi.ImageMetadataStack(image_list)

# Get the pixel positions of results
ps_list = []

times = search.stack.build_zeroed_times()
for row in result_list.results:
trj = row.trajectory
PixelPositions = [[trj.get_x_pos(t), trj.get_y_pos(t)] for t in times]

ps = koffi.PotentialSource()
ps.build_from_images_and_xy_positions(PixelPositions, metadata)
ps_list.append(ps)

matches = {}
known_obj_thresh = config["known_obj_thresh"]
min_obs = config["known_obj_obs"]
if config["known_obj_jpl"]:
logger.info("Querying known objects from JPL.")
matches = koffi.jpl_query_known_objects_stack(
potential_sources=ps_list,
images=metadata,
min_observations=min_obs,
tolerance=known_obj_thresh,
)
else:
logger.info("Querying known objects from SkyBoT.")
matches = koffi.skybot_query_known_objects_stack(
potential_sources=ps_list,
images=metadata,
min_observations=min_obs,
tolerance=known_obj_thresh,
)

matches_string = ""
num_found = 0
for ps_id in matches.keys():
if len(matches[ps_id]) > 0:
num_found += 1
matches_string += f"result id {ps_id}:" + str(matches[ps_id])[1:-1] + "\n"
logger.info(f"Found {num_found} objects with at least {config['num_obs']} potential observations.")

if num_found > 0:
logger.info(f"{matches_string}")

0 comments on commit ab10e23

Please sign in to comment.