starplot 0.20.5__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 (98) hide show
  1. starplot/__init__.py +59 -0
  2. starplot/callables.py +176 -0
  3. starplot/cli.py +29 -0
  4. starplot/config.py +80 -0
  5. starplot/coordinates.py +7 -0
  6. starplot/data/__init__.py +22 -0
  7. starplot/data/catalogs.py +356 -0
  8. starplot/data/constellations.py +71 -0
  9. starplot/data/db.py +33 -0
  10. starplot/data/dsos.py +85 -0
  11. starplot/data/ecliptic.py +201 -0
  12. starplot/data/library/constellation_names.parquet +0 -0
  13. starplot/data/library/dso_names.parquet +0 -0
  14. starplot/data/library/readme.md +1 -0
  15. starplot/data/library/star_designations.parquet +0 -0
  16. starplot/data/stars.py +79 -0
  17. starplot/data/translations.py +408 -0
  18. starplot/data/utils.py +35 -0
  19. starplot/geometry.py +319 -0
  20. starplot/mixins.py +360 -0
  21. starplot/models/__init__.py +21 -0
  22. starplot/models/base.py +77 -0
  23. starplot/models/comet.py +302 -0
  24. starplot/models/constellation.py +151 -0
  25. starplot/models/dso.py +317 -0
  26. starplot/models/milky_way.py +30 -0
  27. starplot/models/moon.py +130 -0
  28. starplot/models/objects.py +29 -0
  29. starplot/models/observer.py +125 -0
  30. starplot/models/optics.py +342 -0
  31. starplot/models/planet.py +137 -0
  32. starplot/models/satellite.py +138 -0
  33. starplot/models/star.py +253 -0
  34. starplot/models/sun.py +62 -0
  35. starplot/plots/__init__.py +7 -0
  36. starplot/plots/base.py +1023 -0
  37. starplot/plots/galaxy.py +372 -0
  38. starplot/plots/horizon.py +543 -0
  39. starplot/plots/map.py +515 -0
  40. starplot/plots/optic.py +469 -0
  41. starplot/plots/zenith.py +217 -0
  42. starplot/plotters/__init__.py +9 -0
  43. starplot/plotters/arrow.py +174 -0
  44. starplot/plotters/constellations.py +298 -0
  45. starplot/plotters/debug.py +21 -0
  46. starplot/plotters/dsos.py +294 -0
  47. starplot/plotters/experimental.py +722 -0
  48. starplot/plotters/gradients.py +153 -0
  49. starplot/plotters/legend.py +253 -0
  50. starplot/plotters/milkyway.py +51 -0
  51. starplot/plotters/stars.py +319 -0
  52. starplot/plotters/text.py +802 -0
  53. starplot/profile.py +16 -0
  54. starplot/projections.py +184 -0
  55. starplot/styles/__init__.py +6 -0
  56. starplot/styles/base.py +1344 -0
  57. starplot/styles/ext/antique.yml +175 -0
  58. starplot/styles/ext/blue_dark.yml +163 -0
  59. starplot/styles/ext/blue_gold.yml +147 -0
  60. starplot/styles/ext/blue_light.yml +123 -0
  61. starplot/styles/ext/blue_medium.yml +142 -0
  62. starplot/styles/ext/blue_night.yml +185 -0
  63. starplot/styles/ext/cb_wong.yml +124 -0
  64. starplot/styles/ext/color_print.yml +111 -0
  65. starplot/styles/ext/gradient_presets.yml +158 -0
  66. starplot/styles/ext/grayscale.yml +94 -0
  67. starplot/styles/ext/grayscale_dark.yml +136 -0
  68. starplot/styles/ext/map.yml +12 -0
  69. starplot/styles/ext/nord.yml +158 -0
  70. starplot/styles/ext/optic.yml +20 -0
  71. starplot/styles/ext/publication.yml +8 -0
  72. starplot/styles/extensions.py +129 -0
  73. starplot/styles/fonts-library/gfs-didot/DESCRIPTION.en_us.html +9 -0
  74. starplot/styles/fonts-library/gfs-didot/GFSDidot-Regular.ttf +0 -0
  75. starplot/styles/fonts-library/gfs-didot/METADATA.pb +16 -0
  76. starplot/styles/fonts-library/gfs-didot/OFL.txt +94 -0
  77. starplot/styles/fonts-library/inter/Inter-Bold.ttf +0 -0
  78. starplot/styles/fonts-library/inter/Inter-BoldItalic.ttf +0 -0
  79. starplot/styles/fonts-library/inter/Inter-ExtraBold.ttf +0 -0
  80. starplot/styles/fonts-library/inter/Inter-ExtraLight.ttf +0 -0
  81. starplot/styles/fonts-library/inter/Inter-ExtraLightItalic.ttf +0 -0
  82. starplot/styles/fonts-library/inter/Inter-Italic.ttf +0 -0
  83. starplot/styles/fonts-library/inter/Inter-Light.ttf +0 -0
  84. starplot/styles/fonts-library/inter/Inter-LightItalic.ttf +0 -0
  85. starplot/styles/fonts-library/inter/Inter-Regular.ttf +0 -0
  86. starplot/styles/fonts-library/inter/Inter-SemiBold.ttf +0 -0
  87. starplot/styles/fonts-library/inter/Inter-SemiBoldItalic.ttf +0 -0
  88. starplot/styles/fonts-library/inter/LICENSE.txt +92 -0
  89. starplot/styles/fonts.py +15 -0
  90. starplot/styles/helpers.py +93 -0
  91. starplot/styles/markers.py +308 -0
  92. starplot/utils.py +169 -0
  93. starplot/warnings.py +21 -0
  94. starplot-0.20.5.dist-info/METADATA +146 -0
  95. starplot-0.20.5.dist-info/RECORD +98 -0
  96. starplot-0.20.5.dist-info/WHEEL +4 -0
  97. starplot-0.20.5.dist-info/entry_points.txt +3 -0
  98. starplot-0.20.5.dist-info/licenses/LICENSE +21 -0
