rms-starcat 0.0.1__py3-none-any.whl → 1.0.0__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,152 @@
1
+ Metadata-Version: 2.1
2
+ Name: rms-starcat
3
+ Version: 1.0.0
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: Repository, https://github.com/SETI/rms-starcat
9
+ Project-URL: Source, https://github.com/SETI/rms-starcat
10
+ Project-URL: Issues, https://github.com/SETI/rms-starcat/issues
11
+ Keywords: UCAC4,YBSC,star
12
+ Classifier: Development Status :: 5 - Production/Stable
13
+ Classifier: Natural Language :: English
14
+ Classifier: Topic :: Scientific/Engineering
15
+ Classifier: Topic :: Scientific/Engineering :: Astronomy
16
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
17
+ Classifier: Topic :: Utilities
18
+ Classifier: License :: OSI Approved :: Apache Software License
19
+ Classifier: Programming Language :: Python :: 3.9
20
+ Classifier: Programming Language :: Python :: 3.10
21
+ Classifier: Programming Language :: Python :: 3.11
22
+ Classifier: Programming Language :: Python :: 3.12
23
+ Classifier: Programming Language :: Python :: 3.13
24
+ Classifier: Operating System :: MacOS :: MacOS X
25
+ Classifier: Operating System :: POSIX :: Linux
26
+ Classifier: Operating System :: Microsoft :: Windows
27
+ Requires-Python: >=3.8
28
+ Description-Content-Type: text/markdown
29
+ License-File: LICENSE
30
+ Requires-Dist: cspyce
31
+ Requires-Dist: numpy
32
+
33
+ [![GitHub release; latest by date](https://img.shields.io/github/v/release/SETI/rms-starcat)](https://github.com/SETI/rms-starcat/releases)
34
+ [![GitHub Release Date](https://img.shields.io/github/release-date/SETI/rms-starcat)](https://github.com/SETI/rms-starcat/releases)
35
+ [![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)
36
+ [![Documentation Status](https://readthedocs.org/projects/rms-starcat/badge/?version=latest)](https://rms-starcat.readthedocs.io/en/latest/?badge=latest)
37
+ [![Code coverage](https://img.shields.io/codecov/c/github/SETI/rms-starcat/main?logo=codecov)](https://codecov.io/gh/SETI/rms-starcat)
38
+ <br />
39
+ [![PyPI - Version](https://img.shields.io/pypi/v/rms-starcat)](https://pypi.org/project/rms-starcat)
40
+ [![PyPI - Format](https://img.shields.io/pypi/format/rms-starcat)](https://pypi.org/project/rms-starcat)
41
+ [![PyPI - Downloads](https://img.shields.io/pypi/dm/rms-starcat)](https://pypi.org/project/rms-starcat)
42
+ [![PyPI - Python Version](https://img.shields.io/pypi/pyversions/rms-starcat)](https://pypi.org/project/rms-starcat)
43
+ <br />
44
+ [![GitHub commits since latest release](https://img.shields.io/github/commits-since/SETI/rms-starcat/latest)](https://github.com/SETI/rms-starcat/commits/main/)
45
+ [![GitHub commit activity](https://img.shields.io/github/commit-activity/m/SETI/rms-starcat)](https://github.com/SETI/rms-starcat/commits/main/)
46
+ [![GitHub last commit](https://img.shields.io/github/last-commit/SETI/rms-starcat)](https://github.com/SETI/rms-starcat/commits/main/)
47
+ <br />
48
+ [![Number of GitHub open issues](https://img.shields.io/github/issues-raw/SETI/rms-starcat)](https://github.com/SETI/rms-starcat/issues)
49
+ [![Number of GitHub closed issues](https://img.shields.io/github/issues-closed-raw/SETI/rms-starcat)](https://github.com/SETI/rms-starcat/issues)
50
+ [![Number of GitHub open pull requests](https://img.shields.io/github/issues-pr-raw/SETI/rms-starcat)](https://github.com/SETI/rms-starcat/pulls)
51
+ [![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)
52
+ <br />
53
+ ![GitHub License](https://img.shields.io/github/license/SETI/rms-starcat)
54
+ [![Number of GitHub stars](https://img.shields.io/github/stars/SETI/rms-starcat)](https://github.com/SETI/rms-starcat/stargazers)
55
+ ![GitHub forks](https://img.shields.io/github/forks/SETI/rms-starcat)
56
+
57
+ # Introduction
58
+
59
+ `starcat` is a set of classes for reading and searching star catalogs. Currently NAIF SPICE
60
+ star catalogs, the Yale Bright Star Catalog (YBSC), and UCAC4 are supported.
61
+
62
+ `starcat` is a product of the [PDS Ring-Moon Systems Node](https://pds-rings.seti.org).
63
+
64
+ # Installation
65
+
66
+ The `starcat` module is available via the `rms-starcat` package on PyPI and can be installed with:
67
+
68
+ ```sh
69
+ pip install rms-starcat
70
+ ```
71
+
72
+ # Getting Started
73
+
74
+ The `starcat` module provides the `StarCatalog` class, which is the superclass for classes
75
+ that handle specific star catalogs. Each star catalog class takes an optional directory
76
+ path to point at the root of the star catalog data; if no directory path is provided,
77
+ the contents of an environment variable is used instead. Each path can be a full URL
78
+ as supported by [`rms-filecache`](https://rms-filecache.readthedocs.io/en/latest/),
79
+ allowing the catalog data to be downloaded (and cached locally) at runtime.
80
+
81
+ - `SpiceStarCatalog`
82
+ - The `dir` argument, if specified, must point to a directory containing NAIF SPICE
83
+ kernels.
84
+ - Otherwise, the environment variable `SPICE_PATH`, if defined, must contain a `Stars`
85
+ subdirectory with NAIF SPICE kernels.
86
+ - Otherwise, the environment variable `OOPS_RESOURCES` must contain a `SPICE/Stars`
87
+ subdirectory.
88
+ - `YBSCStarCatalog`
89
+ - The `dir` argument, if specified, must point to a directory containing the file
90
+ `catalog`.
91
+ - Otherwise, the environment variable `YBSC_PATH` must point to that directory.
92
+ - `UCAC4StarCatalog`
93
+ - The `dir` argument, if specified, must point to a directory containing the directory
94
+ `u4b`.
95
+ - Otherwise, the environment variable `UCAC4_PATH` must point to that directory.
96
+
97
+ Each star catalog returns stars as a class that is a subclass of `Star`. Each subclass
98
+ contains the attributes provided by that star catalog, and none are guaranteed to be
99
+ filled in for all stars:
100
+
101
+ - `SpiceStar`
102
+ - `YBSCStar`
103
+ - `UCAC4Star`
104
+
105
+ Details of each class are available in the [module documentation](https://rms-starcat.readthedocs.io/en/latest/module.html).
106
+
107
+ Basic operation is as follows:
108
+
109
+ ```python
110
+ from starcat import YBSCStarCatalog
111
+ import numpy as np
112
+ cat = YBSCStarCatalog()
113
+ ra_vega = 279.2333
114
+ dec_vega = 38.7836
115
+ vega_list = list(cat.find_stars(ra_min=np.radians(ra_vega-0.1),
116
+ ra_max=np.radians(ra_vega+0.1),
117
+ dec_min=np.radians(dec_vega-0.1),
118
+ dec_max=np.radians(dec_vega+0.1)))
119
+
120
+ assert len(vega_list) == 1
121
+ print(vega_list[0])
122
+ ```
123
+
124
+ yields:
125
+
126
+ ```
127
+ UNIQUE ID 7001 | RA 279.2345833° (18h36m56.300s) | DEC 38.7836111° (+038d47m1.000s)
128
+ VMAG 0.030 | PM RA 259.135 mas/yr | PM DEC 286.000 mas/yr
129
+ TEMP 10800 | SCLASS A0Va
130
+ Name "3Alp Lyr" | Durch "BD+38 3238" | Draper 172167 | SAO 67174 | FK5 699
131
+ IR 1 Ref NASA | Multiple " " | Aitken 11510 None | Variable "Alp Lyr"
132
+ SCLASS Code | Galactic LON 67.44 LAT 19.24
133
+ B-V 0.0 | U-B -0.01 | R-I -0.03
134
+ Parallax TRIG 0.1230000 arcsec | RadVel -14.0 km/s V | RotVel (v sin i) 15.0 km/s
135
+ Double mag diff 10.40 Sep 62.80 arcsec Components AB # 5
136
+ ```
137
+
138
+ # Contributing
139
+
140
+ Information on contributing to this package can be found in the
141
+ [Contributing Guide](https://github.com/SETI/rms-starcat/blob/main/CONTRIBUTING.md).
142
+
143
+ # Links
144
+
145
+ - [Documentation](https://rms-starcat.readthedocs.io)
146
+ - [Repository](https://github.com/SETI/rms-starcat)
147
+ - [Issue tracker](https://github.com/SETI/rms-starcat/issues)
148
+ - [PyPi](https://pypi.org/project/rms-starcat)
149
+
150
+ # Licensing
151
+
152
+ This code is licensed under the [Apache License v2.0](https://github.com/SETI/rms-starcat/blob/main/LICENSE).
@@ -0,0 +1,12 @@
1
+ starcat/__init__.py,sha256=-MdUUzR86srX3uhw-FXBaVYXP5lgnZ82Oyefecm5WuE,749
2
+ starcat/_version.py,sha256=DGJ4pj32xs3_DRJhSzQwCiRNnAQrMgo09USYpyMZsKc,411
3
+ starcat/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
4
+ starcat/spice.py,sha256=oisWst7g2aH5otRqNvWYt4j_GdDdLbtu2Eoe70iJ1FM,3286
5
+ starcat/starcatalog.py,sha256=01jIdgVsJsKx1AeYpwxMQBhkDKWwGKm4TAuYvp_6iJc,17139
6
+ starcat/ucac4.py,sha256=WW7m7ZN7Lx21UC5hcz8-uQ2mFtiOdFE34LlouymAhnQ,51372
7
+ starcat/ybsc.py,sha256=yNPWH_6DmBJaRuzKDGYowhvb6iQPwx_Q_hPwLgNt0i0,25999
8
+ rms_starcat-1.0.0.dist-info/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
9
+ rms_starcat-1.0.0.dist-info/METADATA,sha256=qpuD_M2_DkbDWPA3_eAbKG7GiMkZppgkD7oPzOWCiMw,7423
10
+ rms_starcat-1.0.0.dist-info/WHEEL,sha256=PZUExdf71Ui_so67QXpySuHtCi3-J3wvF4ORK6k_S8U,91
11
+ rms_starcat-1.0.0.dist-info/top_level.txt,sha256=9_BfZoZasqtspX07JKebH3RqlssKXS1EUX22j-m2D48,8
12
+ rms_starcat-1.0.0.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: bdist_wheel (0.41.3)
2
+ Generator: setuptools (75.6.0)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
5
5
 
starcat/__init__.py CHANGED
@@ -2,11 +2,25 @@
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, StarCatalog # noqa: F401
6
+ from starcat.spice import SpiceStar, SpiceStarCatalog # noqa: F401
7
+ from starcat.ucac4 import UCAC4Star, UCAC4StarCatalog # noqa: F401
8
+ from starcat.ybsc import YBSCStar, YBSCStarCatalog # noqa: F401
8
9
 
10
+ # Version
9
11
  try:
10
- from _version import __version__
11
- except ImportError as err:
12
+ from ._version import __version__
13
+ except ImportError:
12
14
  __version__ = 'Version unspecified'
15
+
16
+ __all__ = [
17
+ 'Star',
18
+ 'StarCatalog',
19
+ 'SpiceStar',
20
+ 'SpiceStarCatalog',
21
+ 'UCAC4Star',
22
+ 'UCAC4StarCatalog',
23
+ 'YBSCStar',
24
+ 'YBSCStarCatalog',
25
+ '__version__'
26
+ ]
starcat/_version.py CHANGED
@@ -12,5 +12,5 @@ __version__: str
12
12
  __version_tuple__: VERSION_TUPLE
13
13
  version_tuple: VERSION_TUPLE
14
14
 
15
- __version__ = version = '0.0.1'
16
- __version_tuple__ = version_tuple = (0, 0, 1)
15
+ __version__ = version = '1.0.0'
16
+ __version_tuple__ = version_tuple = (1, 0, 0)
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