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

tidying up and applying carton name changes throughout #28

Merged
merged 1 commit into from
Aug 24, 2020
Merged
Show file tree
Hide file tree
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
16 changes: 7 additions & 9 deletions python/target_selection/cartons/bhm_aqmes.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,13 @@

## This provides the following BHM cartons:
# bhm_aqmes_med
# bhm_aqmes_med_faint
# bhm_aqmes_med-faint
# bhm_aqmes_wide2
# bhm_aqmes_wide2_faint
# bhm_aqmes_wide2-faint
# bhm_aqmes_wide3
# bhm_aqmes_wide3_faint
# bhm_aqmes_bonus_dark
# bhm_aqmes_bonus_bright
# bhm_aqmes_wide3-faint
# bhm_aqmes_bonus-dark
# bhm_aqmes_bonus-bright



Expand Down Expand Up @@ -167,7 +167,7 @@ class BhmAqmesMedCarton(BhmAqmesBaseCarton):
SELECT * FROM sdss_dr1x_qso WHERE psfmag_i BETWEEN 16.x AND 19.1
'''
name = 'bhm_aqmes_med'
cadence = 'bhm_aqmes_medium_12x4'
cadence = 'bhm_aqmes_medium_12x4'
#cadence = 'dummy_cadence'

# add something like the following if want to add carton-specific selections
Expand Down Expand Up @@ -195,9 +195,8 @@ class BhmAqmesWide3Carton(BhmAqmesBaseCarton):
'''
SELECT * FROM sdss_dr1x_qso WHERE psfmag_i BETWEEN 16.x AND 19.1
'''
name = 'bhm_aqmes-wide3'
name = 'bhm_aqmes_wide3'
cadence = 'bhm_aqmes_wide_3x4'
#program = 'bhm_aqmes'


class BhmAqmesWide3FaintCarton(BhmAqmesBaseCarton):
Expand All @@ -215,7 +214,6 @@ class BhmAqmesWide2Carton(BhmAqmesBaseCarton):
'''
name = 'bhm_aqmes_wide2'
cadence = 'bhm_aqmes_wide_2x4'
#program = 'bhm_aqmes'


class BhmAqmesWide2FaintCarton(BhmAqmesBaseCarton):
Expand Down
9 changes: 4 additions & 5 deletions python/target_selection/cartons/bhm_csc.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@
# https://wiki.sdss.org/display/OPS/Defining+target+selection+and+cadence+algorithms#Definingtargetselectionandcadencealgorithms-ChandraSourceCatalogue(CSC)-inprogress

## This module provides the following BHM cartons:
# bhm_csc_boss_dark
# bhm_csc_boss_bright
# bhm_csc_boss-dark
# bhm_csc_boss-bright
# bhm_csc_apogee


Expand All @@ -36,8 +36,8 @@ class BhmCscBaseCarton(BaseCarton):
To be sub-classed, not typically to be called directly.
'''

name = 'bhm_csc_base'
base_name = 'bhm_csc_base'
name = 'bhm_csc-base'
base_name = 'bhm_csc-base'
category = 'science'
mapper = 'BHM'
program = 'bhm_csc'
Expand All @@ -59,7 +59,6 @@ def build_query(self, version_id, query_region=None):
query = (
c
.select(c.catalogid,
# c.ra, c.dec, t.cxo_name, t.oir_ra.alias("csc_oir_ra"), t.oir_dec.alias("csc_oir_dec"), ## debug
priority,
value,
t.mag_g.alias('g'),
Expand Down
34 changes: 11 additions & 23 deletions python/target_selection/cartons/bhm_gua.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@
# https://wiki.sdss.org/display/OPS/Defining+target+selection+and+cadence+algorithms

## This module provides the following BHM cartons:
# bhm_gaia_unwise_agn_dark
# bhm_gaia_unwise_agn_bright
# bhm_gua_dark
# bhm_gua_bright


'''
Expand All @@ -44,10 +44,10 @@
AND WHERE gua.prob_rf > 0.8
AND WHERE (so.specobjid = NULL OR so.zwarning != 0 OR so.sn_median_all < x.x OR so.z_err > 0.0xx )
bhm_gaia_unwise_agn_dark
bhm_gua_dark
AND WHERE ( gua.g > 16.5 AND gua.rp > 16.5 AND (gua.g < 21.2 OR gua.rp < 21.0 ) )
bhm_gaia_unwise_agn_bright
bhm_gua_bright
AND WHERE ( gua.g > 13.0 AND gua.rp > 13.5 AND (gua.g < 18.5 OR gua.rp < 18.5) )
'''

Expand All @@ -62,7 +62,7 @@ class BhmGuaBaseCarton(BaseCarton):
Catalog -> CatalogToTIC_v8 -> Gaia_DR2 -> Gaia_unWISE_AGN
'''

