starplot 0.14.0__py2.py3-none-any.whl → 0.15.1__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 +3 -1
- starplot/base.py +149 -37
- starplot/cli.py +33 -0
- starplot/data/__init__.py +6 -24
- starplot/data/bigsky.py +58 -40
- starplot/data/constellation_lines.py +827 -0
- starplot/data/constellation_stars.py +1501 -0
- starplot/data/constellations.py +43 -32
- starplot/data/db.py +17 -0
- starplot/data/dsos.py +24 -141
- starplot/data/library/{stars.bigsky.mag11.parquet → bigsky.0.4.0.stars.mag11.parquet} +0 -0
- starplot/data/library/sky.db +0 -0
- starplot/data/stars.py +45 -24
- starplot/geod.py +0 -6
- starplot/geometry.py +105 -6
- starplot/horizon.py +118 -107
- starplot/map.py +45 -96
- starplot/mixins.py +75 -14
- starplot/models/__init__.py +1 -1
- starplot/models/base.py +10 -128
- starplot/models/constellation.py +55 -32
- starplot/models/dso.py +132 -67
- starplot/models/moon.py +57 -78
- starplot/models/planet.py +44 -69
- starplot/models/star.py +91 -60
- starplot/models/sun.py +32 -53
- starplot/optic.py +14 -17
- starplot/plotters/constellations.py +81 -78
- starplot/plotters/dsos.py +49 -68
- starplot/plotters/experimental.py +1 -1
- starplot/plotters/milkyway.py +18 -20
- starplot/plotters/stars.py +91 -116
- starplot/profile.py +16 -0
- starplot/settings.py +26 -0
- starplot/styles/__init__.py +2 -0
- starplot/styles/base.py +7 -17
- starplot/styles/ext/blue_gold.yml +135 -0
- starplot/styles/ext/blue_light.yml +5 -4
- starplot/styles/ext/blue_medium.yml +11 -7
- starplot/styles/extensions.py +1 -0
- starplot/warnings.py +5 -0
- {starplot-0.14.0.dist-info → starplot-0.15.1.dist-info}/METADATA +11 -11
- {starplot-0.14.0.dist-info → starplot-0.15.1.dist-info}/RECORD +46 -54
- starplot-0.15.1.dist-info/entry_points.txt +3 -0
- starplot/data/bayer.py +0 -3499
- starplot/data/flamsteed.py +0 -2682
- starplot/data/library/constellation_borders_inv.gpkg +0 -0
- starplot/data/library/constellation_lines_hips.json +0 -709
- starplot/data/library/constellation_lines_inv.gpkg +0 -0
- starplot/data/library/constellations.gpkg +0 -0
- starplot/data/library/constellations_hip.fab +0 -88
- starplot/data/library/milkyway.gpkg +0 -0
- starplot/data/library/milkyway_inv.gpkg +0 -0
- starplot/data/library/ongc.gpkg.zip +0 -0
- starplot/data/library/stars.hipparcos.parquet +0 -0
- starplot/data/messier.py +0 -111
- starplot/data/prep/__init__.py +0 -0
- starplot/data/prep/constellations.py +0 -108
- starplot/data/prep/dsos.py +0 -299
- starplot/data/prep/utils.py +0 -16
- starplot/models/geometry.py +0 -44
- {starplot-0.14.0.dist-info → starplot-0.15.1.dist-info}/LICENSE +0 -0
- {starplot-0.14.0.dist-info → starplot-0.15.1.dist-info}/WHEEL +0 -0
starplot/data/constellations.py
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
import
|
|
1
|
+
import ibis
|
|
2
|
+
from ibis import _
|
|
2
3
|
|
|
3
|
-
from
|
|
4
|
-
|
|
5
|
-
from starplot.data import DataFiles, load as _load
|
|
4
|
+
from starplot.data import db
|
|
6
5
|
|
|
7
6
|
|
|
8
7
|
"""
|
|
@@ -88,7 +87,8 @@ properties = {
|
|
|
88
87
|
"Scl": ("Sculptor", 0.33, -32.01),
|
|
89
88
|
"Sco": ("Scorpius", 16.9, -33.55),
|
|
90
89
|
"Sct": ("Scutum", 18.54, -12.35),
|
|
91
|
-
"
|
|
90
|
+
"Ser1": ("Serpens\nCaput", 16.45, 3.59),
|
|
91
|
+
"Ser2": ("Serpens\nCauda", 18.2, -7.29),
|
|
92
92
|
"Sex": ("Sextans", 10.55, -4.24),
|
|
93
93
|
"Sge": ("Sagitta", 19.74, 14.92),
|
|
94
94
|
"Sgr": ("Sagittarius", 18.81, -26.05),
|
|
@@ -578,22 +578,17 @@ CONSTELLATION_HIP_IDS = {
|
|
|
578
578
|
87261,
|
|
579
579
|
},
|
|
580
580
|
"sct": {90595, 91117, 91726, 92175},
|
|
581
|
-
"
|
|
582
|
-
79593,
|
|
581
|
+
"ser1": {
|
|
583
582
|
77450,
|
|
584
|
-
89962,
|
|
585
583
|
77516,
|
|
586
|
-
84012,
|
|
587
584
|
77070,
|
|
588
|
-
88048,
|
|
589
585
|
77233,
|
|
590
|
-
92946,
|
|
591
586
|
76852,
|
|
592
587
|
76276,
|
|
593
588
|
77622,
|
|
594
|
-
86263,
|
|
595
589
|
78072,
|
|
596
590
|
},
|
|
591
|
+
"ser2": {86263, 89962, 88048, 92946},
|
|
597
592
|
"sex": {51437, 49641, 51362, 48437},
|
|
598
593
|
"sge": {98337, 96837, 96757, 97365},
|
|
599
594
|
"sgr": {
|
|
@@ -674,25 +669,46 @@ CONSTELLATION_HIP_IDS = {
|
|
|
674
669
|
}
|
|
675
670
|
|
|
676
671
|
|
|
677
|
-
def
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
672
|
+
def load(extent=None, filters=None):
|
|
673
|
+
filters = filters or []
|
|
674
|
+
con = db.connect()
|
|
675
|
+
c = con.table("constellations")
|
|
676
|
+
c = c.mutate(
|
|
677
|
+
ra=_.center_ra,
|
|
678
|
+
dec=_.center_dec,
|
|
679
|
+
constellation_id=_.iau_id,
|
|
680
|
+
rowid=ibis.row_number(),
|
|
681
|
+
boundary=_.geometry,
|
|
682
|
+
)
|
|
683
|
+
|
|
684
|
+
if extent:
|
|
685
|
+
filters.append(_.geometry.intersects(extent))
|
|
686
|
+
|
|
687
|
+
if filters:
|
|
688
|
+
return c.filter(*filters)
|
|
681
689
|
|
|
690
|
+
return c
|
|
682
691
|
|
|
683
|
-
def load(**kwargs):
|
|
684
|
-
import geopandas as gpd
|
|
685
|
-
import numpy as np
|
|
686
|
-
from starplot.data import DataFiles
|
|
687
692
|
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
+
def load_borders(extent=None, filters=None):
|
|
694
|
+
filters = filters or []
|
|
695
|
+
con = db.connect()
|
|
696
|
+
c = con.table("constellation_borders")
|
|
697
|
+
c = c.mutate(
|
|
698
|
+
# ra=_.center_ra,
|
|
699
|
+
# dec=_.center_dec,
|
|
700
|
+
# constellation_id=_.iau_id,
|
|
701
|
+
rowid=ibis.row_number(),
|
|
702
|
+
# boundary=_.geometry,
|
|
693
703
|
)
|
|
694
|
-
|
|
695
|
-
|
|
704
|
+
|
|
705
|
+
if extent:
|
|
706
|
+
filters.append(_.geometry.intersects(extent))
|
|
707
|
+
|
|
708
|
+
if filters:
|
|
709
|
+
return c.filter(*filters)
|
|
710
|
+
|
|
711
|
+
return c
|
|
696
712
|
|
|
697
713
|
|
|
698
714
|
def get(constellation_id: str):
|
|
@@ -702,8 +718,3 @@ def get(constellation_id: str):
|
|
|
702
718
|
def iterator():
|
|
703
719
|
for c in CONSTELLATIONS.keys():
|
|
704
720
|
yield c
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
def lines():
|
|
708
|
-
with open(DataFiles.CONSTELLATION_LINES_HIP, "r") as conlines:
|
|
709
|
-
return json.loads(conlines.read())
|
starplot/data/db.py
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
from functools import cache
|
|
2
|
+
|
|
3
|
+
import ibis
|
|
4
|
+
|
|
5
|
+
from starplot import settings
|
|
6
|
+
from starplot.data import DataFiles
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
@cache
|
|
10
|
+
def connect():
|
|
11
|
+
connection = ibis.duckdb.connect(
|
|
12
|
+
DataFiles.DATABASE, read_only=True
|
|
13
|
+
) # , threads=2, memory_limit="1GB"
|
|
14
|
+
connection.raw_sql(
|
|
15
|
+
f"SET extension_directory = '{str(settings.DUCKDB_EXTENSION_PATH)}';"
|
|
16
|
+
)
|
|
17
|
+
return connection
|
starplot/data/dsos.py
CHANGED
|
@@ -1,131 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
ZENITH_BASE = [
|
|
5
|
-
"M5",
|
|
6
|
-
"M13",
|
|
7
|
-
"M23",
|
|
8
|
-
"M31",
|
|
9
|
-
"M42",
|
|
10
|
-
"M44",
|
|
11
|
-
"M45",
|
|
12
|
-
"M47",
|
|
13
|
-
"M51",
|
|
14
|
-
"M55",
|
|
15
|
-
"M83",
|
|
16
|
-
"M93",
|
|
17
|
-
"M104",
|
|
18
|
-
]
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
class DsoType(str, Enum):
|
|
22
|
-
"""
|
|
23
|
-
Types of deep sky objects (DSOs), as designated in OpenNGC
|
|
24
|
-
"""
|
|
1
|
+
import ibis
|
|
2
|
+
from ibis import _
|
|
25
3
|
|
|
26
|
-
|
|
27
|
-
DOUBLE_STAR = "Double star"
|
|
28
|
-
ASSOCIATION_OF_STARS = "Association of stars"
|
|
29
|
-
|
|
30
|
-
OPEN_CLUSTER = "Open Cluster"
|
|
31
|
-
GLOBULAR_CLUSTER = "Globular Cluster"
|
|
32
|
-
|
|
33
|
-
GALAXY = "Galaxy"
|
|
34
|
-
GALAXY_PAIR = "Galaxy Pair"
|
|
35
|
-
GALAXY_TRIPLET = "Galaxy Triplet"
|
|
36
|
-
GROUP_OF_GALAXIES = "Group of galaxies"
|
|
37
|
-
|
|
38
|
-
NEBULA = "Nebula"
|
|
39
|
-
PLANETARY_NEBULA = "Planetary Nebula"
|
|
40
|
-
EMISSION_NEBULA = "Emission Nebula"
|
|
41
|
-
STAR_CLUSTER_NEBULA = "Star cluster + Nebula"
|
|
42
|
-
REFLECTION_NEBULA = "Reflection Nebula"
|
|
43
|
-
|
|
44
|
-
DARK_NEBULA = "Dark Nebula"
|
|
45
|
-
HII_IONIZED_REGION = "HII Ionized region"
|
|
46
|
-
SUPERNOVA_REMNANT = "Supernova remnant"
|
|
47
|
-
NOVA_STAR = "Nova star"
|
|
48
|
-
NONEXISTENT = "Nonexistent object"
|
|
49
|
-
UNKNOWN = "Object of other/unknown type"
|
|
50
|
-
DUPLICATE_RECORD = "Duplicated record"
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
ONGC_TYPE = {
|
|
54
|
-
# Star Clusters ----------
|
|
55
|
-
DsoType.OPEN_CLUSTER: "OCl",
|
|
56
|
-
DsoType.GLOBULAR_CLUSTER: "GCl",
|
|
57
|
-
# Galaxies ----------
|
|
58
|
-
DsoType.GALAXY: "G",
|
|
59
|
-
DsoType.GALAXY_PAIR: "GPair",
|
|
60
|
-
DsoType.GALAXY_TRIPLET: "GTrpl",
|
|
61
|
-
DsoType.GROUP_OF_GALAXIES: "GGroup",
|
|
62
|
-
# Nebulas ----------
|
|
63
|
-
DsoType.NEBULA: "Neb",
|
|
64
|
-
DsoType.PLANETARY_NEBULA: "PN",
|
|
65
|
-
DsoType.EMISSION_NEBULA: "EmN",
|
|
66
|
-
DsoType.STAR_CLUSTER_NEBULA: "Cl+N",
|
|
67
|
-
DsoType.REFLECTION_NEBULA: "RfN",
|
|
68
|
-
# Stars ----------
|
|
69
|
-
DsoType.STAR: "*",
|
|
70
|
-
DsoType.DOUBLE_STAR: "**",
|
|
71
|
-
DsoType.ASSOCIATION_OF_STARS: "*Ass",
|
|
72
|
-
# Others
|
|
73
|
-
DsoType.HII_IONIZED_REGION: "HII",
|
|
74
|
-
DsoType.DARK_NEBULA: "DrkN",
|
|
75
|
-
DsoType.SUPERNOVA_REMNANT: "SNR",
|
|
76
|
-
DsoType.NOVA_STAR: "Nova",
|
|
77
|
-
DsoType.NONEXISTENT: "NonEx",
|
|
78
|
-
DsoType.UNKNOWN: "Other",
|
|
79
|
-
DsoType.DUPLICATE_RECORD: "Dup",
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
ONGC_TYPE_MAP = {v: k.value for k, v in ONGC_TYPE.items()}
|
|
83
|
-
|
|
84
|
-
BASIC_DSO_TYPES = [
|
|
85
|
-
# Star Clusters ----------
|
|
86
|
-
DsoType.OPEN_CLUSTER,
|
|
87
|
-
DsoType.GLOBULAR_CLUSTER,
|
|
88
|
-
# Galaxies ----------
|
|
89
|
-
DsoType.GALAXY,
|
|
90
|
-
DsoType.GALAXY_PAIR,
|
|
91
|
-
DsoType.GALAXY_TRIPLET,
|
|
92
|
-
DsoType.GROUP_OF_GALAXIES,
|
|
93
|
-
# Nebulas ----------
|
|
94
|
-
DsoType.NEBULA,
|
|
95
|
-
DsoType.PLANETARY_NEBULA,
|
|
96
|
-
DsoType.EMISSION_NEBULA,
|
|
97
|
-
DsoType.STAR_CLUSTER_NEBULA,
|
|
98
|
-
DsoType.REFLECTION_NEBULA,
|
|
99
|
-
# Stars ----------
|
|
100
|
-
# DsoType.DOUBLE_STAR,
|
|
101
|
-
DsoType.ASSOCIATION_OF_STARS,
|
|
102
|
-
]
|
|
103
|
-
"""Default types of Deep Sky Objects (DSOs) that are plotted when you call `dsos()` on a plot"""
|
|
104
|
-
|
|
105
|
-
DSO_LEGEND_LABELS = {
|
|
106
|
-
# Galaxies ----------
|
|
107
|
-
DsoType.GALAXY: "Galaxy",
|
|
108
|
-
DsoType.GALAXY_PAIR: "Galaxy",
|
|
109
|
-
DsoType.GALAXY_TRIPLET: "Galaxy",
|
|
110
|
-
DsoType.GROUP_OF_GALAXIES: "Galaxy",
|
|
111
|
-
# Nebulas ----------
|
|
112
|
-
DsoType.NEBULA: "Nebula",
|
|
113
|
-
DsoType.PLANETARY_NEBULA: "Nebula",
|
|
114
|
-
DsoType.EMISSION_NEBULA: "Nebula",
|
|
115
|
-
DsoType.STAR_CLUSTER_NEBULA: "Nebula",
|
|
116
|
-
DsoType.REFLECTION_NEBULA: "Nebula",
|
|
117
|
-
# Star Clusters ----------
|
|
118
|
-
DsoType.OPEN_CLUSTER: "Open Cluster",
|
|
119
|
-
DsoType.GLOBULAR_CLUSTER: "Globular Cluster",
|
|
120
|
-
# Stars ----------
|
|
121
|
-
DsoType.DOUBLE_STAR: "Double Star",
|
|
122
|
-
DsoType.ASSOCIATION_OF_STARS: "Association of stars",
|
|
123
|
-
DsoType.NOVA_STAR: "Nova Star",
|
|
124
|
-
# Others
|
|
125
|
-
DsoType.HII_IONIZED_REGION: "HII Ionized Region",
|
|
126
|
-
DsoType.DARK_NEBULA: "Dark Nebula",
|
|
127
|
-
DsoType.SUPERNOVA_REMNANT: "Supernova Remnant",
|
|
128
|
-
}
|
|
4
|
+
from starplot.data import db
|
|
129
5
|
|
|
130
6
|
|
|
131
7
|
class DsoLabelMaker(dict):
|
|
@@ -149,19 +25,26 @@ class DsoLabelMaker(dict):
|
|
|
149
25
|
DSO_LABELS_DEFAULT = DsoLabelMaker()
|
|
150
26
|
|
|
151
27
|
|
|
152
|
-
def
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
28
|
+
def load(extent=None, filters=None):
|
|
29
|
+
filters = filters or []
|
|
30
|
+
con = db.connect()
|
|
31
|
+
dsos = con.table("deep_sky_objects")
|
|
156
32
|
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
33
|
+
dsos = dsos.mutate(
|
|
34
|
+
ra=_.ra_degrees,
|
|
35
|
+
dec=_.dec_degrees,
|
|
36
|
+
constellation_id=_.constellation,
|
|
37
|
+
magnitude=ibis.coalesce(_.mag_v, _.mag_b, None),
|
|
38
|
+
size=_.size_deg2,
|
|
39
|
+
rowid=ibis.row_number(),
|
|
162
40
|
)
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
41
|
+
|
|
42
|
+
if extent:
|
|
43
|
+
dsos = dsos.filter(_.geometry.intersects(extent))
|
|
44
|
+
|
|
45
|
+
filters.extend([_.ra_degrees.notnull() & _.dec_degrees.notnull()])
|
|
46
|
+
|
|
47
|
+
if filters:
|
|
48
|
+
return dsos.filter(*filters)
|
|
49
|
+
|
|
50
|
+
return dsos
|
|
Binary file
|
|
Binary file
|
starplot/data/stars.py
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
|
|
1
|
+
import ibis
|
|
2
|
+
from ibis import _
|
|
2
3
|
|
|
3
|
-
from
|
|
4
|
-
|
|
5
|
-
from starplot.data import bigsky, DataFiles
|
|
4
|
+
from starplot.data import bigsky, DataFiles, db
|
|
6
5
|
|
|
7
6
|
STAR_NAMES = {
|
|
8
7
|
677: "Alpheratz",
|
|
@@ -432,17 +431,14 @@ STAR_NAMES = {
|
|
|
432
431
|
"""Star names by their HIP id. You can override these values when calling `stars()`"""
|
|
433
432
|
|
|
434
433
|
|
|
435
|
-
class StarCatalog
|
|
434
|
+
class StarCatalog:
|
|
436
435
|
"""Built-in star catalogs"""
|
|
437
436
|
|
|
438
|
-
HIPPARCOS = "hipparcos"
|
|
439
|
-
"""Hipparcos Catalog = 118,218 stars"""
|
|
440
|
-
|
|
441
437
|
BIG_SKY_MAG11 = "big-sky-mag11"
|
|
442
438
|
"""
|
|
443
|
-
[Big Sky Catalog](https://github.com/steveberardi/bigsky) ~
|
|
439
|
+
[Big Sky Catalog](https://github.com/steveberardi/bigsky) ~ 370k stars up to magnitude 10
|
|
444
440
|
|
|
445
|
-
This is an _abridged_ version of the Big Sky Catalog, including stars up to a limiting magnitude of
|
|
441
|
+
This is an _abridged_ version of the Big Sky Catalog, including stars up to a limiting magnitude of 10 (total = 368,330 981,852).
|
|
446
442
|
|
|
447
443
|
This catalog is included with Starplot, so does not require downloading any files.
|
|
448
444
|
"""
|
|
@@ -451,28 +447,53 @@ class StarCatalog(str, Enum):
|
|
|
451
447
|
"""
|
|
452
448
|
[Big Sky Catalog](https://github.com/steveberardi/bigsky) ~ 2.5M stars
|
|
453
449
|
|
|
454
|
-
This is the full version of the Big Sky Catalog, which includes 2,557,
|
|
450
|
+
This is the full version of the Big Sky Catalog, which includes 2,557,500 stars from Hipparcos, Tycho-1, and Tycho-2.
|
|
455
451
|
|
|
456
|
-
This catalog is very large (
|
|
452
|
+
This catalog is very large (approx 100 MB), so it's not built-in to Starplot. When you plot stars and specify this catalog, the catalog
|
|
457
453
|
will be downloaded from the [Big Sky GitHub repository](https://github.com/steveberardi/bigsky) and saved to Starplot's data library
|
|
458
454
|
directory. You can override this download path with the environment variable `STARPLOT_DOWNLOAD_PATH`
|
|
459
455
|
|
|
460
456
|
"""
|
|
461
457
|
|
|
462
458
|
|
|
463
|
-
def
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
return bigsky.load(DataFiles.BIG_SKY)
|
|
459
|
+
def load(extent=None, catalog: StarCatalog = StarCatalog.BIG_SKY_MAG11, filters=None):
|
|
460
|
+
filters = filters or []
|
|
461
|
+
con = db.connect()
|
|
468
462
|
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
if catalog == StarCatalog.HIPPARCOS:
|
|
472
|
-
return read_parquet(DataFiles.HIPPARCOS)
|
|
473
|
-
elif catalog == StarCatalog.BIG_SKY_MAG11:
|
|
474
|
-
return bigsky.load(DataFiles.BIG_SKY_MAG11)
|
|
463
|
+
if catalog == StarCatalog.BIG_SKY_MAG11:
|
|
464
|
+
stars = con.read_parquet(DataFiles.BIG_SKY_MAG11, "stars")
|
|
475
465
|
elif catalog == StarCatalog.BIG_SKY:
|
|
476
|
-
|
|
466
|
+
bigsky.download_if_not_exists()
|
|
467
|
+
stars = con.read_parquet(DataFiles.BIG_SKY, "stars")
|
|
477
468
|
else:
|
|
478
469
|
raise ValueError("Unrecognized star catalog.")
|
|
470
|
+
|
|
471
|
+
designations = con.table("star_designations")
|
|
472
|
+
|
|
473
|
+
stars = stars.mutate(
|
|
474
|
+
epoch_year=2000,
|
|
475
|
+
ra=_.ra_degrees,
|
|
476
|
+
dec=_.dec_degrees,
|
|
477
|
+
constellation_id=_.constellation,
|
|
478
|
+
ra_hours=_.ra_degrees / 15,
|
|
479
|
+
# stars parquet does not have geometry field
|
|
480
|
+
geometry=_.ra_degrees.point(_.dec_degrees),
|
|
481
|
+
rowid=ibis.row_number(),
|
|
482
|
+
)
|
|
483
|
+
|
|
484
|
+
if extent:
|
|
485
|
+
stars = stars.filter(stars.geometry.intersects(extent))
|
|
486
|
+
|
|
487
|
+
stars = stars.join(
|
|
488
|
+
designations,
|
|
489
|
+
[
|
|
490
|
+
stars.hip == designations.hip,
|
|
491
|
+
(stars.ccdm == "A") | (stars.ccdm == "") | (stars.ccdm.isnull()),
|
|
492
|
+
],
|
|
493
|
+
how="left",
|
|
494
|
+
)
|
|
495
|
+
|
|
496
|
+
if filters:
|
|
497
|
+
return stars.filter(*filters)
|
|
498
|
+
|
|
499
|
+
return stars
|
starplot/geod.py
CHANGED
|
@@ -11,10 +11,6 @@ def distance_m(distance_degrees: float, lat: float = 0, lon: float = 0):
|
|
|
11
11
|
return distance
|
|
12
12
|
|
|
13
13
|
|
|
14
|
-
def to_radec(p) -> tuple:
|
|
15
|
-
return (p[0] / 15, p[1])
|
|
16
|
-
|
|
17
|
-
|
|
18
14
|
def away_from_poles(dec):
|
|
19
15
|
# for some reason cartopy does not like plotting things EXACTLY at the poles
|
|
20
16
|
# so, this is a little hack to avoid the bug (or maybe a misconception?) by
|
|
@@ -34,7 +30,6 @@ def rectangle(
|
|
|
34
30
|
angle: float = 0,
|
|
35
31
|
) -> list:
|
|
36
32
|
ra, dec = center
|
|
37
|
-
ra = ra * 15
|
|
38
33
|
dec = away_from_poles(dec)
|
|
39
34
|
angle = 180 - angle
|
|
40
35
|
|
|
@@ -70,7 +65,6 @@ def ellipse(
|
|
|
70
65
|
end_angle: int = 360,
|
|
71
66
|
) -> list:
|
|
72
67
|
ra, dec = center
|
|
73
|
-
ra = ra * 15
|
|
74
68
|
dec = away_from_poles(dec)
|
|
75
69
|
angle = 180 - angle
|
|
76
70
|
|
starplot/geometry.py
CHANGED
|
@@ -1,7 +1,45 @@
|
|
|
1
1
|
import random
|
|
2
2
|
import math
|
|
3
|
+
from typing import Union
|
|
3
4
|
|
|
4
|
-
from shapely
|
|
5
|
+
from shapely import transform
|
|
6
|
+
from shapely.geometry import Point, Polygon, MultiPolygon
|
|
7
|
+
|
|
8
|
+
from starplot import geod, utils
|
|
9
|
+
|
|
10
|
+
GLOBAL_EXTENT = Polygon(
|
|
11
|
+
[
|
|
12
|
+
[0, -90],
|
|
13
|
+
[360, -90],
|
|
14
|
+
[360, 90],
|
|
15
|
+
[0, 90],
|
|
16
|
+
[0, -90],
|
|
17
|
+
]
|
|
18
|
+
)
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
def circle(center, diameter_degrees):
|
|
22
|
+
points = geod.ellipse(
|
|
23
|
+
center,
|
|
24
|
+
diameter_degrees,
|
|
25
|
+
diameter_degrees,
|
|
26
|
+
angle=0,
|
|
27
|
+
num_pts=100,
|
|
28
|
+
)
|
|
29
|
+
points = [
|
|
30
|
+
(round(24 - utils.lon_to_ra(lon), 4), round(dec, 4)) for lon, dec in points
|
|
31
|
+
]
|
|
32
|
+
return Polygon(points)
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
def to_24h(geometry: Union[Point, Polygon, MultiPolygon]):
|
|
36
|
+
geometry_type = str(geometry.geom_type)
|
|
37
|
+
|
|
38
|
+
if geometry_type == "MultiPolygon":
|
|
39
|
+
polygons = [transform(p, lambda c: c * [1 / 15, 1]) for p in geometry.geoms]
|
|
40
|
+
return MultiPolygon(polygons)
|
|
41
|
+
|
|
42
|
+
return transform(geometry, lambda c: c * [1 / 15, 1])
|
|
5
43
|
|
|
6
44
|
|
|
7
45
|
def unwrap_polygon(polygon: Polygon) -> Polygon:
|
|
@@ -20,6 +58,43 @@ def unwrap_polygon(polygon: Polygon) -> Polygon:
|
|
|
20
58
|
return Polygon(new_points)
|
|
21
59
|
|
|
22
60
|
|
|
61
|
+
def unwrap_polygon_360_old(polygon: Polygon) -> Polygon:
|
|
62
|
+
points = list(zip(*polygon.exterior.coords.xy))
|
|
63
|
+
new_points = []
|
|
64
|
+
prev = None
|
|
65
|
+
|
|
66
|
+
for x, y in points:
|
|
67
|
+
if prev is not None and prev > 300 and x < 180:
|
|
68
|
+
x -= 360
|
|
69
|
+
elif prev is not None and prev < 180 and x > 300:
|
|
70
|
+
x += 360
|
|
71
|
+
new_points.append((x, y))
|
|
72
|
+
prev = x
|
|
73
|
+
|
|
74
|
+
return Polygon(new_points)
|
|
75
|
+
|
|
76
|
+
|
|
77
|
+
def unwrap_polygon_360_inverse(polygon: Polygon) -> Polygon:
|
|
78
|
+
ra, dec = [p for p in polygon.exterior.coords.xy]
|
|
79
|
+
|
|
80
|
+
if min(ra) < 180 and max(ra) > 300:
|
|
81
|
+
new_ra = [r + 360 if r < 50 else r for r in ra]
|
|
82
|
+
points = list(zip(new_ra, dec))
|
|
83
|
+
return Polygon(points)
|
|
84
|
+
|
|
85
|
+
return polygon
|
|
86
|
+
|
|
87
|
+
|
|
88
|
+
def unwrap_polygon_360(polygon: Polygon) -> Polygon:
|
|
89
|
+
ra, dec = [p for p in polygon.exterior.coords.xy]
|
|
90
|
+
|
|
91
|
+
if min(ra) < 180 and max(ra) > 300:
|
|
92
|
+
new_ra = [r - 360 if r > 300 else r for r in ra]
|
|
93
|
+
return Polygon(list(zip(new_ra, dec)))
|
|
94
|
+
|
|
95
|
+
return polygon
|
|
96
|
+
|
|
97
|
+
|
|
23
98
|
def random_point_in_polygon(
|
|
24
99
|
polygon: Polygon, max_iterations: int = 100, seed: int = None
|
|
25
100
|
) -> Point:
|
|
@@ -65,7 +140,7 @@ def random_point_in_polygon_at_distance(
|
|
|
65
140
|
return None
|
|
66
141
|
|
|
67
142
|
|
|
68
|
-
def
|
|
143
|
+
def wrapped_polygon_adjustment_old(polygon: Polygon) -> int:
|
|
69
144
|
if "MultiPolygon" == str(polygon.geom_type):
|
|
70
145
|
return 0
|
|
71
146
|
|
|
@@ -73,10 +148,34 @@ def wrapped_polygon_adjustment(polygon: Polygon) -> int:
|
|
|
73
148
|
prev = None
|
|
74
149
|
|
|
75
150
|
for ra, _ in points:
|
|
76
|
-
if prev is not None and prev >
|
|
77
|
-
return
|
|
78
|
-
elif prev is not None and prev <
|
|
79
|
-
return -
|
|
151
|
+
if prev is not None and prev > 300 and ra < 180:
|
|
152
|
+
return 360
|
|
153
|
+
elif prev is not None and prev < 180 and ra > 300:
|
|
154
|
+
return -360
|
|
80
155
|
prev = ra
|
|
81
156
|
|
|
82
157
|
return 0
|
|
158
|
+
|
|
159
|
+
|
|
160
|
+
def wrapped_polygon_adjustment(polygon: Polygon) -> int:
|
|
161
|
+
if "MultiPolygon" == str(polygon.geom_type):
|
|
162
|
+
return 0
|
|
163
|
+
|
|
164
|
+
ra, _ = [p for p in polygon.exterior.coords.xy]
|
|
165
|
+
|
|
166
|
+
if min(ra) < 180 and max(ra) > 300:
|
|
167
|
+
return 360
|
|
168
|
+
|
|
169
|
+
return 0
|
|
170
|
+
|
|
171
|
+
|
|
172
|
+
def is_wrapped_polygon(polygon: Polygon) -> bool:
|
|
173
|
+
if "MultiPolygon" == str(polygon.geom_type):
|
|
174
|
+
return False
|
|
175
|
+
|
|
176
|
+
ra, _ = [p for p in polygon.exterior.coords.xy]
|
|
177
|
+
|
|
178
|
+
if min(ra) < 180 and max(ra) > 300:
|
|
179
|
+
return True
|
|
180
|
+
|
|
181
|
+
return False
|