starplot 0.12.4__py2.py3-none-any.whl → 0.13.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.
Potentially problematic release.
This version of starplot might be problematic. Click here for more details.
- starplot/__init__.py +1 -1
- starplot/base.py +371 -60
- starplot/callables.py +61 -7
- starplot/data/bayer.py +1532 -3
- starplot/data/flamsteed.py +2682 -0
- starplot/data/library/constellation_borders_inv.gpkg +0 -0
- starplot/data/library/constellation_lines_hips.json +3 -1
- starplot/data/stars.py +408 -87
- starplot/horizon.py +398 -0
- starplot/map.py +149 -24
- starplot/models/constellation.py +1 -0
- starplot/optic.py +26 -14
- starplot/plotters/dsos.py +6 -2
- starplot/plotters/stars.py +114 -13
- starplot/styles/base.py +263 -156
- starplot/styles/ext/antique.yml +45 -39
- starplot/styles/ext/blue_dark.yml +32 -36
- starplot/styles/ext/blue_light.yml +43 -25
- starplot/styles/ext/blue_medium.yml +48 -44
- starplot/styles/ext/cb_wong.yml +7 -0
- starplot/styles/ext/grayscale.yml +13 -7
- starplot/styles/ext/grayscale_dark.yml +12 -4
- starplot/styles/ext/map.yml +4 -4
- starplot/styles/ext/nord.yml +32 -32
- starplot/styles/ext/optic.yml +7 -5
- starplot/styles/fonts-library/gfs-didot/DESCRIPTION.en_us.html +9 -0
- starplot/styles/fonts-library/gfs-didot/GFSDidot-Regular.ttf +0 -0
- starplot/styles/fonts-library/gfs-didot/METADATA.pb +16 -0
- starplot/styles/fonts-library/gfs-didot/OFL.txt +94 -0
- starplot/styles/fonts-library/hind/DESCRIPTION.en_us.html +28 -0
- starplot/styles/fonts-library/hind/Hind-Bold.ttf +0 -0
- starplot/styles/fonts-library/hind/Hind-Light.ttf +0 -0
- starplot/styles/fonts-library/hind/Hind-Medium.ttf +0 -0
- starplot/styles/fonts-library/hind/Hind-Regular.ttf +0 -0
- starplot/styles/fonts-library/hind/Hind-SemiBold.ttf +0 -0
- starplot/styles/fonts-library/hind/METADATA.pb +58 -0
- starplot/styles/fonts-library/hind/OFL.txt +93 -0
- starplot/styles/fonts-library/inter/Inter-Black.ttf +0 -0
- starplot/styles/fonts-library/inter/Inter-BlackItalic.ttf +0 -0
- starplot/styles/fonts-library/inter/Inter-Bold.ttf +0 -0
- starplot/styles/fonts-library/inter/Inter-BoldItalic.ttf +0 -0
- starplot/styles/fonts-library/inter/Inter-ExtraBold.ttf +0 -0
- starplot/styles/fonts-library/inter/Inter-ExtraBoldItalic.ttf +0 -0
- starplot/styles/fonts-library/inter/Inter-ExtraLight.ttf +0 -0
- starplot/styles/fonts-library/inter/Inter-ExtraLightItalic.ttf +0 -0
- starplot/styles/fonts-library/inter/Inter-Italic.ttf +0 -0
- starplot/styles/fonts-library/inter/Inter-Light.ttf +0 -0
- starplot/styles/fonts-library/inter/Inter-LightItalic.ttf +0 -0
- starplot/styles/fonts-library/inter/Inter-Medium.ttf +0 -0
- starplot/styles/fonts-library/inter/Inter-MediumItalic.ttf +0 -0
- starplot/styles/fonts-library/inter/Inter-Regular.ttf +0 -0
- starplot/styles/fonts-library/inter/Inter-SemiBold.ttf +0 -0
- starplot/styles/fonts-library/inter/Inter-SemiBoldItalic.ttf +0 -0
- starplot/styles/fonts-library/inter/Inter-Thin.ttf +0 -0
- starplot/styles/fonts-library/inter/Inter-ThinItalic.ttf +0 -0
- starplot/styles/fonts-library/inter/LICENSE.txt +92 -0
- starplot/styles/fonts.py +15 -0
- starplot/styles/markers.py +207 -6
- {starplot-0.12.4.dist-info → starplot-0.13.0.dist-info}/METADATA +9 -10
- starplot-0.13.0.dist-info/RECORD +101 -0
- starplot-0.12.4.dist-info/RECORD +0 -67
- {starplot-0.12.4.dist-info → starplot-0.13.0.dist-info}/LICENSE +0 -0
- {starplot-0.12.4.dist-info → starplot-0.13.0.dist-info}/WHEEL +0 -0
starplot/plotters/stars.py
CHANGED
|
@@ -3,11 +3,13 @@ from functools import cache
|
|
|
3
3
|
|
|
4
4
|
from skyfield.api import Star as SkyfieldStar
|
|
5
5
|
|
|
6
|
+
# import numpy as np
|
|
7
|
+
|
|
6
8
|
from starplot import callables
|
|
7
|
-
from starplot.data import bayer, stars
|
|
9
|
+
from starplot.data import bayer, stars, flamsteed
|
|
8
10
|
from starplot.data.stars import StarCatalog, STAR_NAMES
|
|
9
11
|
from starplot.models.star import Star, from_tuple
|
|
10
|
-
from starplot.styles import ObjectStyle,
|
|
12
|
+
from starplot.styles import ObjectStyle, use_style
|
|
11
13
|
|
|
12
14
|
|
|
13
15
|
class StarPlotterMixin:
|
|
@@ -64,6 +66,7 @@ class StarPlotterMixin:
|
|
|
64
66
|
zorder=kwargs.pop("zorder", None) or style.marker.zorder,
|
|
65
67
|
edgecolors=edge_colors,
|
|
66
68
|
alpha=alphas,
|
|
69
|
+
gid="stars",
|
|
67
70
|
**self._plot_kwargs(),
|
|
68
71
|
**kwargs,
|
|
69
72
|
)
|
|
@@ -77,24 +80,90 @@ class StarPlotterMixin:
|
|
|
77
80
|
def _star_labels(
|
|
78
81
|
self,
|
|
79
82
|
star_objects: list[Star],
|
|
83
|
+
star_sizes: list[float],
|
|
80
84
|
where_labels: list,
|
|
81
|
-
style:
|
|
85
|
+
style: ObjectStyle,
|
|
82
86
|
labels: Mapping[str, str],
|
|
83
87
|
bayer_labels: bool,
|
|
88
|
+
flamsteed_labels: bool,
|
|
84
89
|
label_fn: Callable[[Star], str],
|
|
85
90
|
):
|
|
86
|
-
|
|
91
|
+
_bayer = []
|
|
92
|
+
_flamsteed = []
|
|
93
|
+
|
|
94
|
+
# Plot all star common names first
|
|
95
|
+
for i, s in enumerate(star_objects):
|
|
87
96
|
if where_labels and not all([e.evaluate(s) for e in where_labels]):
|
|
88
97
|
continue
|
|
89
98
|
|
|
99
|
+
if (
|
|
100
|
+
s.hip
|
|
101
|
+
and s.hip in self._labeled_stars
|
|
102
|
+
or s.tyc
|
|
103
|
+
and s.tyc in self._labeled_stars
|
|
104
|
+
):
|
|
105
|
+
continue
|
|
106
|
+
elif s.hip:
|
|
107
|
+
self._labeled_stars.append(s.hip)
|
|
108
|
+
elif s.tyc:
|
|
109
|
+
self._labeled_stars.append(s.tyc)
|
|
110
|
+
|
|
90
111
|
label = labels.get(s.hip) if label_fn is None else label_fn(s)
|
|
91
112
|
bayer_desig = bayer.hip.get(s.hip)
|
|
113
|
+
flamsteed_num = flamsteed.hip.get(s.hip)
|
|
92
114
|
|
|
93
115
|
if label:
|
|
94
|
-
self.text(
|
|
116
|
+
self.text(
|
|
117
|
+
label,
|
|
118
|
+
s.ra,
|
|
119
|
+
s.dec,
|
|
120
|
+
# style,
|
|
121
|
+
# _offset(style, star_sizes[i]),
|
|
122
|
+
style=style.label.offset_from_marker(
|
|
123
|
+
marker_symbol=style.marker.symbol,
|
|
124
|
+
marker_size=star_sizes[i],
|
|
125
|
+
scale=self.scale,
|
|
126
|
+
),
|
|
127
|
+
hide_on_collision=self.hide_colliding_labels,
|
|
128
|
+
gid="stars-label-name",
|
|
129
|
+
)
|
|
95
130
|
|
|
96
131
|
if bayer_labels and bayer_desig:
|
|
97
|
-
|
|
132
|
+
_bayer.append((bayer_desig, s.ra, s.dec, star_sizes[i], s.hip))
|
|
133
|
+
|
|
134
|
+
if flamsteed_labels and flamsteed_num:
|
|
135
|
+
_flamsteed.append((flamsteed_num, s.ra, s.dec, star_sizes[i], s.hip))
|
|
136
|
+
|
|
137
|
+
# Plot bayer/flamsteed
|
|
138
|
+
for bayer_desig, ra, dec, star_size, _ in _bayer:
|
|
139
|
+
self.text(
|
|
140
|
+
bayer_desig,
|
|
141
|
+
ra,
|
|
142
|
+
dec,
|
|
143
|
+
style=self.style.bayer_labels.offset_from_marker(
|
|
144
|
+
marker_symbol=style.marker.symbol,
|
|
145
|
+
marker_size=star_size,
|
|
146
|
+
scale=self.scale,
|
|
147
|
+
),
|
|
148
|
+
hide_on_collision=self.hide_colliding_labels,
|
|
149
|
+
gid="stars-label-bayer",
|
|
150
|
+
)
|
|
151
|
+
|
|
152
|
+
for flamsteed_num, ra, dec, star_size, hip in _flamsteed:
|
|
153
|
+
if hip in bayer.hip:
|
|
154
|
+
continue
|
|
155
|
+
self.text(
|
|
156
|
+
flamsteed_num,
|
|
157
|
+
ra,
|
|
158
|
+
dec,
|
|
159
|
+
style=self.style.flamsteed_labels.offset_from_marker(
|
|
160
|
+
marker_symbol=style.marker.symbol,
|
|
161
|
+
marker_size=star_size,
|
|
162
|
+
scale=self.scale,
|
|
163
|
+
),
|
|
164
|
+
hide_on_collision=self.hide_colliding_labels,
|
|
165
|
+
gid="stars-label-flamsteed",
|
|
166
|
+
)
|
|
98
167
|
|
|
99
168
|
def _prepare_star_coords(self, df):
|
|
100
169
|
df["x"], df["y"] = (
|
|
@@ -119,6 +188,7 @@ class StarPlotterMixin:
|
|
|
119
188
|
labels: Mapping[int, str] = STAR_NAMES,
|
|
120
189
|
legend_label: str = "Star",
|
|
121
190
|
bayer_labels: bool = False,
|
|
191
|
+
flamsteed_labels: bool = False,
|
|
122
192
|
*args,
|
|
123
193
|
**kwargs,
|
|
124
194
|
):
|
|
@@ -138,7 +208,8 @@ class StarPlotterMixin:
|
|
|
138
208
|
where_labels: A list of expressions that determine which stars are labeled on the plot. See [Selecting Objects](/reference-selecting-objects/) for details.
|
|
139
209
|
labels: A dictionary that maps a star's HIP id to the label that'll be plotted for that star. If you want to hide name labels, then set this arg to `None`.
|
|
140
210
|
legend_label: Label for stars in the legend. If `None`, then they will not be in the legend.
|
|
141
|
-
bayer_labels: If True, then Bayer labels for stars will be plotted.
|
|
211
|
+
bayer_labels: If True, then Bayer labels for stars will be plotted.
|
|
212
|
+
flamsteed_labels: If True, then Flamsteed number labels for stars will be plotted.
|
|
142
213
|
"""
|
|
143
214
|
self.logger.debug("Plotting stars...")
|
|
144
215
|
|
|
@@ -160,8 +231,6 @@ class StarPlotterMixin:
|
|
|
160
231
|
else:
|
|
161
232
|
labels = {**STAR_NAMES, **labels}
|
|
162
233
|
|
|
163
|
-
star_size_multiplier = self._size_multiplier * style.marker.size / 5
|
|
164
|
-
|
|
165
234
|
nearby_stars_df = self._load_stars(catalog, mag)
|
|
166
235
|
nearby_stars = SkyfieldStar.from_dataframe(nearby_stars_df)
|
|
167
236
|
astrometric = self.ephemeris["earth"].at(self.timescale).observe(nearby_stars)
|
|
@@ -180,12 +249,36 @@ class StarPlotterMixin:
|
|
|
180
249
|
if not all([e.evaluate(obj) for e in where]):
|
|
181
250
|
continue
|
|
182
251
|
|
|
183
|
-
size = size_fn(obj) *
|
|
252
|
+
size = size_fn(obj) * self.scale**2
|
|
184
253
|
alpha = alpha_fn(obj)
|
|
185
254
|
color = color_fn(obj) or style.marker.color.as_hex()
|
|
186
255
|
|
|
187
256
|
starz.append((star.x, star.y, size, alpha, color, obj))
|
|
188
257
|
|
|
258
|
+
# Experimental code for keeping spatial index of plotted stars (for better label placement)
|
|
259
|
+
# if getattr(self, "_geodetic", None):
|
|
260
|
+
# # TODO : clean up!
|
|
261
|
+
# x, y = self._proj.transform_point(
|
|
262
|
+
# star.ra * -1, star.dec, self._geodetic
|
|
263
|
+
# )
|
|
264
|
+
# x0, y0 = self.ax.transData.transform((x, y))
|
|
265
|
+
|
|
266
|
+
# if (
|
|
267
|
+
# x0 < 0
|
|
268
|
+
# or y0 < 0
|
|
269
|
+
# or obj.magnitude > 5
|
|
270
|
+
# or np.isnan(x0)
|
|
271
|
+
# or np.isnan(y0)
|
|
272
|
+
# ):
|
|
273
|
+
# continue
|
|
274
|
+
# radius = 1 + (5 - obj.magnitude)
|
|
275
|
+
# # radius = max(((size**0.5 / 2) / self.scale)/1.44 - 6, 0) #size / self.scale**2 / 200
|
|
276
|
+
# self._stars_rtree.insert(
|
|
277
|
+
# 0,
|
|
278
|
+
# np.array((x0 - radius, y0 - radius, x0 + radius, y0 + radius)),
|
|
279
|
+
# obj=star.x,
|
|
280
|
+
# )
|
|
281
|
+
|
|
189
282
|
starz.sort(key=lambda s: s[2], reverse=True) # sort by descending size
|
|
190
283
|
|
|
191
284
|
if not starz:
|
|
@@ -215,6 +308,14 @@ class StarPlotterMixin:
|
|
|
215
308
|
|
|
216
309
|
self._add_legend_handle_marker(legend_label, style.marker)
|
|
217
310
|
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
311
|
+
if labels:
|
|
312
|
+
self._star_labels(
|
|
313
|
+
star_objects,
|
|
314
|
+
sizes,
|
|
315
|
+
where_labels,
|
|
316
|
+
style,
|
|
317
|
+
labels,
|
|
318
|
+
bayer_labels,
|
|
319
|
+
flamsteed_labels,
|
|
320
|
+
label_fn,
|
|
321
|
+
)
|