1
+ from functools import cache
2
+
1
3
import ibis
2
4
from ibis import _
3
5
@@ -456,15 +458,15 @@ class StarCatalog:
456
458
"""
457
459
458
460
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" ):
461
463
con = db .connect ()
462
464
463
465
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 )
465
467
elif catalog == StarCatalog .BIG_SKY :
466
468
bigsky .download_if_not_exists ()
467
- stars = con .read_parquet (DataFiles .BIG_SKY , "stars" )
469
+ stars = con .read_parquet (DataFiles .BIG_SKY , table_name )
468
470
else :
469
471
raise ValueError ("Unrecognized star catalog." )
470
472
@@ -481,9 +483,6 @@ def load(extent=None, catalog: StarCatalog = StarCatalog.BIG_SKY_MAG11, filters=
481
483
rowid = ibis .row_number (),
482
484
)
483
485
484
- if extent :
485
- stars = stars .filter (stars .geometry .intersects (extent ))
486
-
487
486
stars = stars .join (
488
487
designations ,
489
488
[
@@ -493,6 +492,16 @@ def load(extent=None, catalog: StarCatalog = StarCatalog.BIG_SKY_MAG11, filters=
493
492
how = "left" ,
494
493
)
495
494
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
+
496
505
if filters :
497
506
return stars .filter (* filters )
498
507
0 commit comments