lsdb-gaia 0.0.4__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.
- lsdb_gaia/__init__.py +5 -0
- lsdb_gaia/_version.py +24 -0
- lsdb_gaia/dr4/__init__.py +7 -0
- lsdb_gaia/dr4/catalog.py +72 -0
- lsdb_gaia/dr4/gaia_source_hats/dataset/_common_metadata +0 -0
- lsdb_gaia/dr4/gaia_source_hats/hats.properties +8 -0
- lsdb_gaia/dr4/gaia_source_hats/partition_info.csv +1789 -0
- lsdb_gaia/dr4/join.py +50 -0
- lsdb_gaia/dr4/metadata.py +105 -0
- lsdb_gaia/dr4/regions.py +33 -0
- lsdb_gaia/dr4/storage.py +13 -0
- lsdb_gaia/dr4/tables.py +147 -0
- lsdb_gaia-0.0.4.dist-info/METADATA +79 -0
- lsdb_gaia-0.0.4.dist-info/RECORD +17 -0
- lsdb_gaia-0.0.4.dist-info/WHEEL +5 -0
- lsdb_gaia-0.0.4.dist-info/licenses/LICENSE +21 -0
- lsdb_gaia-0.0.4.dist-info/top_level.txt +1 -0
lsdb_gaia/__init__.py
ADDED
lsdb_gaia/_version.py
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
# file generated by vcs-versioning
|
|
2
|
+
# don't change, don't track in version control
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
__all__ = [
|
|
6
|
+
"__version__",
|
|
7
|
+
"__version_tuple__",
|
|
8
|
+
"version",
|
|
9
|
+
"version_tuple",
|
|
10
|
+
"__commit_id__",
|
|
11
|
+
"commit_id",
|
|
12
|
+
]
|
|
13
|
+
|
|
14
|
+
version: str
|
|
15
|
+
__version__: str
|
|
16
|
+
__version_tuple__: tuple[int | str, ...]
|
|
17
|
+
version_tuple: tuple[int | str, ...]
|
|
18
|
+
commit_id: str | None
|
|
19
|
+
__commit_id__: str | None
|
|
20
|
+
|
|
21
|
+
__version__ = version = '0.0.4'
|
|
22
|
+
__version_tuple__ = version_tuple = (0, 0, 4)
|
|
23
|
+
|
|
24
|
+
__commit_id__ = commit_id = None
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
"""Gaia DR4 bulk-download tables with LSDB."""
|
|
2
|
+
|
|
3
|
+
from lsdb_gaia.dr4.catalog import open_gaia_dr4
|
|
4
|
+
from lsdb_gaia.dr4.storage import ESA_DR4_S3_ENDPOINT, GAIA_DR4
|
|
5
|
+
from lsdb_gaia.dr4.tables import NESTED_TABLES, TABLE_PATHS
|
|
6
|
+
|
|
7
|
+
__all__ = ["ESA_DR4_S3_ENDPOINT", "GAIA_DR4", "NESTED_TABLES", "TABLE_PATHS", "open_gaia_dr4"]
|
lsdb_gaia/dr4/catalog.py
ADDED
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
"""Open Gaia DR4 tables as a single LSDB catalog."""
|
|
2
|
+
|
|
3
|
+
import lsdb
|
|
4
|
+
|
|
5
|
+
from lsdb_gaia.dr4.join import empty_frame, join, join_partition
|
|
6
|
+
from lsdb_gaia.dr4.metadata import files_by_region, gaia_source_hats_dir
|
|
7
|
+
from lsdb_gaia.dr4.regions import healpix_to_region_id
|
|
8
|
+
from lsdb_gaia.dr4.tables import GAIA_SOURCE, check_table, table_dir
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
def _gaia_source_path(catalog_base_dir, pixel, query_params=None, npix_suffix="/"):
|
|
12
|
+
region_id = healpix_to_region_id(pixel)
|
|
13
|
+
return table_dir(GAIA_SOURCE) / "data" / f"region={region_id}" / "sector_001"
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
def _with_source_id(columns):
|
|
17
|
+
return ["source_id", *(c for c in columns if c != "source_id")]
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
def open_gaia_dr4(tables, search_filter=None):
|
|
21
|
+
"""Open Gaia DR4 tables as one LSDB catalog, joined on ``source_id``.
|
|
22
|
+
|
|
23
|
+
Data are read lazily from the ESA Gaia DR4 bulk-download bucket. gaia_source
|
|
24
|
+
provides positions and partitioning; every other table is inner-joined to it,
|
|
25
|
+
so only sources present in all requested tables are kept. Tables with one row
|
|
26
|
+
per source become flat columns (clashing names get a ``_<table>`` suffix);
|
|
27
|
+
tables in `NESTED_TABLES` become a nested column named after the table.
|
|
28
|
+
|
|
29
|
+
Parameters
|
|
30
|
+
----------
|
|
31
|
+
tables : dict of str to list of str
|
|
32
|
+
Gaia archive table names mapped to the columns to load, e.g.
|
|
33
|
+
``{"gaia_source": ["phot_g_mean_mag"], "rvs_epoch_parameters_single": ["radial_velocity"]}``.
|
|
34
|
+
Supported tables are the keys of `TABLE_PATHS`. ``source_id`` is always
|
|
35
|
+
loaded; gaia_source ``ra``, ``dec`` and ``healpix29`` are always loaded too.
|
|
36
|
+
search_filter : lsdb.core.search.AbstractSearch, optional
|
|
37
|
+
Spatial filter applied to gaia_source, e.g. ``lsdb.ConeSearch``.
|
|
38
|
+
By default the whole sky is used.
|
|
39
|
+
|
|
40
|
+
Returns
|
|
41
|
+
-------
|
|
42
|
+
lsdb.Catalog
|
|
43
|
+
Lazy catalog with one row per source, indexed by gaia_source ``healpix29``.
|
|
44
|
+
|
|
45
|
+
Notes
|
|
46
|
+
-----
|
|
47
|
+
DR4 files are partitioned by ``source_id``, while ``healpix29`` is computed from
|
|
48
|
+
the coordinates. For a small fraction of sources (~0.002% in tested regions) the
|
|
49
|
+
two disagree, so such a source sits in a partition whose pixel does not contain
|
|
50
|
+
its position. A spatial filter can miss these sources when it covers their
|
|
51
|
+
position but not the partition they are stored in.
|
|
52
|
+
"""
|
|
53
|
+
tables = dict(tables)
|
|
54
|
+
for table in tables:
|
|
55
|
+
check_table(table)
|
|
56
|
+
gaia_source = lsdb.open_catalog(
|
|
57
|
+
gaia_source_hats_dir(),
|
|
58
|
+
search_filter=search_filter,
|
|
59
|
+
columns=_with_source_id(tables.pop(GAIA_SOURCE, [])),
|
|
60
|
+
path_generator=_gaia_source_path,
|
|
61
|
+
)
|
|
62
|
+
if not tables:
|
|
63
|
+
return gaia_source
|
|
64
|
+
|
|
65
|
+
joined_tables = {}
|
|
66
|
+
meta = gaia_source.meta
|
|
67
|
+
for table, columns in tables.items():
|
|
68
|
+
columns = _with_source_id(columns)
|
|
69
|
+
empty_df = empty_frame(table, columns)
|
|
70
|
+
joined_tables[table] = (files_by_region(table), columns, empty_df)
|
|
71
|
+
meta = join(meta, table, empty_df)
|
|
72
|
+
return gaia_source.map_partitions(join_partition, tables=joined_tables, include_pixel=True, meta=meta)
|
|
Binary file
|