Skip to content

Commit

Permalink
Removing old getter
Browse files Browse the repository at this point in the history
  • Loading branch information
Christoph Toennis committed Oct 14, 2024
1 parent 0ca8561 commit 4f28af2
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 69 deletions.
53 changes: 3 additions & 50 deletions src/ctapipe/utils/astro.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

log = logging.getLogger("main")

__all__ = ["get_bright_stars_with_motion", "get_bright_stars"]
__all__ = ["get_bright_stars"]


CACHE_FILE = Path("~/.psf_stars.ecsv").expanduser()
Expand Down Expand Up @@ -70,7 +70,7 @@ def select_stars(stars, pointing=None, radius=None, Bmag_cut=None, Vmag_cut=None
return stars


def get_bright_stars_with_motion(
def get_bright_stars(
pointing=None, radius=None, Bmag_cut=None, Vmag_cut=None, catalog="Yale"
): # max_magnitude):
"""
Expand Down Expand Up @@ -128,7 +128,7 @@ def get_bright_stars_with_motion(
row_limit=1000000,
)

stars = vizier.query_constraints(Vmag="0.0..100.0")[0]
stars = vizier.query_constraints(Vmag="0.0..10.0")[0]
if "Bmag" in stars.keys():
if Bmag_cut is not None:
stars.meta["Bmag_cut"] = Bmag_cut
Expand Down Expand Up @@ -156,50 +156,3 @@ def get_bright_stars_with_motion(
)

return stars


def get_bright_stars(pointing=None, radius=None, magnitude_cut=None):
"""
Get an astropy table of bright stars.
This function is using the Yale bright star catalog, available through ctapipe
data downloads.
The included Yale bright star catalog contains all 9096 stars, excluding the
Nova objects present in the original catalog and is complete down to magnitude
~6.5, while the faintest included star has mag=7.96. :cite:p:`bright-star-catalog`
Parameters
----------
pointing: astropy Skycoord
pointing direction in the sky (if none is given, full sky is returned)
radius: astropy angular units
Radius of the sky region around pointing position. Default: full sky
magnitude_cut: float
Return only stars above a given magnitude. Default: None (all entries)
Returns
-------
Astropy table:
List of all stars after cuts with names, catalog numbers, magnitudes,
and coordinates
"""
from ctapipe.utils import get_table_dataset

catalog = get_table_dataset("yale_bright_star_catalog5", role="bright star catalog")

starpositions = SkyCoord(
ra=Angle(catalog["RAJ2000"], unit=u.deg),
dec=Angle(catalog["DEJ2000"], unit=u.deg),
frame="icrs",
copy=False,
)
catalog["ra_dec"] = starpositions

catalog = select_stars(
catalog, pointing=pointing, radius=radius, Vmag_cut=magnitude_cut
)

catalog.remove_columns(["RAJ2000", "DEJ2000"])

return catalog
24 changes: 5 additions & 19 deletions src/ctapipe/utils/tests/test_astro.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,14 @@
from astropy import units as u
from astropy.coordinates import Angle, SkyCoord

from ..astro import get_bright_stars, get_bright_stars_with_motion
from ..astro import get_bright_stars


def test_get_bright_stars_with_motion():
def test_get_bright_stars():
"""
unit test for utils.astro.get_bright_stars_with_motion().
"""
# TODO add tests for all catalogues, specifically by trying to find some particular bright star, also test that motion is properly included
pointing = SkyCoord(
ra=Angle("03 47 29.1", unit=u.deg),
dec=Angle("+24 06 18", unit=u.deg),
Expand All @@ -20,21 +21,6 @@ def test_get_bright_stars_with_motion():

# lets find 25 Eta Tau

table = get_bright_stars_with_motion(
pointing=pointing, radius=1.0 * u.deg, Vmag_cut=3.5
)

assert len(table) == 1


def test_get_bright_stars():
"""
unit test for utils.astro.get_bright_stars(). Tests that only Zeta Tau is
returned close to the Crab Nebula as object brighter than mag=3.5.
"""
pointing = SkyCoord(ra=83.275 * u.deg, dec=21.791 * u.deg, frame="icrs")

table = get_bright_stars(pointing, radius=2.0 * u.deg, magnitude_cut=3.5)
table = get_bright_stars(pointing=pointing, radius=1.0 * u.deg, Vmag_cut=3.5)

assert len(table) == 1
assert table[0]["Name"] == "123Zet Tau"
assert len(table) == 1 # this looks if 25 Eta Tau was found

0 comments on commit 4f28af2

Please sign in to comment.