-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Allow to read XMatchPlanner configuration from a dictionary * Use rich handler for logger * Allow _temp_count=0 * Allow to override the logger used by the XMatchPlanner * Linting indentation fix * Add added_by_phase column to relational model * Revert Felipe's use of SQL files for phase 1 * Phase 1: distinct only on model_pk This should prevent duplicates when a target in the intermediate table has been cross-matched to multiple catalogids. * Phase 2: allow to cross-match with temporary and real catalog * Phase 3: require using only best matches This is an imporant bug fix. Before we were missing targets that where associated with a catalogid in phase 2 but only as a secondary match. * Revert Felipe's use of SQL files for phase 3 * Consolidate line * Revert using rich logger * Delete phase1_range option from XMatchPlanner * Deepcopy config file * Add mode parameter to load method of BaseCarton * Add ToO_Carton * Always use self.log instead of log in BaseCarton * Import CatalogToToO_Target inside build_query * Go back to importing CatalogToToO_Target at top * Add IF NOT EXISTS to the creation of the q3c index * Store intermediate catalog_to_XXX results in sandbox * Linting
- Loading branch information
Showing
5 changed files
with
382 additions
and
334 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
#!/usr/bin/env python | ||
# -*- coding: utf-8 -*- | ||
# | ||
# @Author: José Sánchez-Gallego ([email protected]) | ||
# @Date: 2024-02-16 | ||
# @Filename: too.py | ||
# @License: BSD 3-clause (http://www.opensource.org/licenses/BSD-3-Clause) | ||
|
||
from __future__ import annotations | ||
|
||
from sdssdb.peewee.sdss5db.catalogdb import (CatalogToToO_Target, | ||
ToO_Metadata, ToO_Target) | ||
from sdssdb.peewee.sdss5db.targetdb import (Carton, CartonToTarget, | ||
Target, Version) | ||
|
||
from .base import BaseCarton | ||
|
||
|
||
__all__ = ['ToO_Carton'] | ||
|
||
|
||
class ToO_Carton(BaseCarton): | ||
"""Target of opportunity carton. | ||
Selects all the targets in ``catalogdb.too_target`` that don't yet exist in | ||
the carton. | ||
""" | ||
|
||
name = 'too' | ||
category = 'science' | ||
cadence = 'bright_1x1' | ||
priority = 3000 | ||
program = 'too' | ||
can_offset = True | ||
|
||
def build_query(self, version_id, query_region=None): | ||
|
||
C2TT = CatalogToToO_Target | ||
|
||
too_in_carton = (Target | ||
.select(Target.catalogid) | ||
.join(CartonToTarget) | ||
.join(Carton) | ||
.join(Version) | ||
.where(Version.plan == self.plan, | ||
Carton.carton == self.name)).alias('too_in_carton') | ||
|
||
query = (ToO_Target.select(C2TT.catalogid, | ||
ToO_Target.fiber_type.alias('instrument'), | ||
ToO_Metadata.g_mag.alias('g'), | ||
ToO_Metadata.r_mag.alias('r'), | ||
ToO_Metadata.i_mag.alias('i'), | ||
ToO_Metadata.z_mag.alias('z'), | ||
ToO_Metadata.optical_prov) | ||
.join(C2TT, on=(ToO_Target.too_id == C2TT.target_id)) | ||
.switch(ToO_Target) | ||
.join(ToO_Metadata, on=(ToO_Target.too_id == ToO_Metadata.too_id)) | ||
.where(C2TT.version_id == version_id, | ||
C2TT.best >> True, | ||
C2TT.catalogid.not_in(too_in_carton))) | ||
|
||
return query |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.