Skip to content

Commit

Permalink
Added '_3' versions of several BHM cartons. Added bhm_aqmes_wide1* ca…
Browse files Browse the repository at this point in the history
…rtons.
  • Loading branch information
tdwelly committed Jul 16, 2024
1 parent e8de788 commit a344da3
Show file tree
Hide file tree
Showing 9 changed files with 136 additions and 103 deletions.
2 changes: 2 additions & 0 deletions .flake8
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[flake8]
max-line-length = 99
23 changes: 23 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,28 @@
# Changelog

## 1.3.1 - July 16, 2024

## New

* .flake8 - allow line length up to 100 characters (as it was before)
* added bhm\_aqmes\_wide1 and bhm\_aqmes\_wide1\_faint cartons
* identical to 'wide2' versions, but with a 'dark\_1x4' cadence and +1 added to priorities
* new '\_3' versions of selected BHM cartons
* these new cartons assign targets which prevously had cadence 'dark\_flexible\_4x1' a new cadence of 'dark\_flexible\_3x1'
* these new versions only output the subset of targets having cadence (targets with easier cadences are omitted)
* the '\_3' versions have target priority incremented by 1
* new '\_3' cartons are:
* bhm\_csc\_boss\_3
* bhm\_gua\_dark\_3
* bhm\_spiders\_clusters\_lsdr10\_3
* bhm\_spiders\_agn\_lsdr10\_3
* bhm\_spiders\_agn\_hard\_3
* bhm\_spiders\_agn\_gaiadr3\_3
* bhm\_spiders\_agn\_tda\_3
* bhm\_spiders\_agn\_sep\_3
* bhm\_colr\_galaxies\_lsdr10\_3


## 1.3.0 - July 10, 2024

### ✨ Improved
Expand Down
21 changes: 14 additions & 7 deletions python/target_selection/cartons/bhm_aqmes.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,12 @@ class BhmAqmesBaseCarton(BaseCarton):
cadence = None
cadence_v0p5 = None

# read the AQMES field centres from a fits file and convert to a list of dicts
def get_fieldlist(self, cadence_v1=None):
def get_fieldlist(self, cadence_v0=None):
"""
read the AQMES field centres from a fits file and convert to a list of dicts
New: it is now the responsibility of the calling function to convert from a
v1 cadence into a v0 cadence name
"""
stub = self.parameters.get("fieldlist", None)
if stub is None or stub == "" or stub == "None":
return None
Expand All @@ -104,10 +108,11 @@ def get_fieldlist(self, cadence_v1=None):

assert len(hdul[1].data) > 0

# choose the correct subset of fields based on the cadence name and form a list of dicts
# we have to use the v0 cadence names though
assert cadence_v1 in cadence_map_v1_to_v0
cadence_v0 = cadence_map_v1_to_v0[cadence_v1]
# # choose the correct subset of fields based on the cadence name
# # and then form a list of dicts
# # we have to use the v0 cadence names in the file though
# assert cadence_v1 in cadence_map_v1_to_v0
# cadence_v0 = cadence_map_v1_to_v0[cadence_v1]

try:
fieldlist = [
Expand Down Expand Up @@ -242,7 +247,9 @@ def build_query(self, version_id, query_region=None):
.distinct([c.catalogid]) # avoid duplicates - trust the catalog
)

query = self.append_spatial_query(query, self.get_fieldlist(cadence_v1))
# query = self.append_spatial_query(query, self.get_fieldlist(cadence_v1))
query = self.append_spatial_query(query,
self.get_fieldlist(cadence_v0))

return query

Expand Down
10 changes: 10 additions & 0 deletions python/target_selection/cartons/bhm_csc.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@

# This module provides the following BHM cartons:
# bhm_csc_boss
# bhm_csc_boss_3
# bhm_csc_apogee


Expand All @@ -49,6 +50,7 @@ class BhmCscBossCarton(BaseCarton):
instrument = "BOSS"
tile = False
can_offset = True
only_faintest_cadence = False

