starplot 0.18.1__py2.py3-none-any.whl → 0.19.0__py2.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.
Files changed (39) hide show
  1. starplot/__init__.py +33 -27
  2. starplot/cli.py +5 -8
  3. starplot/config.py +1 -0
  4. starplot/data/__init__.py +3 -5
  5. starplot/data/catalogs.py +23 -11
  6. starplot/data/db.py +1 -7
  7. starplot/data/library/constellation_names.parquet +0 -0
  8. starplot/data/library/dso_names.parquet +0 -0
  9. starplot/data/library/star_designations.parquet +0 -0
  10. starplot/data/translations.py +45 -0
  11. starplot/models/__init__.py +3 -1
  12. starplot/models/constellation.py +7 -1
  13. starplot/models/milky_way.py +30 -0
  14. starplot/models/observer.py +11 -2
  15. starplot/plots/__init__.py +6 -0
  16. starplot/{base.py → plots/base.py} +74 -439
  17. starplot/{horizon.py → plots/horizon.py} +12 -10
  18. starplot/{map.py → plots/map.py} +10 -7
  19. starplot/{optic.py → plots/optic.py} +21 -30
  20. starplot/{zenith.py → plots/zenith.py} +31 -8
  21. starplot/plotters/__init__.py +9 -7
  22. starplot/plotters/arrow.py +1 -1
  23. starplot/plotters/constellations.py +46 -61
  24. starplot/plotters/dsos.py +33 -16
  25. starplot/plotters/experimental.py +0 -1
  26. starplot/plotters/milkyway.py +15 -6
  27. starplot/plotters/stars.py +19 -36
  28. starplot/plotters/text.py +464 -0
  29. starplot/styles/__init__.py +4 -4
  30. starplot/styles/base.py +20 -18
  31. starplot/styles/ext/antique.yml +2 -2
  32. starplot/styles/ext/blue_dark.yml +0 -1
  33. starplot/styles/ext/color_print.yml +2 -2
  34. {starplot-0.18.1.dist-info → starplot-0.19.0.dist-info}/METADATA +5 -3
  35. {starplot-0.18.1.dist-info → starplot-0.19.0.dist-info}/RECORD +38 -36
  36. starplot/data/library/sky.db +0 -0
  37. {starplot-0.18.1.dist-info → starplot-0.19.0.dist-info}/WHEEL +0 -0
  38. {starplot-0.18.1.dist-info → starplot-0.19.0.dist-info}/entry_points.txt +0 -0
  39. {starplot-0.18.1.dist-info → starplot-0.19.0.dist-info}/licenses/LICENSE +0 -0
starplot/__init__.py CHANGED
@@ -1,36 +1,42 @@
1
+ # ruff: noqa: F401,F403
2
+
1
3
  """Star charts and maps of the sky"""
2
4
 
3
- __version__ = "0.18.1"
5
+ __version__ = "0.19.0"
4
6
 
5
- from .base import BasePlot # noqa: F401
6
- from .map import MapPlot # noqa: F401
7
- from .horizon import HorizonPlot # noqa: F401
8
- from .optic import OpticPlot # noqa: F401
9
- from .zenith import ZenithPlot # noqa: F401
7
+ from .plots import (
8
+ MapPlot,
9
+ HorizonPlot,
10
+ OpticPlot,
11
+ ZenithPlot,
12
+ )
10
13
  from .models import (
11
- DSO, # noqa: F401
12
- DsoType, # noqa: F401
13
- Star, # noqa: F401
14
- Constellation, # noqa: F401
15
- Comet, # noqa: F401
16
- Planet, # noqa: F401
17
- Moon, # noqa: F401
18
- Sun, # noqa: F401
19
- ObjectList, # noqa: F401
20
- Scope, # noqa: F401
21
- Binoculars, # noqa: F401
22
- Reflector, # noqa: F401
23
- Refractor, # noqa: F401
24
- Camera, # noqa: F401
25
- Satellite, # noqa: F401
26
- Observer, # noqa: F401
14
+ DSO,
15
+ DsoType,
16
+ Star,
17
+ Constellation,
18
+ ConstellationBorder,
19
+ Comet,
20
+ Planet,
21
+ Moon,
22
+ Sun,
23
+ ObjectList,
24
+ Scope,
25
+ Binoculars,
26
+ Reflector,
27
+ Refractor,
28
+ Camera,
29
+ Satellite,
30
+ Observer,
31
+ MilkyWay,
27
32
  )
