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.
Files changed (37) hide show
  1. starplot/__init__.py +28 -2
  2. starplot/base.py +36 -56
  3. starplot/config.py +16 -0
  4. starplot/data/constellations.py +5 -676
  5. starplot/data/dsos.py +7 -23
  6. starplot/data/library/bigsky.0.4.0.stars.mag11.parquet +0 -0
  7. starplot/data/library/sky.db +0 -0
  8. starplot/data/stars.py +12 -2
  9. starplot/data/translations.py +161 -0
  10. starplot/geometry.py +7 -6
  11. starplot/horizon.py +9 -8
  12. starplot/map.py +1 -1
  13. starplot/models/__init__.py +19 -7
  14. starplot/models/base.py +1 -1
  15. starplot/models/comet.py +332 -0
  16. starplot/models/constellation.py +10 -0
  17. starplot/models/dso.py +24 -0
  18. starplot/{optics.py → models/optics.py} +4 -4
  19. starplot/models/satellite.py +158 -0
  20. starplot/models/star.py +10 -0
  21. starplot/optic.py +10 -9
  22. starplot/plotters/__init__.py +1 -0
  23. starplot/plotters/arrow.py +162 -0
  24. starplot/plotters/constellations.py +15 -51
  25. starplot/plotters/dsos.py +8 -14
  26. starplot/plotters/experimental.py +559 -6
  27. starplot/plotters/legend.py +5 -0
  28. starplot/plotters/stars.py +7 -16
  29. starplot/styles/base.py +20 -1
  30. starplot/styles/extensions.py +10 -1
  31. starplot/zenith.py +4 -1
  32. {starplot-0.16.4.dist-info → starplot-0.17.0.dist-info}/METADATA +19 -15
  33. {starplot-0.16.4.dist-info → starplot-0.17.0.dist-info}/RECORD +37 -33
  34. /starplot/{observer.py → models/observer.py} +0 -0
  35. {starplot-0.16.4.dist-info → starplot-0.17.0.dist-info}/WHEEL +0 -0
  36. {starplot-0.16.4.dist-info → starplot-0.17.0.dist-info}/entry_points.txt +0 -0
  37. {starplot-0.16.4.dist-info → starplot-0.17.0.dist-info}/licenses/LICENSE +0 -0
starplot/__init__.py CHANGED
@@ -1,6 +1,6 @@
1
1
  """Star charts and maps of the sky"""
2
2
 
3
- __version__ = "0.16.4"
3
+ __version__ = "0.17.0"
4
4
 
5
5
  from .base import BasePlot # noqa: F401
6
6
  from .map import MapPlot # noqa: F401
@@ -12,14 +12,40 @@ from .models import (
12
12
  DsoType, # noqa: F401
13
13
  Star, # noqa: F401
14
14
  Constellation, # noqa: F401
15
+ Comet, # noqa: F401
15
16
  Planet, # noqa: F401
16
17
  Moon, # noqa: F401
17
18
  Sun, # noqa: F401
18
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
19
27
  )
20
28
  from .styles import * # noqa: F401 F403
21
- from .observer import Observer # noqa: F401
22
29
  from .projections import * # noqa: F401 F403
23
30
  from .config import settings # noqa: F401
24
31
 
25
32
  from ibis import _ # noqa: F401 F403
33
+
34
+
35
+ import contextlib
36
+
37
+
38
+ @contextlib.contextmanager
39
+ def override_settings(**kwargs):
40
+ original = {}
41
+
42
+ for key, value in kwargs.items():
43
+ original[key] = getattr(settings, key, None)
44
+ setattr(settings, key, value)
45
+
46
+ try:
47
+ yield
48
+
49
+ finally:
50
+ for key, value in original.items():
51
+ setattr(settings, key, value)
starplot/base.py CHANGED
@@ -16,9 +16,11 @@ from starplot.coordinates import CoordinateSystem
16
16
  from starplot import geod, models, warnings
17
17
  from starplot.config import settings as StarplotSettings, SvgTextType
18
18
  from starplot.data import load, ecliptic
