starplot 0.16.4__py2.py3-none-any.whl → 0.17.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.
- starplot/__init__.py +28 -2
- starplot/base.py +36 -56
- starplot/config.py +16 -0
- starplot/data/constellations.py +5 -676
- starplot/data/dsos.py +7 -23
- starplot/data/library/bigsky.0.4.0.stars.mag11.parquet +0 -0
- starplot/data/library/sky.db +0 -0
- starplot/data/stars.py +12 -2
- starplot/data/translations.py +161 -0
- starplot/geometry.py +7 -6
- starplot/horizon.py +9 -8
- starplot/map.py +1 -1
- starplot/models/__init__.py +19 -7
- starplot/models/base.py +1 -1
- starplot/models/comet.py +332 -0
- starplot/models/constellation.py +10 -0
- starplot/models/dso.py +24 -0
- starplot/{optics.py → models/optics.py} +4 -4
- starplot/models/satellite.py +158 -0
- starplot/models/star.py +10 -0
- starplot/optic.py +10 -9
- starplot/plotters/__init__.py +1 -0
- starplot/plotters/arrow.py +162 -0
- starplot/plotters/constellations.py +15 -51
- starplot/plotters/dsos.py +8 -14
- starplot/plotters/experimental.py +559 -6
- starplot/plotters/legend.py +5 -0
- starplot/plotters/stars.py +7 -16
- starplot/styles/base.py +20 -1
- starplot/styles/extensions.py +10 -1
- starplot/zenith.py +4 -1
- {starplot-0.16.4.dist-info → starplot-0.17.0.dist-info}/METADATA +19 -15
- {starplot-0.16.4.dist-info → starplot-0.17.0.dist-info}/RECORD +37 -33
- /starplot/{observer.py → models/observer.py} +0 -0
- {starplot-0.16.4.dist-info → starplot-0.17.0.dist-info}/WHEEL +0 -0
- {starplot-0.16.4.dist-info → starplot-0.17.0.dist-info}/entry_points.txt +0 -0
- {starplot-0.16.4.dist-info → starplot-0.17.0.dist-info}/licenses/LICENSE +0 -0
starplot/data/dsos.py
CHANGED
|
@@ -2,32 +2,13 @@ from functools import cache
|
|
|
2
2
|
|
|
3
3
|
from ibis import _, row_number, coalesce
|
|
4
4
|
|
|
5
|
+
from starplot.config import settings
|
|
5
6
|
from starplot.data import db
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
class DsoLabelMaker(dict):
|
|
9
|
-
"""
|
|
10
|
-
This is pretty hacky, but it helps keep a consistent interface for plotting labels and any overrides.
|
|
11
|
-
|
|
12
|
-
Basically this is just a dictionary that returns the key itself for any get() call, unless
|
|
13
|
-
the key is present in the 'overrides' dict that's passed on init
|
|
14
|
-
"""
|
|
15
|
-
|
|
16
|
-
def __init__(self, *args, **kwargs):
|
|
17
|
-
self._overrides = kwargs.get("overrides") or {}
|
|
18
|
-
|
|
19
|
-
def __getitem__(self, key):
|
|
20
|
-
return self.get(key)
|
|
21
|
-
|
|
22
|
-
def get(self, key):
|
|
23
|
-
return self._overrides.get(key) or key
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
DSO_LABELS_DEFAULT = DsoLabelMaker()
|
|
7
|
+
from starplot.data.translations import language_name_column
|
|
27
8
|
|
|
28
9
|
|
|
29
10
|
@cache
|
|
30
|
-
def table():
|
|
11
|
+
def table(language):
|
|
31
12
|
con = db.connect()
|
|
32
13
|
dsos = con.table("deep_sky_objects")
|
|
33
14
|
|
|
@@ -37,6 +18,9 @@ def table():
|
|
|
37
18
|
constellation_id=_.constellation,
|
|
38
19
|
magnitude=coalesce(_.mag_v, _.mag_b, None),
|
|
39
20
|
size=_.size_deg2,
|
|
21
|
+
common_names=getattr(
|
|
22
|
+
dsos, language_name_column(language, column_prefix="common_names")
|
|
23
|
+
),
|
|
40
24
|
rowid=row_number(),
|
|
41
25
|
sk=row_number(),
|
|
42
26
|
)
|
|
@@ -44,7 +28,7 @@ def table():
|
|
|
44
28
|
|
|
45
29
|
def load(extent=None, filters=None, sql=None):
|
|
46
30
|
filters = filters or []
|
|
47
|
-
dsos = table()
|
|
31
|
+
dsos = table(language=settings.language)
|
|
48
32
|
|
|
49
33
|
if extent:
|
|
50
34
|
dsos = dsos.filter(_.geometry.intersects(extent))
|
|
Binary file
|
starplot/data/library/sky.db
CHANGED
|
Binary file
|
starplot/data/stars.py
CHANGED
|
@@ -2,7 +2,9 @@ from functools import cache
|
|
|
2
2
|
|
|
3
3
|
from ibis import _, row_number
|
|
4
4
|
|
|
5
|
+
from starplot.config import settings
|
|
5
6
|
from starplot.data import bigsky, DataFiles, db
|
|
7
|
+
from starplot.data.translations import language_name_column
|
|
6
8
|
|
|
7
9
|
|
|
8
10
|
class StarCatalog:
|
|
@@ -31,7 +33,11 @@ class StarCatalog:
|
|
|
31
33
|
|
|
32
34
|
|
|
33
35
|
@cache
|
|
34
|
-
def table(
|
|
36
|
+
def table(
|
|
37
|
+
catalog: StarCatalog = StarCatalog.BIG_SKY_MAG11,
|
|
38
|
+
table_name="stars",
|
|
39
|
+
language: str = "en-us",
|
|
40
|
+
):
|
|
35
41
|
con = db.connect()
|
|
36
42
|
|
|
37
43
|
if catalog == StarCatalog.BIG_SKY_MAG11:
|
|
@@ -56,6 +62,10 @@ def table(catalog: StarCatalog = StarCatalog.BIG_SKY_MAG11, table_name="stars"):
|
|
|
56
62
|
sk=row_number(),
|
|
57
63
|
)
|
|
58
64
|
|
|
65
|
+
designations = designations.mutate(
|
|
66
|
+
name=getattr(designations, language_name_column(language))
|
|
67
|
+
)
|
|
68
|
+
|
|
59
69
|
stars = stars.join(
|
|
60
70
|
designations,
|
|
61
71
|
[
|
|
@@ -75,7 +85,7 @@ def load(
|
|
|
75
85
|
sql=None,
|
|
76
86
|
):
|
|
77
87
|
filters = filters or []
|
|
78
|
-
stars = table(catalog)
|
|
88
|
+
stars = table(catalog, language=settings.language)
|
|
79
89
|
|
|
80
90
|
if extent:
|
|
81
91
|
stars = stars.filter(stars.geometry.intersects(extent))
|
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
LABELS = {
|
|
2
|
+
"en-us": {
|
|
3
|
+
"legend": "legend",
|
|
4
|
+
"star magnitude": "star magnitude",
|
|
5
|
+
"star": "star",
|
|
6
|
+
"deep sky object": "deep sky object",
|
|
7
|
+
"open cluster": "open cluster",
|
|
8
|
+
"globular cluster": "globular cluster",
|
|
9
|
+
"nebula": "nebula",
|
|
10
|
+
"galaxy": "galaxy",
|
|
11
|
+
"dark nebula": "dark nebula",
|
|
12
|
+
"association of stars": "association of stars",
|
|
13
|
+
"double star": "double star",
|
|
14
|
+
"emission nebula": "emission nebula",
|
|
15
|
+
"galaxy pair": "galaxy pair",
|
|
16
|
+
"galaxy triplet": "galaxy triplet",
|
|
17
|
+
"galaxy cluster": "galaxy cluster",
|
|
18
|
+
"group of galaxies": "group of galaxies",
|
|
19
|
+
"hii ionized region": "hii ionized region",
|
|
20
|
+
"nova star": "nova star",
|
|
21
|
+
"planetary nebula": "planetary nebula",
|
|
22
|
+
"reflection nebula": "reflection nebula",
|
|
23
|
+
"star cluster nebula": "star cluster nebula",
|
|
24
|
+
"supernova remnant": "supernova remnant",
|
|
25
|
+
"unknown": "unknown",
|
|
26
|
+
"planet": "planet",
|
|
27
|
+
"mercury": "mercury",
|
|
28
|
+
"venus": "venus",
|
|
29
|
+
"mars": "mars",
|
|
30
|
+
"jupiter": "jupiter",
|
|
31
|
+
"saturn": "saturn",
|
|
32
|
+
"uranus": "uranus",
|
|
33
|
+
"neptune": "neptune",
|
|
34
|
+
"pluto": "pluto",
|
|
35
|
+
"sun": "sun",
|
|
36
|
+
"moon": "moon",
|
|
37
|
+
"north": "north",
|
|
38
|
+
"east": "east",
|
|
39
|
+
"south": "south",
|
|
40
|
+
"west": "west",
|
|
41
|
+
"ecliptic": "ecliptic",
|
|
42
|
+
"celestial equator": "celestial equator",
|
|
43
|
+
"n": "n",
|
|
44
|
+
"e": "e",
|
|
45
|
+
"s": "s",
|
|
46
|
+
"w": "w",
|
|
47
|
+
"milky way": "milky way",
|
|
48
|
+
},
|
|
49
|
+
"fr": {
|
|
50
|
+
"legend": "légende",
|
|
51
|
+
"star magnitude": "magnitude des étoiles",
|
|
52
|
+
"star": "étoile",
|
|
53
|
+
"deep sky object": "objet du ciel profond",
|
|
54
|
+
"open cluster": "amas ouvert",
|
|
55
|
+
"globular cluster": "amas globulaire",
|
|
56
|
+
"nebula": "nébuleuse",
|
|
57
|
+
"galaxy": "galaxie",
|
|
58
|
+
"dark nebula": "nébuleuse obscure",
|
|
59
|
+
"association of stars": "amas d'étoiles",
|
|
60
|
+
"double star": "étoile double",
|
|
61
|
+
"emission nebula": "nébuleuse en émission",
|
|
62
|
+
"galaxy pair": "paire de galaxies",
|
|
63
|
+
"galaxy triplet": "triplet de galaxies",
|
|
64
|
+
"galaxy cluster": "amas de galaxies",
|
|
65
|
+
"group of galaxies": "groupes de galaxies",
|
|
66
|
+
"hii ionized region": "région d'hydrogène ionisé",
|
|
67
|
+
"nova star": "nova",
|
|
68
|
+
"planetary nebula": "nébuleuse planétaire",
|
|
69
|
+
"reflection nebula": "nébuleuse par réflexion",
|
|
70
|
+
"star cluster nebula": "nébuleuse d’amas d’étoiles",
|
|
71
|
+
"supernova remnant": "rémanent de supernova",
|
|
72
|
+
"unknown": "inconnu",
|
|
73
|
+
"planet": "planète",
|
|
74
|
+
"mercury": "mercure",
|
|
75
|
+
"venus": "venus",
|
|
76
|
+
"mars": "mars",
|
|
77
|
+
"jupiter": "jupiter",
|
|
78
|
+
"saturn": "saturne",
|
|
79
|
+
"uranus": "uranus",
|
|
80
|
+
"neptune": "neptune",
|
|
81
|
+
"pluto": "pluton",
|
|
82
|
+
"sun": "soleil",
|
|
83
|
+
"moon": "lune",
|
|
84
|
+
"north": "nord",
|
|
85
|
+
"east": "est",
|
|
86
|
+
"south": "sud",
|
|
87
|
+
"west": "ouest",
|
|
88
|
+
"ecliptic": "écliptique",
|
|
89
|
+
"celestial equator": "équateur céleste",
|
|
90
|
+
"n": "n",
|
|
91
|
+
"e": "e",
|
|
92
|
+
"s": "s",
|
|
93
|
+
"w": "o",
|
|
94
|
+
"milky way": "voie lactée",
|
|
95
|
+
},
|
|
96
|
+
"zh-cn": {
|
|
97
|
+
"legend": "图例",
|
|
98
|
+
"star magnitude": "星等",
|
|
99
|
+
"star": "恒星",
|
|
100
|
+
"deep sky object": "深空天体",
|
|
101
|
+
"open cluster": "疏散星团",
|
|
102
|
+
"globular cluster": "球状星团",
|
|
103
|
+
"nebula": "星云",
|
|
104
|
+
"galaxy": "星系",
|
|
105
|
+
"dark nebula": "暗星云",
|
|
106
|
+
"association of stars": "星协",
|
|
107
|
+
"double star": "双星",
|
|
108
|
+
"emission nebula": "发射星云",
|
|
109
|
+
"galaxy pair": "星系对",
|
|
110
|
+
"galaxy triplet": "三重星系",
|
|
111
|
+
"galaxy cluster": "星系团",
|
|
112
|
+
"group of galaxies": "星系群",
|
|
113
|
+
"hii ionized region": "hii电离氢区",
|
|
114
|
+
"nova star": "新星",
|
|
115
|
+
"planetary nebula": "行星状星云",
|
|
116
|
+
"reflection nebula": "反射星云",
|
|
117
|
+
"star cluster nebula": "星团星云",
|
|
118
|
+
"supernova remnant": "超新星遗迹",
|
|
119
|
+
"unknown": "未知天体",
|
|
120
|
+
"planet": "行星",
|
|
121
|
+
"mercury": "水星",
|
|
122
|
+
"venus": "金星",
|
|
123
|
+
"mars": "火星",
|
|
124
|
+
"jupiter": "木星",
|
|
125
|
+
"saturn": "土星",
|
|
126
|
+
"uranus": "天王星",
|
|
127
|
+
"neptune": "海王星",
|
|
128
|
+
"pluto": "冥王星",
|
|
129
|
+
"sun": "太阳",
|
|
130
|
+
"moon": "月球",
|
|
131
|
+
"north": "北",
|
|
132
|
+
"east": "东",
|
|
133
|
+
"south": "南",
|
|
134
|
+
"west": "西",
|
|
135
|
+
"ecliptic": "黄道",
|
|
136
|
+
"celestial equator": "天赤道",
|
|
137
|
+
"n": "北",
|
|
138
|
+
"e": "东",
|
|
139
|
+
"s": "南",
|
|
140
|
+
"w": "西",
|
|
141
|
+
"milky way": "银河",
|
|
142
|
+
},
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
|
|
146
|
+
def language_name_column(language: str, column_prefix: str = "name") -> str:
|
|
147
|
+
language_name = language.replace("-", "_").lower()
|
|
148
|
+
|
|
149
|
+
return f"{column_prefix}_{language_name}"
|
|
150
|
+
|
|
151
|
+
|
|
152
|
+
def translate(text: str, language: str) -> str:
|
|
153
|
+
if not text:
|
|
154
|
+
return text
|
|
155
|
+
|
|
156
|
+
translation = LABELS[language.lower()].get(text.lower())
|
|
157
|
+
|
|
158
|
+
if not translation:
|
|
159
|
+
return text
|
|
160
|
+
|
|
161
|
+
return translation.title()
|
starplot/geometry.py
CHANGED
|
@@ -5,7 +5,7 @@ from typing import Union
|
|
|
5
5
|
from shapely import transform
|
|
6
6
|
from shapely.geometry import Point, Polygon, MultiPolygon
|
|
7
7
|
|
|
8
|
-
from starplot import geod
|
|
8
|
+
from starplot import geod
|
|
9
9
|
|
|
10
10
|
GLOBAL_EXTENT = Polygon(
|
|
11
11
|
[
|
|
@@ -18,17 +18,18 @@ GLOBAL_EXTENT = Polygon(
|
|
|
18
18
|
)
|
|
19
19
|
|
|
20
20
|
|
|
21
|
-
def circle(center, diameter_degrees):
|
|
21
|
+
def circle(center, diameter_degrees, num_pts=100):
|
|
22
22
|
points = geod.ellipse(
|
|
23
23
|
center,
|
|
24
24
|
diameter_degrees,
|
|
25
25
|
diameter_degrees,
|
|
26
26
|
angle=0,
|
|
27
|
-
num_pts=
|
|
27
|
+
num_pts=num_pts,
|
|
28
28
|
)
|
|
29
|
-
points = [
|
|
30
|
-
|
|
31
|
-
]
|
|
29
|
+
# points = [
|
|
30
|
+
# (round(24 - utils.lon_to_ra(lon), 4), round(dec, 4)) for lon, dec in points
|
|
31
|
+
# ]
|
|
32
|
+
points = [(round(lon, 4), round(dec, 4)) for lon, dec in points]
|
|
32
33
|
return Polygon(points)
|
|
33
34
|
|
|
34
35
|
|
starplot/horizon.py
CHANGED
|
@@ -3,9 +3,6 @@ import math
|
|
|
3
3
|
from functools import cache
|
|
4
4
|
from typing import Callable
|
|
5
5
|
|
|
6
|
-
# import pandas as pd
|
|
7
|
-
# import geopandas as gpd
|
|
8
|
-
|
|
9
6
|
from cartopy import crs as ccrs
|
|
10
7
|
from matplotlib import pyplot as plt, patches
|
|
11
8
|
from matplotlib.ticker import FixedLocator, FuncFormatter
|
|
@@ -14,13 +11,14 @@ from shapely import Point, Polygon, MultiPolygon
|
|
|
14
11
|
from starplot.coordinates import CoordinateSystem
|
|
15
12
|
from starplot.base import BasePlot, DPI
|
|
16
13
|
from starplot.mixins import ExtentMaskMixin
|
|
17
|
-
from starplot.observer import Observer
|
|
14
|
+
from starplot.models.observer import Observer
|
|
18
15
|
from starplot.plotters import (
|
|
19
16
|
ConstellationPlotterMixin,
|
|
20
17
|
StarPlotterMixin,
|
|
21
18
|
DsoPlotterMixin,
|
|
22
19
|
MilkyWayPlotterMixin,
|
|
23
20
|
GradientBackgroundMixin,
|
|
21
|
+
LegendPlotterMixin,
|
|
24
22
|
)
|
|
25
23
|
from starplot.styles import (
|
|
26
24
|
PlotStyle,
|
|
@@ -30,8 +28,6 @@ from starplot.styles import (
|
|
|
30
28
|
GradientDirection,
|
|
31
29
|
)
|
|
32
30
|
|
|
33
|
-
# pd.options.mode.chained_assignment = None # default='warn'
|
|
34
|
-
|
|
35
31
|
DEFAULT_HORIZON_STYLE = PlotStyle().extend(extensions.MAP)
|
|
36
32
|
|
|
37
33
|
DEFAULT_HORIZON_LABELS = {
|
|
@@ -55,6 +51,7 @@ class HorizonPlot(
|
|
|
55
51
|
DsoPlotterMixin,
|
|
56
52
|
MilkyWayPlotterMixin,
|
|
57
53
|
GradientBackgroundMixin,
|
|
54
|
+
LegendPlotterMixin,
|
|
58
55
|
):
|
|
59
56
|
"""Creates a new horizon plot.
|
|
60
57
|
|
|
@@ -378,6 +375,11 @@ class HorizonPlot(
|
|
|
378
375
|
label,
|
|
379
376
|
(x, patch_y + 0.027),
|
|
380
377
|
xycoords=self.ax.transAxes,
|
|
378
|
+
xytext=(
|
|
379
|
+
style.label.offset_x * self.scale,
|
|
380
|
+
style.label.offset_y * self.scale,
|
|
381
|
+
),
|
|
382
|
+
textcoords="offset points",
|
|
381
383
|
**style.label.matplot_kwargs(self.scale),
|
|
382
384
|
clip_on=False,
|
|
383
385
|
)
|
|
@@ -432,7 +434,6 @@ class HorizonPlot(
|
|
|
432
434
|
label_style_kwargs.pop("ha")
|
|
433
435
|
|
|
434
436
|
line_style_kwargs = style.line.matplot_kwargs()
|
|
435
|
-
|
|
436
437
|
gridlines = self.ax.gridlines(
|
|
437
438
|
draw_labels=show_labels,
|
|
438
439
|
x_inline=False,
|
|
@@ -497,7 +498,7 @@ class HorizonPlot(
|
|
|
497
498
|
"|",
|
|
498
499
|
(x, -0.011 * self.scale),
|
|
499
500
|
xycoords=self.ax.transAxes,
|
|
500
|
-
**
|
|
501
|
+
**style.label.matplot_kwargs(self.scale / 2),
|
|
501
502
|
)
|
|
502
503
|
|
|
503
504
|
@cache
|
starplot/map.py
CHANGED
|
@@ -14,7 +14,7 @@ from starplot.coordinates import CoordinateSystem
|
|
|
14
14
|
from starplot import geod
|
|
15
15
|
from starplot.base import BasePlot, DPI
|
|
16
16
|
from starplot.mixins import ExtentMaskMixin
|
|
17
|
-
from starplot.observer import Observer
|
|
17
|
+
from starplot.models.observer import Observer
|
|
18
18
|
from starplot.plotters import (
|
|
19
19
|
ConstellationPlotterMixin,
|
|
20
20
|
StarPlotterMixin,
|
starplot/models/__init__.py
CHANGED
|
@@ -1,7 +1,19 @@
|
|
|
1
|
-
|
|
2
|
-
from .
|
|
3
|
-
from .
|
|
4
|
-
from .
|
|
5
|
-
from .
|
|
6
|
-
from .
|
|
7
|
-
from .
|
|
1
|
+
# ruff: noqa: F401,F403
|
|
2
|
+
from .constellation import Constellation
|
|
3
|
+
from .comet import Comet
|
|
4
|
+
from .dso import DSO, DsoType
|
|
5
|
+
from .star import Star
|
|
6
|
+
from .planet import Planet
|
|
7
|
+
from .moon import Moon
|
|
8
|
+
from .sun import Sun
|
|
9
|
+
from .optics import (
|
|
10
|
+
Optic,
|
|
11
|
+
Scope,
|
|
12
|
+
Reflector,
|
|
13
|
+
Refractor,
|
|
14
|
+
Binoculars,
|
|
15
|
+
Camera,
|
|
16
|
+
)
|
|
17
|
+
from .objects import ObjectList
|
|
18
|
+
from .satellite import Satellite
|
|
19
|
+
from .observer import Observer
|
starplot/models/base.py
CHANGED
|
@@ -83,7 +83,7 @@ class SkyObject(BaseModel, CreateMapMixin, CreateOpticMixin):
|
|
|
83
83
|
def constellation_id(self) -> str | None:
|
|
84
84
|
"""Identifier of the constellation that contains this object. The ID is the three-letter (all lowercase) abbreviation from the International Astronomical Union (IAU)."""
|
|
85
85
|
if not self._constellation_id:
|
|
86
|
-
pos = position_of_radec(self.ra, self.dec)
|
|
86
|
+
pos = position_of_radec(self.ra / 15, self.dec)
|
|
87
87
|
self._constellation_id = constellation_at()(pos).lower()
|
|
88
88
|
return self._constellation_id
|
|
89
89
|
|