Skip to content

Commit d6e4f33

Browse files
authored
STAR-70 / star catalog loading (#135)
* cache catalog * fix mensa * version
1 parent b7fcebf commit d6e4f33

File tree

5 files changed

+27
-9
lines changed

5 files changed

+27
-9
lines changed

docs/changelog.md

+3
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@
1010
- [**v0.15.1**] Fixes bug with build script that prevented starplot data from being included in the distribution
1111
- [**v0.15.2**] Fixes a few colors in the dark blue and blue gold style extensions
1212
- [**v0.15.3**] Locks version of a few dependencies (DuckDB and Ibis)
13+
- [**v0.15.4**]
14+
- Fixes constellation lines for Mensa
15+
- Optimizes star catalog loading
1316

1417
## v0.14.x
1518
[Documentation](https://archives.starplot.dev/0.14.0/)

src/starplot/__init__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
"""Star charts and maps of the sky"""
22

3-
__version__ = "0.15.3"
3+
__version__ = "0.15.4"
44

55
from .base import BasePlot # noqa: F401
66
from .map import MapPlot, Projection # noqa: F401

src/starplot/data/constellation_lines.py

+5-1
Original file line numberDiff line numberDiff line change
@@ -499,7 +499,11 @@
499499
[93194, 92420],
500500
[92420, 91971],
501501
],
502-
"men": [[29271, 23467]],
502+
"men": [
503+
[29271, 25918],
504+
[25918, 22871],
505+
[22871, 23467],
506+
],
503507
"mic": [[102831, 103738], [103738, 105140], [105140, 105382]],
504508
"mon": [
505509
[31978, 31216],

src/starplot/data/constellation_stars.py

+2
Original file line numberDiff line numberDiff line change
@@ -897,6 +897,7 @@
897897
22783,
898898
22797,
899899
22845,
900+
22871,
900901
22957,
901902
23015,
902903
23040,
@@ -921,6 +922,7 @@
921922
25428,
922923
25606,
923924
25859,
925+
25918,
924926
25930,
925927
25985,
926928
26069,

src/starplot/data/stars.py

+16-7
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
from functools import cache
2+
13
import ibis
24
from ibis import _
35

@@ -456,15 +458,15 @@ class StarCatalog:
456458
"""
457459

458460

459-
def load(extent=None, catalog: StarCatalog = StarCatalog.BIG_SKY_MAG11, filters=None):
460-
filters = filters or []
461+
@cache
462+
def read_catalog(catalog: StarCatalog = StarCatalog.BIG_SKY_MAG11, table_name="stars"):
461463
con = db.connect()
462464

463465
if catalog == StarCatalog.BIG_SKY_MAG11:
464-
stars = con.read_parquet(DataFiles.BIG_SKY_MAG11, "stars")
466+
stars = con.read_parquet(DataFiles.BIG_SKY_MAG11, table_name)
465467
elif catalog == StarCatalog.BIG_SKY:
466468
bigsky.download_if_not_exists()
467-
stars = con.read_parquet(DataFiles.BIG_SKY, "stars")
469+
stars = con.read_parquet(DataFiles.BIG_SKY, table_name)
468470
else:
469471
raise ValueError("Unrecognized star catalog.")
470472

@@ -481,9 +483,6 @@ def load(extent=None, catalog: StarCatalog = StarCatalog.BIG_SKY_MAG11, filters=
481483
rowid=ibis.row_number(),
482484
)
483485

484-
if extent:
485-
stars = stars.filter(stars.geometry.intersects(extent))
486-
487486
stars = stars.join(
488487
designations,
489488
[
@@ -493,6 +492,16 @@ def load(extent=None, catalog: StarCatalog = StarCatalog.BIG_SKY_MAG11, filters=
493492
how="left",
494493
)
495494

495+
return stars
496+
497+
498+
def load(extent=None, catalog: StarCatalog = StarCatalog.BIG_SKY_MAG11, filters=None):
499+
filters = filters or []
500+
stars = read_catalog(catalog)
501+
502+
if extent:
503+
stars = stars.filter(stars.geometry.intersects(extent))
504+
496505
if filters:
497506
return stars.filter(*filters)
498507

0 commit comments

Comments
 (0)