name = 'bhm_gaia_unwise_agn_base'
name = 'bhm_gua_base'
category = 'science'
mapper = 'BHM'
program = 'bhm_filler'
Expand All @@ -71,7 +71,7 @@ class BhmGuaBaseCarton(BaseCarton):

def build_query(self, version_id, query_region=None):
c = Catalog.alias()
##############c2t = CatalogToGaia_unWISE_AGN.alias()
##############c2t = CatalogToGaia_unWISE_AGN.alias() - deprecated
c2tic = CatalogToTIC_v8.alias()
tic = TIC_v8.alias()
c2s = CatalogToSDSS_DR16_SpecObj.alias()
Expand All @@ -85,7 +85,6 @@ def build_query(self, version_id, query_region=None):
pmra = peewee.Value(0.0).cast('float').alias('pmra')
pmdec = peewee.Value(0.0).cast('float').alias('pmdec')
parallax = peewee.Value(0.0).cast('float').alias('parallax')
#match_radius_spectro = self.parameters['spec_join_radius']/3600.0

query = (
c.select(c.catalogid,
Expand All @@ -102,18 +101,6 @@ def build_query(self, version_id, query_region=None):
.join(tic)
.join(g)
.join(t, on=(g.source_id == t.gaia_sourceid))
# .join(s, JOIN.LEFT_OUTER,
# on=(peewee.fn.q3c_join(c.ra,c.dec,
# s.ra,s.dec,
# match_radius_spectro) &
# (s.snmedian >= self.parameters['spec_sn_thresh']) &
# (s.zwarning == 0) &
# (s.zerr <= self.parameters['spec_z_err_thresh']) &
# (s.zerr > 0.0) &
# (s.scienceprimary > 0)
# )
# )
# .where((s.specobjid.is_null())
.where(c.version_id == version_id,
c2tic.version_id == version_id,
c2tic.best == True)
Expand Down Expand Up @@ -141,26 +128,27 @@ def build_query(self, version_id, query_region=None):
return query


#------- bhm_gaia_unwise_agn_dark ------ #
#------- bhm_gua_dark ------ #

class BhmGuaDarkCarton(BhmGuaBaseCarton):
'''
AND WHERE ( gua.g > 16.x AND gua.rp > 16.x)
'''
name = 'bhm_gua_dark'
program = 'bhm_filler'
cadence = 'bhm_spiders_1x4'

#------- bhm_gaia_unwise_agn_bright ------ #
#------- bhm_gua_bright ------ #

class BhmGuaBrightCarton(BhmGuaBaseCarton):
'''
AND WHERE ( gua.g < 18.x OR gua.rp < 18.x)
'''
name = 'bhm_gua_bright'
program = 'bhm_filler'
cadence = 'bhm_boss_bright_3x1'




'''
Exporting from the temp table
Expand Down
36 changes: 16 additions & 20 deletions python/target_selection/cartons/bhm_rm.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@

## This module provides the following BHM cartons:
# bhm_rm_core
# bhm_rm_known_spec
# bhm_rm_known-spec
# bhm_rm_var
# bhm_rm_ancillary

Expand Down Expand Up @@ -218,15 +218,11 @@ def build_query(self, version_id, query_region=None):
magnitude_r.alias('r'),
magnitude_i.alias('i'),
magnitude_z.alias('z'),
# magnitude_bp.alias('bp'), # let the targetdb fill this in automatically
# magnitude_rp.alias('rp'),
# s.z.alias('sdss_dr16_specobj_z'),
# s.plate.alias('sdss_dr16_specobj_plate'),
# s.mjd.alias('sdss_dr16_specobj_mjd'),
# s.fiberid.alias('sdss_dr16_specobj_fiberid'),
)
.join(c2t)
.join(t, on=(c2t.target_id == t.pk)) # needed because using c2t for Catalog_to_BHM_RM_v0
# The following is needed because we are using c2t for Catalog_to_BHM_RM_v0
# rather than a native c2t for Catalog_to_BHM_RM_v0_2
.join(t, on=(c2t.target_id == t.pk))
.where(c.version_id == version_id,
c2t.version_id == version_id,
(
Expand All @@ -253,10 +249,6 @@ def build_query(self, version_id, query_region=None):
)
query = self.append_spatial_query(query, self.get_fieldlist())

# # also set the Carton priority+value here - read from yaml
# self.priority = self.parameters['priority']
# self.value = self.parameters['value']

return query


Expand Down Expand Up @@ -317,7 +309,7 @@ def build_query(self, version_id, query_region=None):

class BhmRmKnownSpecCarton(BhmRmBaseCarton):
'''
bhm_rm_known_spec: select all spectroscopically confirmed QSOs where redshift is extragalactic
bhm_rm_known-spec: select all spectroscopically confirmed QSOs where redshift is extragalactic
SELECT * FROM bhm_rm
WHERE specz > 0.005
Expand Down Expand Up @@ -367,18 +359,22 @@ def build_query(self, version_id, query_region=None):


class BhmRmVarCarton(BhmRmBaseCarton):
'''
bhm_rm_var: selected based on g-band variability > 0.05 mag and bright enough to be detected by Gaia (G<~21)
'''bhm_rm_var: selected based on g-band variability > 0.05 mag and bright enough to be detected by Gaia (G<~21)
SELECT * FROM bhm_rm
WHERE ( (des_var_sn[0] > 5.0 AND des_var_rms[0] > 0.05) OR (ps1_var_sn[0]>5.0 AND ps1_var_rms[0]>0.05))
WHERE ( (des_var_sn[0] > 5.0 AND des_var_rms[0] > 0.05) OR
(ps1_var_sn[0]>5.0 AND ps1_var_rms[0]>0.05))
AND WHERE mi BETWEEN 15.0 AND 21.5 # <- exact limits TBD
AND WHERE pmsig < 5.0
AND WHERE plxsig < 5.0
AND WHERE pmsig < x.x
AND WHERE plxsig < x.x
AND WHERE gaia = 1
#debug
select t.pk, t.ra, t.dec, t.mi, t.psfmag_sdss[4] as psfmag_i,t.pmsig,t.ps1_var_sn[1],t.ps1_var_rms[1],t.des_var_sn[1],t.des_var_rms[1] from bhm_rm_v0 as t where (t.gaia = 1 AND t.mi < 21.5 AND t.pmsig < 5.0 AND t.plxsig < 5.0 AND t.ps1_var_sn[1] > 5.0 AND t.ps1_var_rms[1] > 0.05 ) limit 10;
#debug select t.pk, t.ra, t.dec, t.mi, t.psfmag_sdss[4] as
psfmag_i,t.pmsig,t.ps1_var_sn[1],t.ps1_var_rms[1],t.des_var_sn[1],t.des_var_rms[1]
from bhm_rm_v0 as t where (t.gaia = 1 AND t.mi < 21.5 AND t.pmsig
< 5.0 AND t.plxsig < 5.0 AND t.ps1_var_sn[1] > 5.0 AND
t.ps1_var_rms[1] > 0.05 ) limit 10;
'''

name = 'bhm_rm_var'
Expand Down
Loading