Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

STAR-70 / star catalog loading #135

Merged
merged 3 commits into from
Feb 9, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions docs/changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@
- [**v0.15.1**] Fixes bug with build script that prevented starplot data from being included in the distribution
- [**v0.15.2**] Fixes a few colors in the dark blue and blue gold style extensions
- [**v0.15.3**] Locks version of a few dependencies (DuckDB and Ibis)
- [**v0.15.4**]
- Fixes constellation lines for Mensa
- Optimizes star catalog loading

## v0.14.x
[Documentation](https://archives.starplot.dev/0.14.0/)
Expand Down
2 changes: 1 addition & 1 deletion src/starplot/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"""Star charts and maps of the sky"""

__version__ = "0.15.3"
__version__ = "0.15.4"

from .base import BasePlot # noqa: F401
from .map import MapPlot, Projection # noqa: F401
Expand Down
6 changes: 5 additions & 1 deletion src/starplot/data/constellation_lines.py
Original file line number Diff line number Diff line change
Expand Up @@ -499,7 +499,11 @@
[93194, 92420],
[92420, 91971],
],
"men": [[29271, 23467]],
"men": [
[29271, 25918],
[25918, 22871],
[22871, 23467],
],
"mic": [[102831, 103738], [103738, 105140], [105140, 105382]],
"mon": [
[31978, 31216],
Expand Down
2 changes: 2 additions & 0 deletions src/starplot/data/constellation_stars.py
Original file line number Diff line number Diff line change
Expand Up @@ -897,6 +897,7 @@
22783,
22797,
22845,
22871,
22957,
23015,
23040,
Expand All @@ -921,6 +922,7 @@
25428,
25606,
25859,
25918,
25930,
25985,
26069,
Expand Down
23 changes: 16 additions & 7 deletions src/starplot/data/stars.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from functools import cache

import ibis
from ibis import _

Expand Down Expand Up @@ -456,15 +458,15 @@ class StarCatalog:
"""


def load(extent=None, catalog: StarCatalog = StarCatalog.BIG_SKY_MAG11, filters=None):
filters = filters or []
@cache
def read_catalog(catalog: StarCatalog = StarCatalog.BIG_SKY_MAG11, table_name="stars"):
con = db.connect()

if catalog == StarCatalog.BIG_SKY_MAG11:
stars = con.read_parquet(DataFiles.BIG_SKY_MAG11, "stars")
stars = con.read_parquet(DataFiles.BIG_SKY_MAG11, table_name)
elif catalog == StarCatalog.BIG_SKY:
bigsky.download_if_not_exists()
stars = con.read_parquet(DataFiles.BIG_SKY, "stars")
stars = con.read_parquet(DataFiles.BIG_SKY, table_name)
else:
raise ValueError("Unrecognized star catalog.")

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

if extent:
stars = stars.filter(stars.geometry.intersects(extent))

stars = stars.join(
designations,
[
Expand All @@ -493,6 +492,16 @@ def load(extent=None, catalog: StarCatalog = StarCatalog.BIG_SKY_MAG11, filters=
how="left",
)

return stars


def load(extent=None, catalog: StarCatalog = StarCatalog.BIG_SKY_MAG11, filters=None):
filters = filters or []
stars = read_catalog(catalog)

if extent:
stars = stars.filter(stars.geometry.intersects(extent))

if filters:
return stars.filter(*filters)

Expand Down