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

tools.py: use CatalogToGaia_DR2 in query_gaia_dr2 #446

Merged
merged 1 commit into from
Jun 17, 2024
Merged
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
35 changes: 25 additions & 10 deletions python/target_selection/cartons/tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,16 +29,15 @@ def get_file_carton(filename):

# Import this here to prevent this module not being importable if the database
# connection is not ready.
from sdssdb.peewee.sdss5db.catalogdb import (Catalog, CatalogToGaia_DR3,
from sdssdb.peewee.sdss5db.catalogdb import (Catalog, CatalogToGaia_DR2,
CatalogToGaia_DR3,
CatalogToLegacy_Survey_DR8,
CatalogToLegacy_Survey_DR10,
CatalogToPanstarrs1,
CatalogToTIC_v8,
CatalogToTwoMassPSC, Gaia_DR2,
Gaia_DR3, Legacy_Survey_DR8,
Legacy_Survey_DR10,
Panstarrs1, TIC_v8,
TwoMassPSC)
Panstarrs1, TwoMassPSC)

class FileCarton(BaseCarton):

Expand Down Expand Up @@ -281,17 +280,33 @@ def build_query(self, version_id, query_region=None):

query_gaia_dr2 = \
(query_common
.join(CatalogToTIC_v8)
.join(TIC_v8, on=(CatalogToTIC_v8.target_id == TIC_v8.id))
.join(Gaia_DR2, on=(TIC_v8.gaia_int == Gaia_DR2.source_id))
.join(CatalogToGaia_DR2)
.join(Gaia_DR2, on=(CatalogToGaia_DR2.target_id == Gaia_DR2.source_id))
.join(temp,
on=(temp.Gaia_DR2_Source_ID == Gaia_DR2.source_id))
.switch(Catalog)
.where(CatalogToTIC_v8.version_id == version_id,
(CatalogToTIC_v8.best >> True) |
CatalogToTIC_v8.best.is_null(),
.where(CatalogToGaia_DR2.version_id == version_id,
(CatalogToGaia_DR2.best >> True) |
CatalogToGaia_DR2.best.is_null(),
Catalog.version_id == version_id))

# Above is the new way for making query_gaia_dr2 after v1.0 crossmatch.
# Below is the old way for making query_gaia_dr2 before v1.0 crossmatch.
# It is kept here for future reference.
#
# query_gaia_dr2 = \
# (query_common
# .join(CatalogToTIC_v8)
# .join(TIC_v8, on=(CatalogToTIC_v8.target_id == TIC_v8.id))
# .join(Gaia_DR2, on=(TIC_v8.gaia_int == Gaia_DR2.source_id))
# .join(temp,
# on=(temp.Gaia_DR2_Source_ID == Gaia_DR2.source_id))
# .switch(Catalog)
# .where(CatalogToTIC_v8.version_id == version_id,
# (CatalogToTIC_v8.best >> True) |
# CatalogToTIC_v8.best.is_null(),
# Catalog.version_id == version_id))

query_legacysurvey_dr10 = \
(query_common
.join(CatalogToLegacy_Survey_DR10)
Expand Down
Loading