Skip to content

Commit

Permalink
carton/tools.py: add comment (#452)
Browse files Browse the repository at this point in the history
  • Loading branch information
astronomygupta authored Jul 3, 2024
1 parent f42d0c3 commit b95f246
Showing 1 changed file with 21 additions and 1 deletion.
22 changes: 21 additions & 1 deletion python/target_selection/cartons/tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,22 @@ def build_query(self, version_id, query_region=None):
peewee.Value(0).alias('value'))
.distinct(Catalog.catalogid))

# The above clause .distinct(Catalog.catalogid)) is
# part of below queries like
# query_gaia_dr3, query_gaia_dr2 etc. via query_common.
# Note that the DISTINCT clause applies to
# each of query_gaia_dr3, query_gaia_dr2 etc.
# However, it does not apply to the UNION of these queries.
# Hence, if the manual carton input fits file
# contains multiple types of IDs
# then it is possible to get duplicate catalogid where
# one catalogid is from query_gaia_dr3 and other is from
# query_twomass_psc. This will be detected at the time of
# creation of the unique index on catalogid
# in the temporary table.
# Hence, the carton owner should remove such duplicates in the
# manual carton input fits file.

query_gaia_dr3 = \
(query_common
.join(CatalogToGaia_DR3)
Expand Down Expand Up @@ -422,6 +438,9 @@ def build_query(self, version_id, query_region=None):

query = None

# Below variable 'query' is a UNION of queries.
# The operator | is used to construct a UNION of queries.

if (is_gaia_dr3 is True):
if (query is None):
query = query_gaia_dr3
Expand Down Expand Up @@ -459,7 +478,8 @@ def build_query(self, version_id, query_region=None):
query = query | query_twomass_psc

if (query is None):
# At least one of the four boolean variables above
# At least one of the boolean variables above
# (e.g. is_gaia_dr3, is_gaia_dr2 etc.)
# must be True, so we should not get here.
raise TargetSelectionError('error in get_file_carton(): ' +
'(is_gaia_dr3 is False) and ' +
Expand Down

0 comments on commit b95f246

Please sign in to comment.