19
+ from starplot.data.translations import translate
19
20
  from starplot.models.planet import PlanetName, PLANET_LABELS_DEFAULT
20
21
  from starplot.models.moon import MoonPhase
21
- from starplot.observer import Observer
22
+ from starplot.models.optics import Optic, Camera
23
+ from starplot.models.observer import Observer
22
24
  from starplot.styles import (
23
25
  AnchorPointEnum,
24
26
  PlotStyle,
@@ -47,16 +49,6 @@ LOG_FORMATTER = logging.Formatter(
47
49
  LOG_HANDLER.setFormatter(LOG_FORMATTER)
48
50
  LOGGER.addHandler(LOG_HANDLER)
49
51
 
50
-
51
- DEFAULT_FOV_STYLE = PolygonStyle(
52
- fill_color=None,
53
- edge_color="red",
54
- line_style=[1, [2, 3]],
55
- edge_width=3,
56
- zorder=-1000,
57
- )
58
- """Default style for plotting scope and bino field of view circles"""
59
-
60
52
  DEFAULT_STYLE = PlotStyle()
61
53
 
62
54
  DEFAULT_RESOLUTION = 4096
@@ -108,6 +100,8 @@ class BasePlot(ABC):
108
100
  px = 1 / DPI # plt.rcParams["figure.dpi"] # pixel in inches
109
101
  self.pixels_per_point = DPI / 72
110
102
 
103
+ self.language = StarplotSettings.language
104
+
111
105
  self.style = style
112
106
  self.figure_size = resolution * px
113
107
  self.resolution = resolution
@@ -739,8 +733,11 @@ class BasePlot(ABC):
739
733
  self.observer.dt, self.observer.lat, self.observer.lon, self._ephemeris_name
740
734
  )
741
735
 
736
+ legend_label = translate(legend_label, self.language)
737
+
742
738
  for p in planets:
743
739
  label = labels.get(p.name)
740
+ label = translate(label, self.language)
744
741
 
745
742
  if self.in_bounds(p.ra, p.dec):
746
743
  self._objects.planets.append(p)
@@ -796,6 +793,8 @@ class BasePlot(ABC):
796
793
  lon=self.observer.lon,
797
794
  ephemeris=self._ephemeris_name,
798
795
  )
796
+ label = translate(label, self.language)
797
+ legend_label = translate(legend_label, self.language)
799
798
  s.name = label or s.name
800
799
 
801
800
  if not self.in_bounds(s.ra, s.dec):
@@ -1074,6 +1073,8 @@ class BasePlot(ABC):
1074
1073
  lon=self.observer.lon,
1075
1074
  ephemeris=self._ephemeris_name,
1076
1075
  )
1076
+ label = translate(label, self.language)
1077
+ legend_label = translate(legend_label, self.language)
1077
1078
  m.name = label or m.name
1078
1079
 
1079
1080
  if not self.in_bounds(m.ra, m.dec):
@@ -1207,61 +1208,36 @@ class BasePlot(ABC):
1207
1208
  gid="moon-marker",
1208
1209
  )
1209
1210
 