def build_query(self, version_id, query_region=None):
x = BHM_CSC_v3.alias()
Expand Down Expand Up @@ -239,6 +241,9 @@ def build_query(self, version_id, query_region=None):
.distinct([fn.coalesce(c2g3.catalogid, c2ls.catalogid, c2ps.catalogid)])
)

if self.only_faintest_cadence:
query = query.where(cadence == cadence3)

if query_region:
query = query.where(
peewee.fn.q3c_radial_query(
Expand All @@ -249,6 +254,11 @@ def build_query(self, version_id, query_region=None):
return query


class BhmCscBoss3Carton(BhmCscBossCarton):
name = "bhm_csc_boss_3"
only_faintest_cadence = True


# #######
class BhmCscApogeeCarton(BaseCarton):
"""
Expand Down
21 changes: 17 additions & 4 deletions python/target_selection/cartons/bhm_galaxies.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,11 @@
"""
Details: Start here
https://wiki.sdss.org/display/OPS/Defining+target+selection+and+cadence+algorithms
see particularly: https://wiki.sdss.org/display/BHM/BHM+Cartons+of+Last+Resort
This module provides the following BHM cartons:
bhm_colr_galaxies_lsdr10
see particularly: https://wiki.sdss.org/display/BHM/BHM+Cartons+of+Last+Resort
bhm_colr_galaxies_lsdr10_3
"""

Expand All @@ -50,6 +51,7 @@ class BhmColrGalaxiesLsdr10Carton(BaseCarton):
# cadence = 'dark_1x1'
instrument = "BOSS"
can_offset = False
only_faintest_cadence = False

def build_query(self, version_id, query_region=None):
c = Catalog.alias()
Expand Down Expand Up @@ -154,13 +156,16 @@ def build_query(self, version_id, query_region=None):

opt_prov = peewee.Case(None, ((valid, "sdss_fiber2mag_from_lsdr10"),), "undefined")

cadence1 = self.parameters["cadence1"]
cadence2 = self.parameters["cadence2"]
cadence3 = self.parameters["cadence3"]
cadence = peewee.Case(
None,
(
(ls.fiberflux_r > fiberflux_r_min_for_cadence1, self.parameters["cadence1"]),
(ls.fiberflux_r > fiberflux_r_min_for_cadence2, self.parameters["cadence2"]),
(ls.fiberflux_r > fiberflux_r_min_for_cadence1, cadence1),
(ls.fiberflux_r > fiberflux_r_min_for_cadence2, cadence2),
),
self.parameters["cadence3"],
cadence3,
)

# compute the abs(Galactic latitude):
Expand Down Expand Up @@ -234,6 +239,9 @@ def build_query(self, version_id, query_region=None):
.distinct(c.catalogid)
)

if self.only_faintest_cadence:
query = query.where(cadence == cadence3)

# query_region[0] is ra of center of the region, degrees
# query_region[1] is dec of center of the region, degrees
# query_region[2] is radius of the region, degrees
Expand All @@ -245,3 +253,8 @@ def build_query(self, version_id, query_region=None):
)

return query


class BhmColrGalaxiesLsdr103Carton(BhmColrGalaxiesLsdr10Carton):
name = "bhm_colr_galaxies_lsdr10_3"
only_faintest_cadence = True
5 changes: 5 additions & 0 deletions python/target_selection/cartons/bhm_gua.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
#
# This module provides the following BHM cartons:
# bhm_gua_dark
# bhm_gua_dark_3
# bhm_gua_bright
#
# Updated by TD on 27/01/2021 to add v0.5 improvements
Expand Down Expand Up @@ -296,6 +297,10 @@ class BhmGuaDarkCarton(BhmGuaBaseCarton):
name = "bhm_gua_dark"


class BhmGuaDark3Carton(BhmGuaBaseCarton):
name = "bhm_gua_dark_3"


class BhmGuaBrightCarton(BhmGuaBaseCarton):
"""
------ bhm_gua_bright ------
Expand Down
27 changes: 27 additions & 0 deletions python/target_selection/cartons/bhm_spiders_agn.py
Original file line number Diff line number Diff line change
Expand Up @@ -622,6 +622,7 @@ class BhmSpidersAgnGaiadr3Carton(BaseCarton):
tile = False
instrument = "BOSS"
can_offset = True
only_faintest_cadence = False

def build_query(self, version_id, query_region=None):
c = Catalog.alias()
Expand Down Expand Up @@ -932,6 +933,9 @@ def build_query(self, version_id, query_region=None):
.distinct([g3.source_id]) # avoid duplicates - we trust the gaia ids
)

if self.only_faintest_cadence:
query = query.where(cadence == cadence3)

if query_region:
query = query.where(
peewee.fn.q3c_radial_query(
Expand Down Expand Up @@ -959,12 +963,25 @@ class BhmSpidersAgnGaiadr3BothCarton(BhmSpidersAgnGaiadr3Carton):
name = "bhm_spiders_agn_gaiadr3_both"


# ##################################################################################
# we can get away with just inheriting the selection code from
# the gaia dr3 hemisphere match and adjusting the parameters only
class BhmSpidersAgnSepCarton(BhmSpidersAgnGaiadr3Carton):
name = "bhm_spiders_agn_sep"


# ##################################################################################
class BhmSpidersAgnGaiadr33CartonCarton(BhmSpidersAgnGaiadr3Carton):
name = "bhm_spiders_agn_gaiadr3_3"
only_faintest_cadence = True


# ##################################################################################
class BhmSpidersAgnSep3Carton(BhmSpidersAgnGaiadr3Carton):
name = "bhm_spiders_agn_sep_3"
only_faintest_cadence = True


class BhmSpidersAgnTdaCarton(BaseCarton):
name = "bhm_spiders_agn_tda"
category = "science"
Expand All @@ -973,6 +990,7 @@ class BhmSpidersAgnTdaCarton(BaseCarton):
tile = False
instrument = "BOSS"
can_offset = True
only_faintest_cadence = False

def build_query(self, version_id, query_region=None):
c = Catalog.alias()
Expand Down Expand Up @@ -1240,6 +1258,9 @@ def build_query(self, version_id, query_region=None):
.distinct([ls.ls_id]) # avoid duplicates - we trust the legacy survey entries
)

if self.only_faintest_cadence:
query = query.where(cadence == cadence3)

if query_region:
query = query.where(
peewee.fn.q3c_radial_query(
Expand All @@ -1248,3 +1269,9 @@ def build_query(self, version_id, query_region=None):
)

return query


# ##################################################################################
class BhmSpidersAgnTda3Carton(BhmSpidersAgnTdaCarton):
name = "bhm_spiders_agn_tda_3"
only_faintest_cadence = True
9 changes: 9 additions & 0 deletions python/target_selection/cartons/bhm_spiders_clusters.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@
# # This file provides the following BHM cartons in v1.0:
#
# bhm_spiders_clusters_lsdr10
# bhm_spiders_clusters_lsdr10_3
#
# ############################################
# ############################################
Expand Down Expand Up @@ -83,6 +84,7 @@ class BhmSpidersClustersLsdr10Carton(BaseCarton):
instrument = "BOSS"
inertial = True
can_offset = True
only_faintest_cadence = False

def build_query(self, version_id, query_region=None):
c = Catalog.alias()
Expand Down Expand Up @@ -395,6 +397,9 @@ def build_query(self, version_id, query_region=None):
.distinct([ls.ls_id])
)

if self.only_faintest_cadence:
query = query.where(cadence == cadence3)

if query_region:
query = query.where(
peewee.fn.q3c_radial_query(
Expand All @@ -408,3 +413,7 @@ def build_query(self, version_id, query_region=None):
#
# END BhmSpidersClustersLsdr10Carton
# ##################################################################################

class BhmSpidersClustersLsdr103Carton(BhmSpidersClustersLsdr10Carton):
name = "bhm_spiders_clusters_lsdr10_3"
only_faintest_cadence = True
Loading

0 comments on commit a344da3

Please sign in to comment.