rms-starcat 0.0.1__py3-none-any.whl → 1.0.1__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of rms-starcat might be problematic. Click here for more details.

@@ -0,0 +1,154 @@
1
+ Metadata-Version: 2.4
2
+ Name: rms-starcat
3
+ Version: 1.0.1
4
+ Summary: Star catalog database
5
+ Maintainer-email: "Robert S. French" <rfrench@seti.org>
6
+ License: Apache-2.0
7
+ Project-URL: Homepage, https://github.com/SETI/rms-starcat
8
+ Project-URL: Documentation, https://rms-starcat.readthedocs.io/en/latest
9
+ Project-URL: Repository, https://github.com/SETI/rms-starcat
10
+ Project-URL: Source, https://github.com/SETI/rms-starcat
11
+ Project-URL: Issues, https://github.com/SETI/rms-starcat/issues
12
+ Keywords: UCAC4,YBSC,star
13
+ Classifier: Development Status :: 5 - Production/Stable
14
+ Classifier: Natural Language :: English
15
+ Classifier: Topic :: Scientific/Engineering
16
+ Classifier: Topic :: Scientific/Engineering :: Astronomy
17
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
18
+ Classifier: Topic :: Utilities
19
+ Classifier: License :: OSI Approved :: Apache Software License
20
+ Classifier: Programming Language :: Python :: 3.9
21
+ Classifier: Programming Language :: Python :: 3.10
22
+ Classifier: Programming Language :: Python :: 3.11
23
+ Classifier: Programming Language :: Python :: 3.12
24
+ Classifier: Programming Language :: Python :: 3.13
25
+ Classifier: Operating System :: MacOS :: MacOS X
26
+ Classifier: Operating System :: POSIX :: Linux
27
+ Classifier: Operating System :: Microsoft :: Windows
28
+ Requires-Python: >=3.8
29
+ Description-Content-Type: text/markdown
30
+ License-File: LICENSE
31
+ Requires-Dist: cspyce
32
+ Requires-Dist: numpy
33
+ Dynamic: license-file
34
+
35
+ [![GitHub release; latest by date](https://img.shields.io/github/v/release/SETI/rms-starcat)](https://github.com/SETI/rms-starcat/releases)
36
+ [![GitHub Release Date](https://img.shields.io/github/release-date/SETI/rms-starcat)](https://github.com/SETI/rms-starcat/releases)
37
+ [![Test Status](https://img.shields.io/github/actions/workflow/status/SETI/rms-starcat/run-tests.yml?branch=main)](https://github.com/SETI/rms-starcat/actions)
38
+ [![Documentation Status](https://readthedocs.org/projects/rms-starcat/badge/?version=latest)](https://rms-starcat.readthedocs.io/en/latest/?badge=latest)
39
+ [![Code coverage](https://img.shields.io/codecov/c/github/SETI/rms-starcat/main?logo=codecov)](https://codecov.io/gh/SETI/rms-starcat)
40
+ <br />
41
+ [![PyPI - Version](https://img.shields.io/pypi/v/rms-starcat)](https://pypi.org/project/rms-starcat)
42
+ [![PyPI - Format](https://img.shields.io/pypi/format/rms-starcat)](https://pypi.org/project/rms-starcat)
43
+ [![PyPI - Downloads](https://img.shields.io/pypi/dm/rms-starcat)](https://pypi.org/project/rms-starcat)
44
+ [![PyPI - Python Version](https://img.shields.io/pypi/pyversions/rms-starcat)](https://pypi.org/project/rms-starcat)
45
+ <br />
46
+ [![GitHub commits since latest release](https://img.shields.io/github/commits-since/SETI/rms-starcat/latest)](https://github.com/SETI/rms-starcat/commits/main/)
47
+ [![GitHub commit activity](https://img.shields.io/github/commit-activity/m/SETI/rms-starcat)](https://github.com/SETI/rms-starcat/commits/main/)
48
+ [![GitHub last commit](https://img.shields.io/github/last-commit/SETI/rms-starcat)](https://github.com/SETI/rms-starcat/commits/main/)
49
+ <br />
50
+ [![Number of GitHub open issues](https://img.shields.io/github/issues-raw/SETI/rms-starcat)](https://github.com/SETI/rms-starcat/issues)
51
+ [![Number of GitHub closed issues](https://img.shields.io/github/issues-closed-raw/SETI/rms-starcat)](https://github.com/SETI/rms-starcat/issues)
52
+ [![Number of GitHub open pull requests](https://img.shields.io/github/issues-pr-raw/SETI/rms-starcat)](https://github.com/SETI/rms-starcat/pulls)
53
+ [![Number of GitHub closed pull requests](https://img.shields.io/github/issues-pr-closed-raw/SETI/rms-starcat)](https://github.com/SETI/rms-starcat/pulls)
54
+ <br />
55
+ ![GitHub License](https://img.shields.io/github/license/SETI/rms-starcat)
56
+ [![Number of GitHub stars](https://img.shields.io/github/stars/SETI/rms-starcat)](https://github.com/SETI/rms-starcat/stargazers)
57
+ ![GitHub forks](https://img.shields.io/github/forks/SETI/rms-starcat)
58
+
59
+ # Introduction
60
+
61
+ `starcat` is a set of classes for reading and searching star catalogs. Currently NAIF SPICE
62
+ star catalogs, the Yale Bright Star Catalog (YBSC), and UCAC4 are supported.
63
+
64
+ `starcat` is a product of the [PDS Ring-Moon Systems Node](https://pds-rings.seti.org).
65
+
66
+ # Installation
67
+
68
+ The `starcat` module is available via the `rms-starcat` package on PyPI and can be installed with:
69
+
70
+ ```sh
71
+ pip install rms-starcat
72
+ ```
73
+
74
+ # Getting Started
75
+
76
+ The `starcat` module provides the `StarCatalog` class, which is the superclass for classes
77
+ that handle specific star catalogs. Each star catalog class takes an optional directory
78
+ path to point at the root of the star catalog data; if no directory path is provided,
79
+ the contents of an environment variable is used instead. Each path can be a full URL
80
+ as supported by [`rms-filecache`](https://rms-filecache.readthedocs.io/en/latest/),
81
+ allowing the catalog data to be downloaded (and cached locally) at runtime.
82
+
83
+ - `SpiceStarCatalog`
84
+ - The `dir` argument, if specified, must point to a directory containing NAIF SPICE
85
+ kernels.
86
+ - Otherwise, the environment variable `SPICE_PATH`, if defined, must contain a `Stars`
87
+ subdirectory with NAIF SPICE kernels.
88
+ - Otherwise, the environment variable `OOPS_RESOURCES` must contain a `SPICE/Stars`
89
+ subdirectory.
90
+ - `YBSCStarCatalog`
91
+ - The `dir` argument, if specified, must point to a directory containing the file
92
+ `catalog`.
93
+ - Otherwise, the environment variable `YBSC_PATH` must point to that directory.
94
+ - `UCAC4StarCatalog`
95
+ - The `dir` argument, if specified, must point to a directory containing the directory
96
+ `u4b`.
97
+ - Otherwise, the environment variable `UCAC4_PATH` must point to that directory.
98
+
99
+ Each star catalog returns stars as a class that is a subclass of `Star`. Each subclass
100
+ contains the attributes provided by that star catalog, and none are guaranteed to be
101
+ filled in for all stars:
102
+
103
+ - `SpiceStar`
104
+ - `YBSCStar`
105
+ - `UCAC4Star`
106
+
107
+ Details of each class are available in the [module documentation](https://rms-starcat.readthedocs.io/en/latest/module.html).
108
+
109
+ Basic operation is as follows:
110
+
111
+ ```python
112
+ from starcat import YBSCStarCatalog
113
+ import numpy as np
114
+ cat = YBSCStarCatalog()
115
+ ra_vega = 279.2333
116
+ dec_vega = 38.7836
117
+ vega_list = list(cat.find_stars(ra_min=np.radians(ra_vega-0.1),
118
+ ra_max=np.radians(ra_vega+0.1),
119
+ dec_min=np.radians(dec_vega-0.1),
120
+ dec_max=np.radians(dec_vega+0.1)))
121
+
122
+ assert len(vega_list) == 1
123
+ print(vega_list[0])
124
+ ```
125
+
126
+ yields:
127
+
128
+ ```
129
+ UNIQUE ID 7001 | RA 279.2345833° (18h36m56.300s) | DEC 38.7836111° (+038d47m1.000s)
130
+ VMAG 0.030 | PM RA 259.135 mas/yr | PM DEC 286.000 mas/yr
131
+ TEMP 10800 | SCLASS A0Va
132
+ Name "3Alp Lyr" | Durch "BD+38 3238" | Draper 172167 | SAO 67174 | FK5 699
133
+ IR 1 Ref NASA | Multiple " " | Aitken 11510 None | Variable "Alp Lyr"
134
+ SCLASS Code | Galactic LON 67.44 LAT 19.24
135
+ B-V 0.0 | U-B -0.01 | R-I -0.03
136
+ Parallax TRIG 0.1230000 arcsec | RadVel -14.0 km/s V | RotVel (v sin i) 15.0 km/s
137
+ Double mag diff 10.40 Sep 62.80 arcsec Components AB # 5
138
+ ```
139
+
140
+ # Contributing
141
+
142
+ Information on contributing to this package can be found in the
143
+ [Contributing Guide](https://github.com/SETI/rms-starcat/blob/main/CONTRIBUTING.md).
144
+
145
+ # Links
146
+
147
+ - [Documentation](https://rms-starcat.readthedocs.io)
148
+ - [Repository](https://github.com/SETI/rms-starcat)
149
+ - [Issue tracker](https://github.com/SETI/rms-starcat/issues)
150
+ - [PyPi](https://pypi.org/project/rms-starcat)
151
+
152
+ # Licensing
153
+
154
+ This code is licensed under the [Apache License v2.0](https://github.com/SETI/rms-starcat/blob/main/LICENSE).
@@ -0,0 +1,12 @@
1
+ rms_starcat-1.0.1.dist-info/licenses/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
2
+ starcat/__init__.py,sha256=X9py3tgph6bKl2Xxok6bWvSQn5FbQB824ky2dB-kiwM,952
3
+ starcat/_version.py,sha256=2Cl9kcQGg7NiH_eHRcv8wDYSW0X4uS5J0mGdZFO9-h0,511
4
+ starcat/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
5
+ starcat/spice.py,sha256=oisWst7g2aH5otRqNvWYt4j_GdDdLbtu2Eoe70iJ1FM,3286
6
+ starcat/starcatalog.py,sha256=01jIdgVsJsKx1AeYpwxMQBhkDKWwGKm4TAuYvp_6iJc,17139
7
+ starcat/ucac4.py,sha256=WW7m7ZN7Lx21UC5hcz8-uQ2mFtiOdFE34LlouymAhnQ,51372
8
+ starcat/ybsc.py,sha256=br3GuI6Zym8FOPa9uPr3_1F8Qkctot_jTTqWN0bd8KA,26000
9
+ rms_starcat-1.0.1.dist-info/METADATA,sha256=BNNezeGVHgy2i_PcwxBMcWTzg4I0W91P685SFPQmeqU,7518
10
+ rms_starcat-1.0.1.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
11
+ rms_starcat-1.0.1.dist-info/top_level.txt,sha256=9_BfZoZasqtspX07JKebH3RqlssKXS1EUX22j-m2D48,8
12
+ rms_starcat-1.0.1.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: bdist_wheel (0.41.3)
2
+ Generator: setuptools (80.9.0)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
5
5
 
starcat/__init__.py CHANGED
@@ -2,11 +2,30 @@
2
2
  # starcat/__init__.py
3
3
  ################################################################################
4
4
 
5
- from starcat.spice import *
6
- from starcat.ucac4 import *
7
- from starcat.ybsc import *
5
+ from starcat.starcatalog import (Star,
6
+ StarCatalog,
7
+ SCLASS_TO_B_MINUS_V,
8
+ SCLASS_TO_SURFACE_TEMP) # noqa: F401
9
+ from starcat.spice import SpiceStar, SpiceStarCatalog # noqa: F401
10
+ from starcat.ucac4 import UCAC4Star, UCAC4StarCatalog # noqa: F401
11
+ from starcat.ybsc import YBSCStar, YBSCStarCatalog # noqa: F401
8
12
 
13
+ # Version
9
14
  try:
10
- from _version import __version__
11
- except ImportError as err:
15
+ from ._version import __version__
16
+ except ImportError:
12
17
  __version__ = 'Version unspecified'
18
+
19
+ __all__ = [
20
+ 'SCLASS_TO_B_MINUS_V',
21
+ 'SCLASS_TO_SURFACE_TEMP',
22
+ 'Star',
23
+ 'StarCatalog',
24
+ 'SpiceStar',
25
+ 'SpiceStarCatalog',
26
+ 'UCAC4Star',
27
+ 'UCAC4StarCatalog',
28
+ 'YBSCStar',
29
+ 'YBSCStarCatalog',
30
+ '__version__'
31
+ ]
starcat/_version.py CHANGED
@@ -1,8 +1,13 @@
1
- # file generated by setuptools_scm
1
+ # file generated by setuptools-scm
2
2
  # don't change, don't track in version control
3
+
4
+ __all__ = ["__version__", "__version_tuple__", "version", "version_tuple"]
5
+
3
6
  TYPE_CHECKING = False
4
7
  if TYPE_CHECKING:
5
- from typing import Tuple, Union
8
+ from typing import Tuple
9
+ from typing import Union
10
+
6
11
  VERSION_TUPLE = Tuple[Union[int, str], ...]
7
12
  else:
8
13
  VERSION_TUPLE = object
@@ -12,5 +17,5 @@ __version__: str
12
17
  __version_tuple__: VERSION_TUPLE
13
18
  version_tuple: VERSION_TUPLE
14
19
 
15
- __version__ = version = '0.0.1'
16
- __version_tuple__ = version_tuple = (0, 0, 1)
20
+ __version__ = version = '1.0.1'
21
+ __version_tuple__ = version_tuple = (1, 0, 1)
starcat/py.typed ADDED
File without changes
starcat/spice.py CHANGED
@@ -2,96 +2,93 @@
2
2
  # starcat/spice.py
3
3
  ################################################################################
4
4
 
5
- from __future__ import print_function
6
-
7
- try:
8
- from starcatalog import *
9
- except:
10
- from .starcatalog import *
11
- import numpy as np
12
- import os.path
5
+ from __future__ import annotations
6
+
7
+ import os
8
+ from pathlib import Path
9
+ from typing import Any, Iterator, Optional
10
+
13
11
  import cspyce
12
+ from filecache import FCPath
13
+
14
+ from .starcatalog import Star, StarCatalog
15
+
14
16
 
15
17
  class SpiceStar(Star):
16
18
  """A holder for star attributes.
17
19
 
18
- This class includes attributes unique to the SPICE catalogs."""
20
+ This class includes attributes unique to stars in SPICE catalogs.
19
21
 
20
- def __init__(self):
21
- # Initialize the standard fields
22
- Star.__init__(self)
22
+ A SpiceStar only supports these attributes: `unique_number`, `ra`, `ra_sigma`, `dec`,
23
+ `dec_sigma`, `vmag`, `spectral_class`, `temperature`
24
+ """
23
25
 
24
- # Initialize the SPICE-specific fields
25
- self.spectral_class = None
26
- """The spectral class"""
26
+ def __init__(self) -> None:
27
+ # Initialize the standard fields
28
+ super().__init__()
27
29
 
28
30
 
29
31
  class SpiceStarCatalog(StarCatalog):
30
- def __init__(self, name):
31
- self.filename = os.path.join(os.environ["SPICE_PATH"], "Stars", name+'.bdb')
32
- self.catalog = cspyce.stcl01(self.filename)[0]
33
- self.debug_level = 0
34
-
35
- # (ra, dec, ra_uncertainty, dec_uncertainty,
36
- # catalog_number, spectral_type, v_magnitude)
37
-
38
- def _find_stars(self, ra_min, ra_max, dec_min, dec_max, **kwargs):
39
- """Yield the results for all stars in the RA,DEC range."""
40
- vmag_min = kwargs.get('vmag_min', None)
41
- vmag_max = kwargs.get('vmag_max', None)
42
-
43
- nstars = cspyce.stcf01(self.catalog, ra_min, ra_max, dec_min, dec_max)
32
+ def __init__(self,
33
+ name: str,
34
+ dir: Optional[str | Path | FCPath] = None) -> None:
35
+ """Create a SpiceStarCatalog.
36
+
37
+ Parameters:
38
+ name: The name of the SPICE catalog without the extension, such as
39
+ ``hipparcos``, ``ppm``, or ``tycho2``.
40
+ dir: The path to the star catalog directory (may be a URL). Within
41
+ this directory should be the kernels for the requested name
42
+ (``name.dbd`` and ``name.xdb``).
43
+ """
44
+
45
+ super().__init__()
46
+ if dir is None:
47
+ try:
48
+ dir = FCPath(os.environ['SPICE_PATH']) / 'Stars'
49
+ except KeyError:
50
+ dir = FCPath(os.environ['OOPS_RESOURCES']) / 'SPICE' / 'Stars'
51
+ except KeyError:
52
+ raise RuntimeError(
53
+ 'SPICE_PATH and OOPS_RESOURCES environment variables not set')
54
+ else:
55
+ dir = FCPath(dir)
56
+ self._filename = dir / f'{name}.bdb'
57
+ local_path = self._filename.retrieve()
58
+ self._catalog = cspyce.stcl01(local_path)[0]
59
+
60
+ def _find_stars(self,
61
+ ra_min: float,
62
+ ra_max: float,
63
+ dec_min: float,
64
+ dec_max: float,
65
+ vmag_min: Optional[float] = None,
66
+ vmag_max: Optional[float] = None,
67
+ full_result: bool = True,
68
+ **kwargs: Any) -> Iterator[SpiceStar]:
69
+
70
+ nstars = cspyce.stcf01(self._catalog, ra_min, ra_max, dec_min, dec_max)
44
71
 
45
72
  for i in range(nstars):
46
73
  star = SpiceStar()
47
74
  result = tuple(cspyce.stcg01(i))
48
75
  (star.ra, star.dec, star.ra_sigma, star.dec_sigma,
49
76
  star.unique_number, star.spectral_class, star.vmag) = result
50
- if vmag_min is not None and star.vmag < vmag_min:
51
- if self.debug_level:
52
- print('SKIPPED VMAG', star.vmag)
53
- continue
54
- if vmag_max is not None and star.vmag > vmag_max:
55
- if self.debug_level:
56
- print('SKIPPED VMAG', star.vmag)
57
- continue
58
-
59
- star.temperature = self.temperature_from_sclass(star.spectral_class)
60
- if self.debug_level:
61
- print('OK!')
62
- yield star
63
-
64
-
65
-
66
- #===============================================================================
67
- # UNIT TESTS
68
- #===============================================================================
69
-
70
- import unittest
71
-
72
- class Test_SpiceStarCatalog(unittest.TestCase):
73
-
74
- def runTest(self):
75
- cat = SpiceStarCatalog('hipparcos')
76
-
77
- num_all = cat.count_stars()
78
- self.assertEqual(num_all, 117955)
79
-
80
- num_vmag_lim = cat.count_stars(vmag_max=10)
81
- self.assertGreater(num_all, num_vmag_lim)
82
-
83
- # Compare slicing directions
84
- num_dec = 0
85
- for idec in range(20):
86
- num_dec += cat.count_stars(dec_min=0.2*idec*RPD,
87
- dec_max=0.2*(idec+1)*RPD,
88
- ra_min=60*RPD, ra_max=70*RPD)
89
- num_ra = 0
90
- for ira in range(10):
91
- num_ra += cat.count_stars(dec_min=0., dec_max=4.*RPD,
92
- ra_min=(ira+60)*RPD, ra_max=((ira+1)+60)*RPD)
93
- self.assertEqual(num_dec, num_ra)
77
+ if star.vmag is not None:
78
+ if vmag_min is not None and star.vmag < vmag_min:
79
+ if self.debug_level:
80
+ print('SKIPPED VMAG', star.vmag)
81
+ continue
82
+ if vmag_max is not None and star.vmag > vmag_max:
83
+ if self.debug_level:
84
+ print('SKIPPED VMAG', star.vmag)
85
+ continue
86
+
87
+ if full_result:
88
+ star.temperature = Star.temperature_from_sclass(star.spectral_class)
94
89
 
90
+ if self.debug_level:
91
+ print(star)
92
+ print('-' * 80)
95
93
 
96
- if __name__ == '__main__':
97
- unittest.main(verbosity=2)
94
+ yield star