Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add method to read bright star catalog and find bright stars in sky region #1105

Merged
merged 20 commits into from
Jul 18, 2019
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions ctapipe/utils/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
from .unstructured_interpolator import UnstructuredInterpolator
from .datasets import (find_all_matching_datasets, get_table_dataset, get_dataset_path,
find_in_path)
from .astro import get_bright_stars
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add this method to __all__

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is still missing!

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is still missing!

Now added

from .CutFlow import CutFlow, PureCountingCut, UndefinedCut


Expand Down
62 changes: 62 additions & 0 deletions ctapipe/utils/astro.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
# Licensed under a 3-clause BSD style license - see LICENSE.rst
from astropy.coordinates import Angle
from astropy.coordinates import SkyCoord
from astropy import units as u
import logging

logger = logging.getLogger(__name__)

__all__ = ['get_bright_stars']


def get_bright_stars(pointing=None, radius=None, magnitude_cut=None):
"""
Returns an astropy table containing star positions above a given magnitude within
a given radius around a position in the sky, using the Yale bright star catalog
which needs to be present in the ctapipe-extra package. The included Yale bright
star catalog contains all 9096 stars, excluding the Nova objects present in the
original catalog from Hoffleit & Jaschek (1991),
http://adsabs.harvard.edu/abs/1991bsc..book.....H, and is complete down to
magnitude ~6.5, while the faintest included star has mag=7.96.

Parameters
----------
pointing: astropy Skycoord
pointing direction in the sky
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 astropy.table import Table
from ctapipe.utils import get_dataset_path

catalog = get_dataset_path("yale_bright_star_catalog5.fits.gz")
table = Table.read(catalog)
maxnoe marked this conversation as resolved.
Show resolved Hide resolved

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

if magnitude_cut is not None:
table = table[table['Vmag'] < magnitude_cut]

if radius is not None:
if pointing is None:
raise ValueError('Sky pointing, pointing=SkyCoord(), must be \
provided if radius is given.')
separations = starpositions.separation(pointing)
maxnoe marked this conversation as resolved.
Show resolved Hide resolved
table['separation'] = separations
table = table[separations < radius]

table.remove_columns(['RAJ2000', 'DEJ2000'])

return table