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 all 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
2 changes: 2 additions & 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 All @@ -19,6 +20,7 @@
'get_table_dataset',
'get_dataset_path',
'find_in_path',
'get_bright_stars',
'CutFlow',
'PureCountingCut',
'UndefinedCut',
Expand Down
63 changes: 63 additions & 0 deletions ctapipe/utils/astro.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
# Licensed under a 3-clause BSD style license - see LICENSE.rst
"""
This module is intended to contain astronomy-related helper tools which are
not provided by external packages and/or to satisfy particular needs of
usage within ctapipe.
"""
from astropy.coordinates import Angle
from astropy.coordinates import SkyCoord
from astropy import units as u

__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 (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

if magnitude_cut is not None:
catalog = catalog[catalog['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 = catalog['ra_dec'].separation(pointing)
catalog['separation'] = separations
catalog = catalog[separations < radius]

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

return catalog

19 changes: 19 additions & 0 deletions ctapipe/utils/tests/test_astro.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Licensed under a 3-clause BSD style license - see LICENSE.rst
"""
This module contains the utils.astro unit tests
"""
from ..astro import get_bright_stars
from astropy.coordinates import SkyCoord
from astropy import units as u

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. * u.deg, magnitude_cut=3.5)

assert len(table) == 1
assert table[0]['Name'] == '123Zet Tau'
kosack marked this conversation as resolved.
Show resolved Hide resolved
3 changes: 3 additions & 0 deletions docs/ctapipe_api/utils/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,9 @@ Reference/API
.. automodapi:: ctapipe.utils
:no-inheritance-diagram:

.. automodapi:: ctapipe.utils.astro
:no-inheritance-diagram:

.. automodapi:: ctapipe.utils.linalg
:no-inheritance-diagram:

2 changes: 1 addition & 1 deletion environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ dependencies:
- pytables
- tqdm
- conda-forge::nbsphinx
- ctapipe-extra=0.2.17
- ctapipe-extra=0.2.18
- pytest-runner
- pip:
- eventio~=0.20.1
Expand Down
2 changes: 1 addition & 1 deletion py3.6_env.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ dependencies:
- tqdm
- conda-forge::nbsphinx
- pytest-runner
- ctapipe-extra=0.2.17
- ctapipe-extra=0.2.18
- pyhessio=2.1
- nbconvert>=5.4
- pip:
Expand Down
2 changes: 1 addition & 1 deletion py3.7_env.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ dependencies:
- tqdm
- conda-forge::nbsphinx
- pytest-runner
- ctapipe-extra=0.2.17
- ctapipe-extra=0.2.18
- pyhessio=2.1
- nbconvert>=5.4
- pip:
Expand Down