Skip to content

Commit

Permalink
Made a function to create star table
Browse files Browse the repository at this point in the history
  • Loading branch information
Christoph Toennis committed Oct 16, 2024
1 parent ced74cc commit 80dfc87
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 1 deletion.
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ tests = [
"pytest-xdist",
"pytest_astropy_header",
"tomli",
"astroquery",
]

docs = [
Expand Down
43 changes: 42 additions & 1 deletion src/ctapipe/utils/astro.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
from astropy.coordinates import Angle, SkyCoord
from astropy.table import Table
from astropy.time import Time
from astroquery.vizier import Vizier

log = logging.getLogger("main")

Expand Down Expand Up @@ -73,6 +72,46 @@ def select_stars(stars, pointing=None, radius=None, Bmag_cut=None, Vmag_cut=None
return stars


def get_star_catalog(catalog, filename):
"""
Utility function to download a star catalog for the get_bright_stars function
Parameters
----------
catalog: string
Name of the catalog to be used. Usable names are found in the Enum StarCatalogues. Default: Yale
filename: string
Name and location of the catalog file to be produced
"""
from astroquery.vizier import Vizier

vizier = Vizier(
catalog=StarCatalogues[catalog].value,
columns=[
"recno",
"RAJ2000",
"DEJ2000",
"pmRA",
"pmDE",
"Vmag",
"Bmag",
"BTmag",
"VTmag",
],
row_limit=1000000,
)

stars = vizier.query_constraints(Vmag="0.0..10.0")[0]

if "Bmag" not in stars.keys():
log.exception("The chosen catalog does not have Bmag data")
if "Vmag" not in stars.keys():
log.exception("The chosen catalog does not have Vmag data")
stars.meta["Catalog"] = StarCatalogues[catalog].value

stars.write(CACHE_FILE, overwrite=True)


def get_bright_stars(
pointing=None, radius=None, Bmag_cut=None, Vmag_cut=None, catalog="Yale"
): # max_magnitude):
Expand Down Expand Up @@ -130,6 +169,8 @@ def get_bright_stars(
log.exception("Cache file exists but reading failed. Recreating")

if stars is None:
from astroquery.vizier import Vizier

log.info("Querying Vizier for bright stars catalog")
# query vizier for stars with 0 <= Vmag <= max_magnitude
vizier = Vizier(
Expand Down

0 comments on commit 80dfc87

Please sign in to comment.