28
- from .data import Catalog # noqa: F401 F403
29
- from .styles import * # noqa: F401 F403
30
- from .projections import * # noqa: F401 F403
31
- from .config import settings # noqa: F401
33
+ from .data import Catalog
34
+ from .styles import *
35
+ from .projections import *
36
+ from .config import settings
37
+ from .plotters.text import CollisionHandler
32
38
 
33
- from ibis import _ # noqa: F401 F403
39
+ from ibis import _
34
40
 
35
41
 
36
42
  import contextlib
starplot/cli.py CHANGED
@@ -1,14 +1,14 @@
1
1
  import sys
2
2
 
3
3
  from starplot.styles import fonts
4
+ from starplot.config import settings
5
+ from starplot.data import db
6
+ from starplot.data.catalogs import download_all_catalogs
4
7
 
5
8
  COMMANDS = ["setup"]
6
9
 
7
10
 
8
11
  def setup(options):
9
- from starplot.config import settings
10
- from starplot.data import db, bigsky
11
-
12
12
  print("Installing DuckDB spatial extension...")
13
13
 
14
14
  con = db.connect()
@@ -16,11 +16,8 @@ def setup(options):
16
16
 
17
17
  fonts.load()
18
18
 
19
- print(f"Installed to: {settings.data_path}")
20
-
21
- if "--install-big-sky" in options:
22
- bigsky.download_if_not_exists()
23
- print(f"Big Sky Catalog downloaded and installed to: {settings.download_path}")
19
+ print(f"Downloading data catalogs to: {settings.data_path}")
20
+ download_all_catalogs()
24
21
 
25
22
 
26
23
  def main():
starplot/config.py CHANGED
@@ -54,6 +54,7 @@ class Settings:
54
54
  Supported values:
55
55
 
56
56
  - `en-us` = English (default)
