Skip to content

Commit

Permalink
Tag1.3.3 (#465)
Browse files Browse the repository at this point in the history
* edits for tag1.3.3

* edits for tag1.3.3

* edit mwm_snc.py

* cartons/base.py: time.sleep(30)

* cartons/base.py: execute_sql(COMMIT

* cartons/base.py: execute_sql('COMMIT;') before get_model()

* cartons/base.py: comments

* edits for tag1.3.3

* edits for tag1.3.3
  • Loading branch information
astronomygupta authored Jul 21, 2024
1 parent 34876bd commit cd2e3a4
Show file tree
Hide file tree
Showing 6 changed files with 123 additions and 12 deletions.
4 changes: 2 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
# Changelog


## 1.3.3 - July 18, 2024
## 1.3.3 - July 21, 2024

## New

* add cartons to target_selection plan 1.2.4
* 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 '\_d3' versions of selected BHM cartons
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "sdss-target-selection"
version = "1.3.3.a0"
version = "1.3.3"
description = "Code to perform target selection for BHM/MWM using catalogdb"
authors = ["José Sánchez-Gallego <[email protected]>"]
license = "BSD 3-Clause"
Expand Down
8 changes: 8 additions & 0 deletions python/target_selection/cartons/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -311,6 +311,12 @@ def run(

self.log.info(f"Created table {path!r} in {timer.interval:.3f} s.")

# Note that above execute_sql() is the same as below
# self.database.execute_sql() since at the top of this method
# we have the below statement.
# execute_sql = self.database.execute_sql

self.database.execute_sql("COMMIT;")
self.RModel = self.get_model()

self.log.debug("Adding columns and indexes.")
Expand Down Expand Up @@ -773,6 +779,7 @@ def write_table(self, filename=None, mode="results", write=True):
self.log.debug(f"Writing table to {filename}.")

if not self.RModel:
self.database.execute_sql("COMMIT;")
self.RModel = self.get_model()

if mode == "results":
Expand Down Expand Up @@ -885,6 +892,7 @@ def load(self, mode="fail", overwrite=False):
raise ValueError(f'Invalid mode {mode!r}. Use "fail", "overwrite", or "append".')

if self.RModel is None:
self.database.execute_sql("COMMIT;")
RModel = self.get_model()
else:
RModel = self.RModel
Expand Down
3 changes: 3 additions & 0 deletions python/target_selection/cartons/bhm_spiders_agn.py
Original file line number Diff line number Diff line change
Expand Up @@ -600,6 +600,9 @@ def build_query(self, version_id, query_region=None):
#
# END BhmSpidersAgnLsdr10Carton
# ##################################################################################
class BhmSpidersAgnLsdr10D3Carton(BhmSpidersAgnLsdr10Carton):
name = "bhm_spiders_agn_lsdr10_d3"
only_faintest_cadence = True


# we can get away with just inheriting the selection code from
Expand Down
116 changes: 109 additions & 7 deletions python/target_selection/cartons/mwm_snc.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,28 +135,130 @@ def build_query(self, version_id, query_region=None):


class MWM_SNC_100pc_BOSS_Carton(MWM_SNC_100pc_Carton):
"""MWM SNC 100pc targets to be observed with BOSS."""
"""MWM SNC 100pc targets to be observed with BOSS.
Shorthand name: mwm_snc_100pc_boss
https://sdss-wiki.atlassian.net/wiki/spaces/OPS/pages/13707660/Cartons+for+post+v1
Existing carton code: https://github.com/sdss/target_selection/blob/main/python/target_selection/cartons/mwm_snc.py
Simplified Description of selection criteria :
Select everything within 100pc (i.e. parallax > 10mas) and Gaia-G
fainter than 10th mag. Add some constraints on astrometric excess noise
in crowded regions (Galactic plane, LMC, SMC, towards Galactic center).
For details, see here. Pseudo-code: For the pseduo-code, I will shorten
it and use the definition of "gal_cut" from the existing carton code.
Also, the red text below is what is being added to the target selection
compared to the original v1 carton. (parallax > 0) & (parallax -
parallax_error > 10) & (phot_g_mean_mag > 10) &
((astrometric_excess_noise < 2) & (ll >= 20) & (ll <= 340) & gal_cut) |
((astrometric_excess_noise < 2) & (ruwe < 1.2) & (1 + 0.015 *
(phot_bp_mean_mag - phot_rp_mean_mag)^2 < phot_bp_rp_excess_factor) &
(phot_bp_rp_excess_factor < 1.3 + 0.06 * (phot_bp_mean_mag -
phot_rp_mean_mag)^2) & (ll < 20 | ll > 340) & gal_cut) | ~gal_cut)
Return columns: Same columns as before + astrometric_excess_noise,
phot_bp_rp_excess_factor, ruwe, phot_bp_mean_mag , phot_rp_mean_mag
Metadata:
Priority: 1800
Cadence: if G < 16, bright_2x1 ; if G > 16, dark_2x1
Instrument: BOSS
can_offset = True
Lead contact: Ilija Medan
"""

name = "mwm_snc_100pc_boss"
category = "science"
program = "mwm_snc"
mapper = "MWM"
instrument = "BOSS"
priority = 2705
priority = 1800
can_offset = True

def build_query(self, version_id, query_region=None):
ll = Gaia_DR3.l
bb = Gaia_DR3.b

# Dense regions (Galactic plane, SMC, LMC).
gal_cut = (
((ll <= 180) & (bb < (-0.139 * ll + 25)) & (bb > (0.139 * ll - 25)))
| ((ll > 180) & (bb > (-0.139 * ll + 25)) & (bb < (0.139 * ll - 25)))
| (fn.sqrt(fn.pow(ll - 303.2, 2) + 2 * fn.pow(bb + 44.4, 2)) < 5)
| (fn.sqrt(fn.pow(ll - 280.3, 2) + 2 * fn.pow(bb + 33.0, 2)) < 8)
)

query = super().build_query(version_id, query_region)
query = query.where(Gaia_DR3.phot_g_mean_mag > 10)
query = query.where(
Gaia_DR3.parallax > 0,
Gaia_DR3.parallax - Gaia_DR3.parallax_error > 10,
Gaia_DR3.phot_g_mean_mag > 10,
((Gaia_DR3.astrometric_excess_noise < 2) & (ll >= 20) & (ll <= 340) & gal_cut)
| (
(Gaia_DR3.astrometric_excess_noise < 2)
& (Gaia_DR3.ruwe < 1.2)
& (
1 + 0.015 * fn.pow(Gaia_DR3.phot_bp_mean_mag - Gaia_DR3.phot_rp_mean_mag, 2)
< Gaia_DR3.phot_bp_rp_excess_factor
)
& (
Gaia_DR3.phot_bp_rp_excess_factor
< 1.3 + 0.06 * fn.pow(Gaia_DR3.phot_bp_mean_mag - Gaia_DR3.phot_rp_mean_mag, 2)
& (ll < 20 | ll > 340)
& gal_cut
)
| ~gal_cut
),
)

return query

def post_process(self, model, **kwargs):
# G < 16 => cadence = bright_2x1
model.update(cadence="bright_2x1").where(model.phot_g_mean_mag < 16).execute()

# G > 16 => cadence = dark_2x1
model.update(cadence="dark_2x1").where(model.phot_g_mean_mag >= 16).execute()

return model


class MWM_SNC_100pc_BOSS_single_Carton(MWM_SNC_100pc_BOSS_Carton):
"""MWM SNC 100pc targets to be observed with BOSS.
Shorthand name: mwm_snc_100pc_boss_single
https://sdss-wiki.atlassian.net/wiki/spaces/OPS/pages/13707660/Cartons+for+post+v1
Simplified Description of selection criteria :
NOTE this is a subcarton of mwm_snc_100pc_boss (see above) where the only change
is the cadence and priority.
Metadata:
Priority: 1801
Cadence: if G < 16, bright_1x1 ; if G > 16, dark_1x1
Instrument: BOSS
can_offset = True
Lead contact: Ilija Medan
"""

name = "mwm_snc_100pc_boss_single"
category = "science"
program = "mwm_snc"
mapper = "MWM"
instrument = "BOSS"
priority = 1801
can_offset = True

def build_query(self, version_id, query_region=None):
query = super().build_query(version_id, query_region)
return query

def post_process(self, model, **kwargs):
# G < 16 => cadence = bright_flexible_1x2
model.update(cadence="bright_flexible_1x2").where(model.phot_g_mean_mag < 16).execute()
# G < 16 => cadence = bright_1x1
model.update(cadence="bright_1x1").where(model.phot_g_mean_mag < 16).execute()

# G > 16 => cadence = dark_flexible_1x2
model.update(cadence="dark_flexible_1x2").where(model.phot_g_mean_mag > 16).execute()
# G > 16 => cadence = dark_1x1
model.update(cadence="dark_1x1").where(model.phot_g_mean_mag >= 16).execute()

return model

Expand Down
2 changes: 0 additions & 2 deletions python/target_selection/config/target_selection.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

'1.2.4':
xmatch_plan: 1.0.0
cartons:
Expand All @@ -12,7 +11,6 @@
- bhm_spiders_agn_gaiadr3_d3
- bhm_spiders_agn_tda_d3
- bhm_spiders_agn_sep_d3
- bhm_colr_galaxies_lsdr10_d3
- mwm_erosita_compact_boss_d3
- mwm_erosita_compact_boss_shallow
open_fiber_path: /uufs/chpc.utah.edu/common/home/sdss50/sdsswork/target/open_fiber/postv1/draft2/
Expand Down

0 comments on commit cd2e3a4

Please sign in to comment.