Skip to content

Commit a67aab8

Browse files
update readme + help string in cli
1 parent 3e76648 commit a67aab8

File tree

2 files changed

+53
-20
lines changed

2 files changed

+53
-20
lines changed

README.md

Lines changed: 31 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,41 @@ Find moving objects in detection catalogs.
44

55
<img width="960" height="720" alt="image" src="https://github.com/user-attachments/assets/1ce78a36-8a80-4db7-97bc-27c4a7e2d67f"/>
66

7-
Usage ([docs/notebooks/search.ipynb](https://github.com/stevenstetzler/find_asteroids/tree/main/docs/notebooks/search.ipynb))
8-
97
Installation via PyPI:
108
```bash
119
$ python -m pip install find-asteroids
1210
```
1311

12+
Usage ([docs/notebooks/search.ipynb](https://github.com/stevenstetzler/find_asteroids/tree/main/docs/notebooks/search.ipynb)):
13+
```
14+
$ find_asteroids --help
15+
usage: find_asteroids.search [-h] --catalog CATALOG [--psfs PSFS] --velocity VELOCITY VELOCITY --angle ANGLE
16+
ANGLE --dx DX --num-results NUM_RESULTS --results-dir RESULTS_DIR [--precompute]
17+
[--gpu] [--gpu-kernels] [--device DEVICE] [--output-format OUTPUT_FORMAT]
18+
19+
optional arguments:
20+
-h, --help show this help message and exit
21+
--catalog CATALOG The detection catalog to search. An astropy-readable table containing at least 'ra',
22+
'dec', and 'time' columns (with units). (default: None)
23+
--psfs PSFS An astropy-readable table containing a 'psf' column (with units) that specifies the PSF-
24+
widths of the images from which the detection catalog is derived. If not provided, a
25+
value of 1 arcsec is assumed. (default: None)
26+
--velocity VELOCITY VELOCITY
27+
The velocity range over which to search, in units of deg/day. (default: None)
28+
--angle ANGLE ANGLE The on-sky angles over which to search, in units of deg. (default: None)
29+
--dx DX Search bin-width, in units of the PSF-width. (default: None)
30+
--num-results NUM_RESULTS
31+
Number of results to produce. (default: None)
32+
--results-dir RESULTS_DIR
33+
The directory into which to write results. (default: None)
34+
--precompute Precompute projected positions of detections for all trial velocities (uses more memory,
35+
but may be faster). (default: False)
36+
--gpu Run the core-search components of the algorithm on GPU. (default: False)
37+
--gpu-kernels Run the entirety of the search algorithm on the GPU. (default: False)
38+
--device DEVICE The GPU device number to use. (default: -1)
39+
--output-format OUTPUT_FORMAT
40+
The astropy.table supported format for writing results. (default: ecsv)
41+
```
42+
1443
References:
1544
- Stetzler, S. et al. (2025) An Efficient Shift-and-Stack Algorithm Applied to Detection Catalogs

src/find_asteroids/search.py

Lines changed: 22 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -173,29 +173,33 @@ def find_clusters_bins(X, bins, hough, n=10):
173173

174174
def main():
175175
import argparse
176-
parser = argparse.ArgumentParser(prog=__name__)
177-
parser.add_argument("--psfs", required=True, type=Path)
178-
parser.add_argument("--catalog", required=True, type=Path)
179-
parser.add_argument("--dx", required=True, type=float)
180-
parser.add_argument("--velocity", required=True, nargs=2, type=float)
181-
parser.add_argument("--angle", required=True, nargs=2, type=float)
182-
parser.add_argument("--threshold", required=True, type=int)
183-
parser.add_argument("--results-dir", type=Path, required=True)
184-
parser.add_argument("--precompute", action='store_true')
185-
parser.add_argument("--gpu", action='store_true')
186-
parser.add_argument("--gpu-kernels", action='store_true')
187-
parser.add_argument("--device", type=int, required=False, default=-1)
188-
parser.add_argument("--output-format", type=str, default='ecsv')
176+
parser = argparse.ArgumentParser(prog="find_asteroids", formatter_class=argparse.ArgumentDefaultsHelpFormatter)
177+
parser.add_argument("--catalog", required=True, type=Path, help="The detection catalog to search. An astropy-readable table containing at least 'ra', 'dec', and 'time' columns (with units).")
178+
parser.add_argument("--psfs", required=False, default=None, type=Path, help="An astropy-readable table containing a 'psf' column (with units) that specifies the PSF-widths of the images from which the detection catalog is derived. If not provided, a value of 1 arcsec is assumed.")
179+
parser.add_argument("--velocity", required=True, nargs=2, type=float, help="The velocity range over which to search, in units of deg/day.")
180+
parser.add_argument("--angle", required=True, nargs=2, type=float, help="The on-sky angles over which to search, in units of deg.")
181+
parser.add_argument("--dx", required=True, type=float, help="Search bin-width, in units of the PSF-width.")
182+
parser.add_argument("--num-results", required=True, type=int, help="Number of results to produce.")
183+
parser.add_argument("--results-dir", type=Path, required=True, help="The directory into which to write results.")
184+
parser.add_argument("--precompute", action='store_true', help="Precompute projected positions of detections for all trial velocities (uses more memory, but may be faster).")
185+
parser.add_argument("--gpu", action='store_true', help="Run the core-search components of the algorithm on GPU.")
186+
parser.add_argument("--gpu-kernels", action='store_true', help="Run the entirety of the search algorithm on the GPU.")
187+
parser.add_argument("--device", type=int, required=False, default=-1, help="The GPU device number to use.")
188+
parser.add_argument("--output-format", type=str, default='ecsv', help="The astropy.table supported format for writing results.")
189189

190190
args = parser.parse_args()
191191

192192
if args.gpu and args.device > -1:
193193
cuda.select_device(args.device)
194194

195-
psfs = astropy.table.Table.read(args.psfs)['psf']
196-
log.info("seeing [min, median, max]: [%f, %f, %f]", np.min(psfs), np.median(psfs), np.max(psfs))
195+
if args.psfs:
196+
psfs = astropy.table.Table.read(args.psfs)['psf']
197+
log.info("seeing [min, median, max]: [%f, %f, %f]", np.min(psfs), np.median(psfs), np.max(psfs))
198+
psf_scaling = np.median(psfs)
199+
else:
200+
psf_scaling = 1 * u.arcsec
197201

198-
dx = args.dx * np.median(psfs) * psfs.unit
202+
dx = args.dx * psf_scaling * psfs.unit
199203
log.info(f"using dx = {dx}")
200204
catalog = astropy.table.Table.read(args.catalog)
201205

@@ -210,9 +214,9 @@ def main():
210214
directions = SearchDirections([vmin, vmax], [phimin, phimax], dx, dt)
211215
log.info("searching %d directions", len(directions.b))
212216
if args.gpu_kernels:
213-
results, results_points = search_gpu(X, directions, dx, reference_epoch.value, num_results=args.threshold)
217+
results, results_points = search_gpu(X, directions, dx, reference_epoch.value, num_results=args.num_results)
214218
else:
215-
results, results_points = search(X, directions, dx, reference_epoch.value, num_results=args.threshold, precompute=args.precompute, gpu=args.gpu)
219+
results, results_points = search(X, directions, dx, reference_epoch.value, num_results=args.num_results, precompute=args.precompute, gpu=args.gpu)
216220

217221
args.results_dir.mkdir(parents=True, exist_ok=False)
218222
for i, (result, points) in enumerate(zip(results, results_points)):

0 commit comments

Comments
 (0)