57
+ - `es` = Spanish
57
58
  - `fa` = Persian (Farsi). Make sure you have a Persian font installed that supports RTL (such as [Vazir](https://github.com/rastikerdar/vazir-font) or [Noto Sans Arabic](https://fonts.google.com/noto/specimen/Noto+Sans+Arabic)) and set it as the font in your plot's style.
58
59
  - `fr` = French
59
60
  - `lt` = Lithuanian
starplot/data/__init__.py CHANGED
@@ -1,9 +1,11 @@
1
+ # ruff: noqa: F401,F403
2
+
1
3
  from pathlib import Path
2
4
 
3
5
  from skyfield.api import Loader
4
6
 
5
7
  from starplot.config import settings
6
- from .catalogs import Catalog # noqa: F401
8
+ from .catalogs import Catalog
7
9
 
8
10
  load = Loader(settings.data_path) # used for loading ephemeris
9
11
 
@@ -16,9 +18,5 @@ INTERNAL_DATA_PATH = HERE / "library"
16
18
 
17
19
  class DataFiles:
18
20
  STAR_DESIGNATIONS = INTERNAL_DATA_PATH / "star_designations.parquet"
19
-
20
21
  CONSTELLATION_NAMES = INTERNAL_DATA_PATH / "constellation_names.parquet"
21
-
22
22
  DSO_NAMES = INTERNAL_DATA_PATH / "dso_names.parquet"
23
-
24
- DATABASE = INTERNAL_DATA_PATH / "sky.db"
starplot/data/catalogs.py CHANGED
@@ -290,31 +290,31 @@ class Catalog:
290
290
  # --------------------------------------------------------
291
291
 
292
292
  BIG_SKY = Catalog(
293
- path=settings.data_path / "stars.bigksy.0.1.2.mag16.parquet",
294
- url="https://github.com/steveberardi/starplot-bigsky/releases/download/v0.1.1/stars.bigksy.0.1.1.mag16.parquet",
293
+ path=settings.data_path / "stars.bigksy.0.1.3.mag16.parquet",
294
+ url="https://github.com/steveberardi/starplot-bigsky/releases/download/v0.1.3/stars.bigksy.0.1.3.mag16.parquet",
295
295
  )
296
296
  """
297
297
  [Big Sky Catalog](https://github.com/steveberardi/bigsky) ~ 2.5M stars
298
298
 
299
- This is the full version of the Big Sky Catalog, which includes 2,557,500 stars from Hipparcos, Tycho-1, and Tycho-2.
299
+ This is the full version of the Big Sky Catalog, which includes 2,557,501 stars from Hipparcos, Tycho-1, and Tycho-2.
300
300
  """
301
301
 
302
302
  BIG_SKY_MAG11 = Catalog(
303
- path=settings.data_path / "stars.bigksy.0.1.2.mag11.parquet",
304
- url="https://github.com/steveberardi/starplot-bigsky/releases/download/v0.1.1/stars.bigksy.0.1.1.mag11.parquet",
303
+ path=settings.data_path / "stars.bigksy.0.1.3.mag11.parquet",
304
+ url="https://github.com/steveberardi/starplot-bigsky/releases/download/v0.1.3/stars.bigksy.0.1.3.mag11.parquet",
305
305
  )
306
306
  """
307
- [Big Sky Catalog](https://github.com/steveberardi/bigsky) ~ 983,822 stars with limiting magnitude 11
307
+ [Big Sky Catalog](https://github.com/steveberardi/bigsky) ~ 983,823 stars with limiting magnitude 11
308
308
 
309
309
  This is an _abridged_ version of the Big Sky Catalog.
310
310
  """
311
311
 
312
312
  BIG_SKY_MAG9 = Catalog(
313
- path=settings.data_path / "stars.bigksy.0.1.2.mag9.parquet",
314
- url="https://github.com/steveberardi/starplot-bigsky/releases/download/v0.1.1/stars.bigksy.0.1.1.mag9.parquet",
313
+ path=settings.data_path / "stars.bigksy.0.1.3.mag9.parquet",
314
+ url="https://github.com/steveberardi/starplot-bigsky/releases/download/v0.1.3/stars.bigksy.0.1.3.mag9.parquet",
315
315
  )
316
316
  """
317
- [Big Sky Catalog](https://github.com/steveberardi/bigsky) ~ 136,125 stars with limiting magnitude 9
317
+ [Big Sky Catalog](https://github.com/steveberardi/bigsky) ~ 136,126 stars with limiting magnitude 9
318
318
 
319
319
  This is an _abridged_ version of the Big Sky Catalog.
320
320
  """
@@ -328,13 +328,23 @@ OPEN_NGC = Catalog(
328
328
  """
329
329
 
330
330
  CONSTELLATIONS_IAU = Catalog(
331
- path=settings.data_path / "constellations-iau-0.1.2.parquet",
332
- url="https://github.com/steveberardi/starplot-constellations/releases/download/v0.1.1/constellations.0.1.1.parquet",
331
+ path=settings.data_path / "constellations-iau-0.2.0.parquet",
332
+ url="https://github.com/steveberardi/starplot-constellations/releases/download/v0.2.0/constellations.0.2.0.parquet",
333
333
  )
334
334
  """
335
335
  Constellations recognized by IAU, with lines by Sky & Telescope.
336
336
  """
337
337
 
338
+ CONSTELLATION_BORDERS = Catalog(
339
+ path=settings.data_path / "constellations-borders-0.2.0.parquet",
340
+ url="https://github.com/steveberardi/starplot-constellations/releases/download/v0.2.0/constellations-borders.0.2.0.parquet",
341
+ )
342
+
343
+ MILKY_WAY = Catalog(
344
+ path=settings.data_path / "milky_way-0.1.0.parquet",
345
+ url="https://github.com/steveberardi/starplot-milkyway/releases/download/v0.1.0/milky_way.parquet",
346
+ )
347
+
338
348
 
339
349
  def download_all_catalogs(silent=False):
340
350
  BIG_SKY.download_if_not_exists(silent=silent)
@@ -342,3 +352,5 @@ def download_all_catalogs(silent=False):
342
352
  BIG_SKY_MAG11.download_if_not_exists(silent=silent)
343
353
  OPEN_NGC.download_if_not_exists(silent=silent)
344
354
  CONSTELLATIONS_IAU.download_if_not_exists(silent=silent)
355
+ CONSTELLATION_BORDERS.download_if_not_exists(silent=silent)
356
+ MILKY_WAY.download_if_not_exists(silent=silent)
starplot/data/db.py CHANGED
@@ -12,13 +12,7 @@ NAME_TABLES = {
12
12
 
13
13
 
14
14
  def connect():
15
- connection = duckdb.connect(
16
- DataFiles.DATABASE,
17
- read_only=True,
18
- # threads=4,
19
- # memory_limit="1GB",
20
- )
21
-
15
+ connection = duckdb.connect()
22
16
  path = settings.data_path / "duckdb-extensions"
23
17
  connection.raw_sql(f"SET extension_directory = '{str(path)}';")
24
18
 
Binary file
@@ -46,6 +46,50 @@ LABELS = {
46
46
  "w": "w",
47
47
  "milky way": "milky way",
48
48
  },
49
+ "es": {
50
+ "star": "estrella",
51
+ "deep sky object": "objeto de cielo profundo",
52
+ "open cluster": "cúmulo abierto",
53
+ "globular cluster": "cúmulo globular",
54
+ "nebula": "nebulosa",
55
+ "galaxy": "galaxia",
56
+ "dark nebula": "nebulosa oscura",
57
+ "association of stars": "asociación estelar",
58
+ "double star": "estrella doble",
59
+ "emission nebula": "nebulosa de emisión",
60
+ "galaxy pair": "galaxia doble",
61
+ "galaxy triplet": "galaxia triple",
62
+ "galaxy cluster": "cúmulo de galaxias",
63
+ "group of galaxies": "grupo de galaxias",
64
+ "hii ionized region": "región ionizada hii",
65
+ "nova star": "estrella nova",
66
+ "planetary nebula": "nebulosa planetaria",
67
+ "reflection nebula": "nebulosa de reflexión",
68
+ "star cluster nebula": "nebulosa de cúmulo abierto",
69
+ "supernova remnant": "remanente de supernova",
70
+ "unknown": "desconocido",
71
+ "mercury": "mercurio",
72
+ "venus": "venus",
73
+ "mars": "marte",
74
+ "jupiter": "júpiter",
75
+ "saturn": "saturno",
76
+ "uranus": "urano",
77
+ "neptune": "neptuno",
78
+ "pluto": "plutón",
79
+ "sun": "sol",
80
+ "moon": "luna",
81
+ "north": "norte",
82
+ "east": "este",
83
+ "south": "sur",
84
+ "west": "oeste",
85
+ "ecliptic": "eclíptica",
86
+ "celestial equator": "ecuador celeste",
87
+ "n": "n",
88
+ "e": "e",
89
+ "s": "s",
90
+ "w": "o",
91
+ "milky way": "vía láctea",
92
+ },
49
93
  "fr": {
50
94
  "legend": "légende",
51
95
  "star magnitude": "magnitude des étoiles",
@@ -284,6 +328,7 @@ LABELS = {
284
328
 
285
329
  LANGUAGES = [
286
330
  "en-us",
331
+ "es",
287
332
  "fa",
288
333
  "fr",
289
334
  "lt",
@@ -1,5 +1,6 @@
1
1
  # ruff: noqa: F401,F403
2
- from .constellation import Constellation
2
+
3
+ from .constellation import Constellation, ConstellationBorder
3
4
  from .comet import Comet
4
5
  from .dso import DSO, DsoType
5
6
  from .star import Star
@@ -17,3 +18,4 @@ from .optics import (
17
18
  from .objects import ObjectList
18
19
  from .satellite import Satellite
19
20
  from .observer import Observer
21
+ from .milky_way import MilkyWay
@@ -2,7 +2,7 @@ from typing import Iterator
2
2
  from dataclasses import dataclass
3
3
 
4
4
  from ibis import _
5
- from shapely import Polygon, MultiPolygon
5
+ from shapely import Polygon, MultiPolygon, LineString
6
6
 
7
7
  from starplot.models.base import SkyObject, CatalogObject
8
8
  from starplot.data.catalogs import Catalog, CONSTELLATIONS_IAU
@@ -132,3 +132,9 @@ def from_tuple(c: tuple) -> Constellation:
132
132
  kwargs = {f: getattr(c, f) for f in Constellation._fields() if hasattr(c, f)}
133
133
  c = Constellation(**kwargs)
134
134
  return c
135
+
136
+
137
+ @dataclass(slots=True, kw_only=True)
138
+ class ConstellationBorder(CatalogObject, SkyObject):
139
+ geometry: LineString
140
+ """Shapely LineString of the border. Right ascension coordinates are in degrees (0...360)."""
@@ -0,0 +1,30 @@
1
+ from dataclasses import dataclass
2
+
3
+ import pyarrow as pa
4
+ from shapely import Polygon, MultiPolygon
5
+
6
+ from starplot.models.base import SkyObject, CatalogObject
7
+
8
+
9
+ @dataclass(slots=True, kw_only=True)
10
+ class MilkyWay(CatalogObject, SkyObject):
11
+ """
12
+ Milky Way model.
13
+ """
14
+
15
+ geometry: Polygon | MultiPolygon
16
+ """Shapely Polygon of the Milky Way's extent. Right ascension coordinates are in degrees (0...360)."""
17
+
18
+ @classmethod
19
+ def _pyarrow_schema(cls):
20
+ base_schema = super(MilkyWay, cls)._pyarrow_schema()
21
+ extra_fields = [
22
+ pa.field("pk", pa.int64(), nullable=False),
23
+ pa.field("geometry", pa.binary(), nullable=False),
24
+ ]
25
+ return pa.schema(list(base_schema) + extra_fields)
26
+
27
+
28
+ def from_tuple(d: tuple) -> MilkyWay:
29
+ kwargs = {f: getattr(d, f) for f in MilkyWay._fields() if hasattr(d, f)}
30
+ return MilkyWay(**kwargs)
@@ -6,6 +6,8 @@ from skyfield.timelib import Timescale
6
6
 
7
7
  from starplot.data import load
8
8
 
9
+ ts = load.timescale()
10
+
9
11
 
10
12
  class Observer(BaseModel):
11
13
  """
@@ -19,8 +21,8 @@ class Observer(BaseModel):
19
21
  lat=33.363484,
20
22
  lon=-116.836394,
21
23
  )
22
-
23
24
  ```
25
+
24
26
  """
25
27
 
26
28
  dt: AwareDatetime = Field(default_factory=lambda: datetime.now(timezone.utc))
@@ -47,7 +49,7 @@ class Observer(BaseModel):
47
49
 
48
50
  Timescale instance of the specified datetime (used by Skyfield)
49
51
  """
50
- return load.timescale().from_datetime(self.dt)
52
+ return ts.from_datetime(self.dt)
51
53
 
52
54
  @computed_field
53
55
  @cached_property
@@ -59,6 +61,13 @@ class Observer(BaseModel):
59
61
  """
60
62
  return float(360.0 * self.timescale.gmst / 24.0 + self.lon) % 360.0
61
63
 
64
+ @classmethod
65
+ def at_epoch(cls, epoch: float) -> "Observer":
66
+ """
67
+ Returns an Observer for the specified epoch (Julian year)
68
+ """
69
+ return Observer(dt=ts.J(epoch).utc_datetime())
70
+
62
71
  # @computed_field
63
72
  # @cached_property
64
73
  # def location(self):
@@ -0,0 +1,6 @@
1
+ # ruff: noqa: F401,F403
2
+
3
+ from .map import MapPlot
4
+ from .horizon import HorizonPlot
5
+ from .zenith import ZenithPlot
6
+ from .optic import OpticPlot