1210
- def _fov_circle(
1211
- self, ra, dec, fov, magnification, style: PolygonStyle = DEFAULT_FOV_STYLE
1212
- ):
1213
- # FOV (degrees) = FOV eyepiece / magnification
1214
- fov_degrees = fov / magnification
1215
- fov_radius = fov_degrees / 2
1216
- self.circle(
1217
- (ra, dec),
1218
- fov_radius,
1219
- style=style,
1220
- )
1221
-
1222
- @use_style(PolygonStyle)
1223
- def scope_fov(
1224
- self,
1225
- ra: float,
1226
- dec: float,
1227
- scope_focal_length: float,
1228
- eyepiece_focal_length: float,
1229
- eyepiece_fov: float,
1230
- style: PolygonStyle = DEFAULT_FOV_STYLE,
1231
- ):
1232
- """Draws a circle representing the field of view for a telescope and eyepiece.
1233
-
1234
- Args:
1235
- ra: Right ascension of the center of view
1236
- dec: Declination of the center of view
1237
- scope_focal_length: focal length (mm) of the scope
1238
- eyepiece_focal_length: focal length (mm) of the eyepiece
1239
- eyepiece_fov: field of view (degrees) of the eyepiece
1240
- style: style of the polygon
1241
- """
1242
- # FOV (degrees) = FOV eyepiece / magnification
1243
- magnification = scope_focal_length / eyepiece_focal_length
1244
- self._fov_circle(ra, dec, eyepiece_fov, magnification, style)
1245
-
1246
- @use_style(PolygonStyle)
1247
- def bino_fov(
1211
+ @use_style(PolygonStyle, "optic_fov")
1212
+ def optic_fov(
1248
1213
  self,
1249
1214
  ra: float,
1250
1215
  dec: float,
1251
- fov: float,
1252
- magnification: float,
1253
- style: PolygonStyle = DEFAULT_FOV_STYLE,
1216
+ optic: Optic,
1217
+ style: PolygonStyle = None,
1254
1218
  ):
1255
- """Draws a circle representing the field of view for binoculars.
1219
+ """Draws a polygon representing the field of view for an optic, centered at a specific point.
1256
1220
 
1257
1221
  Args:
1258
1222
  ra: Right ascension of the center of view
1259
1223
  dec: Declination of the center of view
1260
- fov: field of view (degrees) of the binoculars
1261
- magnification: magnification of the binoculars
1224
+ optic: Instance of an [Optic][starplot.models.Optic]
1262
1225
  style: style of the polygon
1263
1226
  """
1264
- self._fov_circle(ra, dec, fov, magnification, style)
1227
+ if isinstance(optic, Camera):
1228
+ self.rectangle(
1229
+ center=(ra, dec),
1230
+ height_degrees=optic.true_fov_y,
1231
+ width_degrees=optic.true_fov_x,
1232
+ angle=optic.rotation,
1233
+ style=style,
1234
+ )
1235
+ else:
1236
+ self.circle(
1237
+ center=(ra, dec),
1238
+ radius_degrees=optic.true_fov / 2,
1239
+ style=style,
1240
+ )
1265
1241
 
1266
1242
  @use_style(PathStyle, "ecliptic")
1267
1243
  def ecliptic(self, style: PathStyle = None, label: str = "ECLIPTIC"):
@@ -1275,6 +1251,8 @@ class BasePlot(ABC):
1275
1251
  y = []
1276
1252
  inbounds = []
1277
1253
 
1254
+ label = translate(label, self.language)
1255
+
1278
1256
  for ra, dec in ecliptic.RA_DECS:
1279
1257
  x0, y0 = self._prepare_coords(ra * 15, dec)
1280
1258
  x.append(x0)
@@ -1314,6 +1292,8 @@ class BasePlot(ABC):
1314
1292
 
1315
1293
  # TODO : handle wrapping
1316
1294
 
1295
+ label = translate(label, self.language)
1296
+
1317
1297
  for ra in range(25):
1318
1298
  x0, y0 = self._prepare_coords(ra * 15, 0)
1319
1299
  x.append(x0)
starplot/config.py CHANGED
@@ -1,4 +1,5 @@
1
1
  import os
2
+
2
3
  from enum import Enum
3
4
  from pathlib import Path
4
5
  from dataclasses import dataclass, field
@@ -68,5 +69,20 @@ class Settings:
68
69
 
69
70
  """
70
71
 
72
+ language: str = field(
73
+ default_factory=lambda: os.environ.get("STARPLOT_LANGUAGE", "en-US")
74
+ )
75
+ """
76
+ Default language for plotted labels, as an ISO-639 code. Case insensitive.
77
+
78
+ Supported values:
79
+
80
+ - `en-US` = English
81
+ - `fr` = French
82
+ - `zh-CN` = Chinese. Make sure you have a good Chinese font installed (such as [Noto Sans SC](https://fonts.google.com/noto/specimen/Noto+Sans+SC)) and you'll also need to set that as the font in your plot's style.
83
+
84
+ **🌐 Want to see another language available? Please help us add it! [Details here](https://github.com/steveberardi/starplot/tree/main/data/raw/translations).**
85
+ """
86
+
71
87
 
72
88
  settings = Settings()