Skip to content

Commit

Permalink
OverlayStars: plot empty circles
Browse files Browse the repository at this point in the history
  • Loading branch information
scivision committed Feb 6, 2024
1 parent b216567 commit 13174ea
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 4 deletions.
41 changes: 39 additions & 2 deletions scripts/OverlayStars.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,16 @@
"""
Overlay stars from a catalog on an image.
This is like a closed loop check that solve-field output (here, the .rdls file) makes sense.
Use --tag-all option of solve-field to output star magnitude in the .rdls file:
solve-field src/astrometry_azel/tests/apod4.fits --tag-all
"""

import argparse

import numpy as np

from astrometry_azel.io import get_sources
from astrometry_azel.plot import add_image

Expand All @@ -23,8 +29,39 @@
fg = figure()
ax = fg.gca()
add_image(p.new_file, "gray", ax)
ax.set_title(f"{p.rdls_file} stars on {p.new_file}", wrap=True)

ax.scatter(source_ra["ra"], source_ra["dec"], s=10, c="r", marker=".", label="stars")
if "MAG" in source_ra.columns.names:
Ntot = source_ra.shape[0]
Nkeep = 20 # only plot the brightest stars
source_ra.sort(axis=0, order="MAG")
source_ra = source_ra[:Nkeep]

# normalize star magnitude to [0,1]
mag_norm = (source_ra["MAG"] - source_ra["MAG"].min()) / np.ptp(source_ra["MAG"])

ax.scatter(
source_ra["RA"],
source_ra["DEC"],
s=100 * mag_norm,
edgecolors="red",
marker="o",
facecolors="none",
label="stars",
)
ttxt = f"{p.rdls_file} {source_ra.shape[0]} / {Ntot} stars on {p.new_file}"
else:
ax.scatter(
source_ra["RA"],
source_ra["DEC"],
s=25,
edgecolors="red",
marker="o",
facecolors="none",
label="stars",
)
ttxt = f"{p.rdls_file} {source_ra.shape[0]} stars on {p.new_file}"


ax.set_title(ttxt, wrap=True)

show()
4 changes: 2 additions & 2 deletions src/astrometry_azel/io.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
loadmat = None


def get_sources(fn: Path) -> xarray.Dataset:
def get_sources(fn: Path):
"""
read source (star) coordinates from .rdls file
Expand All @@ -42,7 +42,7 @@ def get_sources(fn: Path) -> xarray.Dataset:
Returns
-------
radec: xarray.Dataset
radec: astropy.fits.fitsrec.FITS_rec
RA, Dec of sources
"""

Expand Down

0 comments on commit 13174ea

Please sign in to comment.