starplot 0.12.0__py2.py3-none-any.whl → 0.12.2__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 +1 -1
- starplot/base.py +18 -2
- starplot/map.py +17 -7
- starplot/styles/base.py +6 -5
- {starplot-0.12.0.dist-info → starplot-0.12.2.dist-info}/METADATA +1 -1
- {starplot-0.12.0.dist-info → starplot-0.12.2.dist-info}/RECORD +8 -8
- {starplot-0.12.0.dist-info → starplot-0.12.2.dist-info}/LICENSE +0 -0
- {starplot-0.12.0.dist-info → starplot-0.12.2.dist-info}/WHEEL +0 -0
starplot/__init__.py
CHANGED
starplot/base.py
CHANGED
|
@@ -10,6 +10,7 @@ from matplotlib import patches
|
|
|
10
10
|
from matplotlib import pyplot as plt, patheffects
|
|
11
11
|
from matplotlib.lines import Line2D
|
|
12
12
|
from pytz import timezone
|
|
13
|
+
from shapely import Polygon
|
|
13
14
|
|
|
14
15
|
from starplot import geod, models
|
|
15
16
|
from starplot.data import load, ecliptic
|
|
@@ -498,13 +499,28 @@ class BasePlot(ABC):
|
|
|
498
499
|
self.ax.add_patch(patch)
|
|
499
500
|
|
|
500
501
|
@use_style(PolygonStyle)
|
|
501
|
-
def polygon(
|
|
502
|
-
|
|
502
|
+
def polygon(
|
|
503
|
+
self,
|
|
504
|
+
style: PolygonStyle,
|
|
505
|
+
points: list = None,
|
|
506
|
+
geometry: Polygon = None,
|
|
507
|
+
):
|
|
508
|
+
"""
|
|
509
|
+
Plots a polygon.
|
|
510
|
+
|
|
511
|
+
Must pass in either `points` **or** `geometry` (but not both).
|
|
503
512
|
|
|
504
513
|
Args:
|
|
505
514
|
points: List of polygon points `[(ra, dec), ...]` - **must be in counterclockwise order**
|
|
515
|
+
geometry: A shapely Polygon. If this value is passed, then the `points` kwarg will be ignored.
|
|
506
516
|
style: Style of polygon
|
|
507
517
|
"""
|
|
518
|
+
if points is None and geometry is None:
|
|
519
|
+
raise ValueError("Must pass points or geometry when plotting polygons.")
|
|
520
|
+
|
|
521
|
+
if geometry is not None:
|
|
522
|
+
points = list(zip(*geometry.exterior.coords.xy))
|
|
523
|
+
|
|
508
524
|
_points = [(ra * 15, dec) for ra, dec in points]
|
|
509
525
|
self._polygon(_points, style)
|
|
510
526
|
|
starplot/map.py
CHANGED
|
@@ -451,17 +451,27 @@ class MapPlot(BasePlot, ExtentMaskMixin, StarPlotterMixin, DsoPlotterMixin):
|
|
|
451
451
|
"""
|
|
452
452
|
mw = self._read_geo_package(DataFiles.MILKY_WAY.value)
|
|
453
453
|
|
|
454
|
-
if
|
|
455
|
-
|
|
456
|
-
gs = mw.geometry.to_crs(self._plate_carree)
|
|
457
|
-
mw_union = gs.buffer(0.1).unary_union.buffer(-0.1)
|
|
458
|
-
points = list(zip(*mw_union.boundary.coords.xy))
|
|
454
|
+
if mw.empty:
|
|
455
|
+
return
|
|
459
456
|
|
|
457
|
+
def _prepare_polygon(p):
|
|
458
|
+
points = list(zip(*p.boundary.coords.xy))
|
|
460
459
|
# convert lon to RA and reverse so the coordinates are counterclockwise order
|
|
461
|
-
|
|
460
|
+
return [(lon_to_ra(lon) * 15, dec) for lon, dec in reversed(points)]
|
|
461
|
+
|
|
462
|
+
# create union of all Milky Way patches
|
|
463
|
+
gs = mw.geometry.to_crs(self._plate_carree)
|
|
464
|
+
mw_union = gs.buffer(0.1).unary_union.buffer(-0.1)
|
|
465
|
+
polygons = []
|
|
466
|
+
|
|
467
|
+
if mw_union.geom_type == "MultiPolygon":
|
|
468
|
+
polygons.extend([_prepare_polygon(polygon) for polygon in mw_union.geoms])
|
|
469
|
+
else:
|
|
470
|
+
polygons.append(_prepare_polygon(mw_union))
|
|
462
471
|
|
|
472
|
+
for polygon_points in polygons:
|
|
463
473
|
self._polygon(
|
|
464
|
-
|
|
474
|
+
polygon_points,
|
|
465
475
|
style=style,
|
|
466
476
|
)
|
|
467
477
|
|
starplot/styles/base.py
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import json
|
|
2
2
|
from enum import Enum
|
|
3
3
|
from pathlib import Path
|
|
4
|
-
from typing import Optional
|
|
4
|
+
from typing import Optional, Union
|
|
5
5
|
from functools import cache
|
|
6
6
|
|
|
7
7
|
import yaml
|
|
@@ -332,8 +332,8 @@ class LineStyle(BaseStyle):
|
|
|
332
332
|
color: ColorStr = ColorStr("#000")
|
|
333
333
|
"""Color of the line. Can be a hex, rgb, hsl, or word string."""
|
|
334
334
|
|
|
335
|
-
style: LineStyleEnum = LineStyleEnum.SOLID
|
|
336
|
-
"""Style of the line (e.g. solid, dashed, etc)."""
|
|
335
|
+
style: Union[LineStyleEnum, tuple] = LineStyleEnum.SOLID
|
|
336
|
+
"""Style of the line (e.g. solid, dashed, etc). Can be a predefined value in `LineStyleEnum` or a [Matplotlib linestyle tuple](https://matplotlib.org/stable/gallery/lines_bars_and_markers/linestyles.html)."""
|
|
337
337
|
|
|
338
338
|
dash_capstyle: DashCapStyleEnum = DashCapStyleEnum.PROJECTING
|
|
339
339
|
"""Style of dash endpoints"""
|
|
@@ -401,8 +401,8 @@ class PolygonStyle(BaseStyle):
|
|
|
401
401
|
fill_color: Optional[ColorStr] = None
|
|
402
402
|
"""Fill color of the polygon"""
|
|
403
403
|
|
|
404
|
-
line_style: LineStyleEnum = LineStyleEnum.SOLID
|
|
405
|
-
"""Edge line style"""
|
|
404
|
+
line_style: Union[LineStyleEnum, tuple] = LineStyleEnum.SOLID
|
|
405
|
+
"""Edge line style. Can be a predefined value in `LineStyleEnum` or a [Matplotlib linestyle tuple](https://matplotlib.org/stable/gallery/lines_bars_and_markers/linestyles.html)."""
|
|
406
406
|
|
|
407
407
|
alpha: float = 1.0
|
|
408
408
|
"""Alpha value (controls transparency)"""
|
|
@@ -419,6 +419,7 @@ class PolygonStyle(BaseStyle):
|
|
|
419
419
|
linestyle=self.line_style,
|
|
420
420
|
alpha=self.alpha,
|
|
421
421
|
zorder=self.zorder,
|
|
422
|
+
capstyle="round",
|
|
422
423
|
)
|
|
423
424
|
if self.color:
|
|
424
425
|
styles["color"] = self.color.as_hex()
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
starplot/__init__.py,sha256=
|
|
2
|
-
starplot/base.py,sha256=
|
|
1
|
+
starplot/__init__.py,sha256=2lnh-uGVPlF6yYtorZZRVz4sfHXRnDGyoISl3tbDdYs,435
|
|
2
|
+
starplot/base.py,sha256=QYjlLeiEZ5M3fq2NQiaQdkTjUVamzsc5_V2Ry-KWP2M,29309
|
|
3
3
|
starplot/callables.py,sha256=5GZZoOhYc3wAJTzPgXt_tHdjIr-fKdhCbWjm6FT7Er8,2927
|
|
4
4
|
starplot/geod.py,sha256=QJmF6dOa4dpLoLQ32QsiXaG4gBpTBuagzSFquM9OzsM,2665
|
|
5
|
-
starplot/map.py,sha256=
|
|
5
|
+
starplot/map.py,sha256=Xw6jVGGAULl1S6yI7SzGyhfUXE2oeVFJE90ehbyzIRA,31048
|
|
6
6
|
starplot/mixins.py,sha256=Gp6qzlz-QWHI5pxWLSbrmBF7LltY0isBZm-Z4saSZo0,3249
|
|
7
7
|
starplot/optic.py,sha256=8F7CTJcVXPYLeXlsBNSHtO_qIqm4uC4HBtbbqG1-0Ag,14197
|
|
8
8
|
starplot/optics.py,sha256=JfSzfrCx_g8r3upyukgJUtXekwyVkCJ3dZxdOclfzU4,8624
|
|
@@ -46,7 +46,7 @@ starplot/plotters/__init__.py,sha256=MvgqZDMPuR3NaHW9SoiAk47HyMSiFwjrv34RTa_j0rs
|
|
|
46
46
|
starplot/plotters/dsos.py,sha256=vyFx2eB1NhSZdkumSPy7VfgoFx79E1TCIUr1q3eiDpU,9066
|
|
47
47
|
starplot/plotters/stars.py,sha256=VF76I5zv8XpH97y3vbfinKMQQ8BDGqBsQpyPXfK5ho8,8455
|
|
48
48
|
starplot/styles/__init__.py,sha256=luEPtL8bIpcCCUlvBojmYn7XQtGYapId-8xuA2m783U,124
|
|
49
|
-
starplot/styles/base.py,sha256=
|
|
49
|
+
starplot/styles/base.py,sha256=S77625QNXNuTnvjvY6zI9_gzMc3tv-NUuTOjJDIePsc,30341
|
|
50
50
|
starplot/styles/extensions.py,sha256=4DsFMOHy3PHpam14o-S7f73jNTR7ARNFE21ZUo8_RGU,615
|
|
51
51
|
starplot/styles/helpers.py,sha256=AGgHWaHLzJZ6jicvwPzY-p5oSHE0H8gDk1raCmeRFtg,3032
|
|
52
52
|
starplot/styles/markers.py,sha256=iDuzpBnRhrhElBzv5M4AWxValDxpTFaIcldq46VB4_M,2135
|
|
@@ -61,7 +61,7 @@ starplot/styles/ext/grayscale_dark.yml,sha256=6tm79qOdYpNc38bToak9RX-NHabrcE5jFN
|
|
|
61
61
|
starplot/styles/ext/map.yml,sha256=HbP7po572UMdDmYFyA34Reac9s8V2nEoO9pi5DT9M1o,120
|
|
62
62
|
starplot/styles/ext/nord.yml,sha256=AXQ-YGbKGOaQgGO6qdnNKYa1ushn3IYofg04ztE4EHE,2615
|
|
63
63
|
starplot/styles/ext/optic.yml,sha256=fiTvTl8Ka07o5KqtIqqBGL65ADjnMe6oyxTBbfoHz40,236
|
|
64
|
-
starplot-0.12.
|
|
65
|
-
starplot-0.12.
|
|
66
|
-
starplot-0.12.
|
|
67
|
-
starplot-0.12.
|
|
64
|
+
starplot-0.12.2.dist-info/LICENSE,sha256=jcjClHF4BQwhz-kDgia-KphO9Zxu0rCa2BbiA7j1jeU,1070
|
|
65
|
+
starplot-0.12.2.dist-info/WHEEL,sha256=Sgu64hAMa6g5FdzHxXv9Xdse9yxpGGMeagVtPMWpJQY,99
|
|
66
|
+
starplot-0.12.2.dist-info/METADATA,sha256=zJeM49DBvS4zFSgmFvti0A9yW87RC4s6UuWZicUXGhs,4120
|
|
67
|
+
starplot-0.12.2.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|