starplot/profile.py ADDED
@@ -0,0 +1,16 @@
1
+ import time
2
+
3
+
4
+ def profile(func):
5
+ def wrapper(*args, **kwargs):
6
+ start = time.time()
7
+
8
+ result = func(*args, **kwargs)
9
+
10
+ duration = round(time.time() - start, 4)
11
+
12
+ args[0].logger.debug(f"{func.__name__} = {str(duration)} sec")
13
+
14
+ return result
15
+
16
+ return wrapper
@@ -0,0 +1,184 @@
1
+ from abc import ABC
2
+ from functools import cached_property
3
+
4
+ from cartopy import crs as ccrs
5
+ from pydantic import BaseModel, Field
6
+
7
+
8
+ class CenterRA(BaseModel, ABC):
9
+ center_ra: float = Field(default=180, ge=0, le=360)
10
+ """Central right ascension"""
11
+
12
+
13
+ class CenterDEC(BaseModel, ABC):
14
+ center_dec: float = Field(default=0, ge=-90, le=90)
15
+ """Central declination"""
16
+
17
+
18
+ class CenterRADEC(CenterRA, CenterDEC):
19
+ pass
20
+
21
+
22
+ class Azimuth(BaseModel, ABC):
23
+ azimuth: float = Field(default=0, ge=0, le=360)
24
+ """Direction of central line of the projection"""
25
+
26
+
27
+ class ProjectionBase(BaseModel, ABC):
28
+ threshold: int = 1000
29
+
30
+ _ccrs = None
31
+
32
+ class Config:
33
+ arbitrary_types_allowed = True
34
+
35
+ @cached_property
36
+ def crs(self):
37
+ kwargs = {}
38
+
39
+ if hasattr(self, "center_ra"):
40
+ kwargs["central_longitude"] = -1 * self.center_ra
41
+
42
+ if hasattr(self, "center_dec"):
43
+ kwargs["central_latitude"] = self.center_dec
44
+
45
+ if hasattr(self, "azimuth"):
46
+ kwargs["azimuth"] = self.azimuth
47
+
48
+ c = self._ccrs(**kwargs)
49
+ c.threshold = self.threshold
50
+ return c
51
+
52
+
53
+ class AutoProjection:
54
+ """
55
+ Automatically selects a projection based on the RA/DEC extent you specify when creating the map plot.
56
+
57
+ This uses a pretty simple method:
58
+
59
+ 1. If the extent is the full celestial sphere (RA is 0 to 360 and DEC is -90 to 90), then it'll use Mollweide
60
+
61
+ 2. If the max declination is greater than 75 and the min is greater than or equal to 0, then it'll use a Stereographic North projection
62
+
63
+ 3. If the max declination is less than or equal to 0 and the min is less than -75, then it'll use a Stereographic South projection
64
+
65
+ 4. If the extent doesn't match any of the above, then it'll use a Miller projection
66
+
67
+ In all cases, it sets the central RA to the midpoint of the RA extent.
68
+
69
+ Unlike the other projection options, this class does not expose any public parameters (e.g. center RA/DEC), since everything is determined automatically.
70
+
71
+ To use this automatic projection:
72
+
73
+ ```python
74
+
75
+ from starplot import MapPlot, AutoProjection
76
+
77
+ p = MapPlot(
78
+ projection=AutoProjection(),
79
+ ra_min=4 * 15,
80
+ ra_max=6 * 15,
81
+ dec_min=0,
82
+ dec_max=20,
83
+ )
84
+ ```
85
+ """
86
+
87
+ def _is_global(
88
+ self, ra_min: float, ra_max: float, dec_min: float, dec_max: float
89
+ ) -> bool:
90
+ return ra_min == 0 and ra_max == 360 and dec_min == -90 and dec_max == 90
91
+
92
+ def crs(self, ra_min: float, ra_max: float, dec_min: float, dec_max: float):
93
+ central_longitude = -1 * (ra_min + ra_max) / 2
94
+
95
+ if self._is_global(ra_min, ra_max, dec_min, dec_max):
96
+ c = ccrs.Mollweide(central_longitude=central_longitude)
97
+
98
+ elif dec_max < 75 and dec_min > -75:
99
+ c = ccrs.Miller(central_longitude=central_longitude)
100
+
101
+ elif dec_max > 75 and dec_min >= 0:
102
+ c = ccrs.NorthPolarStereo(central_longitude=central_longitude)
103
+
104
+ elif dec_max <= 0 and dec_min < -75:
105
+ c = ccrs.SouthPolarStereo(central_longitude=central_longitude)
106
+
107
+ else:
108
+ c = ccrs.Miller(central_longitude=central_longitude)
109
+
110
+ c.threshold = 1_000
111
+
112
+ return c
113
+
114
+
115
+ class Miller(ProjectionBase, CenterRA):
116
+ """Similar to Mercator: good for declinations between -70 and 70, but distorts objects near the poles"""
117
+
118
+ _ccrs = ccrs.Miller
119
+
120
+
121
+ class Mercator(ProjectionBase, CenterRA):
122
+ """Good for declinations between -70 and 70, but distorts objects near the poles"""
123
+
124
+ _ccrs = ccrs.Mercator
125
+
126
+
127
+ class PlateCarree(ProjectionBase, CenterRA):
128
+ """An equirectangular projection"""
129
+
130
+ _ccrs = ccrs.PlateCarree
131
+
132
+
133
+ class ObliqueMercator(ProjectionBase, CenterRADEC, Azimuth):
134
+ """Oblique Mercator projection"""
135
+
136
+ _ccrs = ccrs.ObliqueMercator
137
+
138
+
139
+ class Mollweide(ProjectionBase, CenterRA):
140
+ """Good for showing the entire celestial sphere in one plot"""
141
+
142
+ _ccrs = ccrs.Mollweide
143
+
144
+
145
+ class Equidistant(ProjectionBase, CenterRADEC):
146
+ """Shows accurate distances from the center position. Often used for planispheres."""
147
+
148
+ _ccrs = ccrs.AzimuthalEquidistant
149
+
150
+
151
+ class StereoNorth(ProjectionBase, CenterRA):
152
+ """Good for objects near the north celestial pole, but distorts objects near the mid declinations"""
153
+
154
+ _ccrs = ccrs.NorthPolarStereo
155
+
156
+
157
+ class StereoSouth(ProjectionBase, CenterRA):
158
+ """Good for objects near the south celestial pole, but distorts objects near the mid declinations"""
159
+
160
+ _ccrs = ccrs.SouthPolarStereo
161
+
162
+
163
+ class Robinson(ProjectionBase, CenterRA):
164
+ """Good for showing the entire celestial sphere in one plot"""
165
+
166
+ _ccrs = ccrs.Robinson
167
+
168
+
169
+ class LambertAzEqArea(ProjectionBase, CenterRADEC):
170
+ """Lambert Azimuthal Equal-Area projection - accurately shows area, but distorts angles."""
171
+
172
+ _ccrs = ccrs.LambertAzimuthalEqualArea
173
+
174
+
175
+ class Orthographic(ProjectionBase, CenterRADEC):
176
+ """Shows the celestial sphere as a 3D-looking globe. Objects near the edges will be distorted."""
177
+
178
+ _ccrs = ccrs.Orthographic
179
+
180
+
181
+ class Stereographic(ProjectionBase, CenterRADEC):
182
+ """Similar to the North/South Stereographic projection, but allows custom central declination"""
183
+
184
+ _ccrs = ccrs.Stereographic
@@ -0,0 +1,6 @@
1
+ # ruff: noqa: F401,F403
2
+
3
+ from .base import *
4
+ from .helpers import *
5
+
6
+ import starplot.styles.extensions as style_extensions