Skip to content

Commit

Permalink
Merge pull request #723 from desihub/rongpu-lrg
Browse files Browse the repository at this point in the history
Update baseline LRG selection
  • Loading branch information
geordie666 committed May 5, 2021
2 parents e59fc85 + fd0c8ea commit 05db498
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 62 deletions.
10 changes: 8 additions & 2 deletions doc/changes.rst
Expand Up @@ -5,6 +5,12 @@ desitarget Change Log
0.57.3 (unreleased)
-------------------

* Update the baseline LRG selection [`PR #723`_]. Changes from SV3 include:
* Change the zfiber faint limit from 21.7 to 21.6.
* Change the low-z limit from z>0.3 to z>0.4.
* Change the overall density from 800/sq.deg. to 600/sq.deg.
* Remove the LRG_LOWDENS target bit.
* Add ``desispec.skybricks`` to lookup if ras,decs are blank sky [`PR #722`_].
* Add `MWS-FAINT-RED` and `MWS-FAINT-BLUE` target classes for main survey
[`PR #719`_].
* Prepare the Main Survey cuts and bit-masks [`PR #718`_]. Includes:
Expand All @@ -25,8 +31,7 @@ desitarget Change Log
to swap EDR3 proper motions/parallaxes for values in sweeps files.
* New function and bin script to make QSO redshift catalogs [`PR #714`_].
* Incorporates functionality from QuasarNET and SQUEzE.
* Add ``desispec.skybricks`` to lookup whether ra,dec locations are blank sky
[`PR #722`_].


.. _`PR #714`: https://github.com/desihub/desitarget/pull/714
.. _`PR #715`: https://github.com/desihub/desitarget/pull/715
Expand All @@ -35,6 +40,7 @@ desitarget Change Log
.. _`PR #718`: https://github.com/desihub/desitarget/pull/718
.. _`PR #719`: https://github.com/desihub/desitarget/pull/719
.. _`PR #722`: https://github.com/desihub/desitarget/pull/722
.. _`PR #723`: https://github.com/desihub/desitarget/pull/723

0.57.2 (2021-04-18)
-------------------
Expand Down
72 changes: 16 additions & 56 deletions py/desitarget/cuts.py
Expand Up @@ -381,7 +381,7 @@ def isLRG(gflux=None, rflux=None, zflux=None, w1flux=None, w2flux=None,
Notes
-----
- Current version (03/31/21) is version 15 on `the SV3 wiki`_.
- Current version (05/04/21) is version 254 on `the wiki`_.
- See :func:`~desitarget.cuts.set_target_bits` for other parameters.
"""
# ADM LRG targets.
Expand All @@ -398,15 +398,14 @@ def isLRG(gflux=None, rflux=None, zflux=None, w1flux=None, w2flux=None,
)

# ADM color-based selection of LRGs.
lrg, lrg_lowdens = isLRG_colors(
lrg = isLRG_colors(
gflux=gflux, rflux=rflux, zflux=zflux, w1flux=w1flux,
zfiberflux=zfiberflux, south=south, primary=primary
)

lrg &= lrg_quality
lrg_lowdens &= lrg_quality

return lrg, lrg_lowdens
return lrg


def notinLRG_mask(primary=None, rflux=None, zflux=None, w1flux=None,
Expand Down Expand Up @@ -459,7 +458,6 @@ def isLRG_colors(gflux=None, rflux=None, zflux=None, w1flux=None,
if primary is None:
primary = np.ones_like(rflux, dtype='?')
lrg = primary.copy()
lrg_lowdens = primary.copy() # lower density LRG selection

# ADM to maintain backwards-compatibility with mocks.
if zfiberflux is None:
Expand All @@ -476,56 +474,24 @@ def isLRG_colors(gflux=None, rflux=None, zflux=None, w1flux=None,
# Full SV3 selection
if south:
lrg &= zmag - w1mag > 0.8 * (rmag - zmag) - 0.6 # non-stellar cut
lrg &= zfibermag < 21.7 # faint limit
lrg &= (
(gmag - rmag > 1.3) & ((gmag - rmag) > -1.55 * (rmag - w1mag)+3.13)
| (rmag - w1mag > 1.8)
) # low-z cuts
lrg &= zfibermag < 21.6 # faint limit
lrg &= (gmag - w1mag > 2.9) | (rmag - w1mag > 1.8) # low-z cuts
lrg &= (
(rmag - w1mag > (w1mag - 17.26) * 1.8)
& (rmag - w1mag > (w1mag - 16.36) * 1.)
| (rmag - w1mag > 3.29)
((rmag - w1mag > (w1mag - 17.14) * 1.8)
& (rmag - w1mag > (w1mag - 16.33) * 1.))
| (rmag - w1mag > 3.33)
) # double sliding cuts and high-z extension
else:
lrg &= zmag - w1mag > 0.8 * (rmag - zmag) - 0.6 # non-stellar cut
lrg &= zfibermag < 21.72 # faint limit
lrg &= (
(gmag - rmag > 1.34) & ((gmag - rmag) > -1.55 * (rmag - w1mag)+3.23)
| (rmag - w1mag > 1.8)
) # low-z cuts
lrg &= zfibermag < 21.61 # faint limit
lrg &= (gmag - w1mag > 2.97) | (rmag - w1mag > 1.8) # low-z cuts
lrg &= (
(rmag - w1mag > (w1mag - 17.24) * 1.83)
& (rmag - w1mag > (w1mag - 16.33) * 1.)
| (rmag - w1mag > 3.39)
((rmag - w1mag > (w1mag - 17.13) * 1.83)
& (rmag - w1mag > (w1mag - 16.31) * 1.))
| (rmag - w1mag > 3.4)
) # double sliding cuts and high-z extension

# Selection of the lower density subset
if south:
lrg_lowdens &= zmag - w1mag > 0.8 * (rmag - zmag) - 0.6 # non-stellar cut
lrg_lowdens &= zfibermag < 21.7 # faint limit
lrg_lowdens &= (
(gmag - rmag > 1.3) & ((gmag - rmag) > -1.55 * (rmag - w1mag)+3.13)
| (rmag - w1mag > 1.8)
) # low-z cuts
lrg_lowdens &= (
(rmag - w1mag > (w1mag - 17.07) * 1.8)
& (rmag - w1mag > (w1mag - 16.17) * 1.)
| (rmag - w1mag > 3.39)
) # double sliding cuts and high-z extension
else:
lrg_lowdens &= zmag - w1mag > 0.8 * (rmag - zmag) - 0.6 # non-stellar cut
lrg_lowdens &= zfibermag < 21.72 # faint limit
lrg_lowdens &= (
(gmag - rmag > 1.34) & ((gmag - rmag) > -1.55 * (rmag - w1mag)+3.23)
| (rmag - w1mag > 1.8)
) # low-z cuts
lrg_lowdens &= (
(rmag - w1mag > (w1mag - 17.05) * 1.83)
& (rmag - w1mag > (w1mag - 16.14) * 1.)
| (rmag - w1mag > 3.49)
) # double sliding cuts and high-z extension

return lrg, lrg_lowdens
return lrg


def isELG(gflux=None, rflux=None, zflux=None, w1flux=None, w2flux=None,
Expand Down Expand Up @@ -2458,7 +2424,7 @@ def set_target_bits(photsys_north, photsys_south, obs_rflux,

# ADM initially set everything to arrays of False for LRG selection.
# ADM zeroth element stores the northern targets bits (south=False).
lrg_classes = [[tcfalse, tcfalse], [tcfalse, tcfalse]]
lrg_classes = [tcfalse, tcfalse]
if "LRG" in tcnames:
for south in south_cuts:
lrg_classes[int(south)] = isLRG(
Expand All @@ -2469,13 +2435,10 @@ def set_target_bits(photsys_north, photsys_south, obs_rflux,
gaiagmag=gaiagmag, zfibertotflux=zfibertotflux,
maskbits=maskbits, south=south
)
lrg_north, lrg_lowdens_north = lrg_classes[0]
lrg_south, lrg_lowdens_south = lrg_classes[1]
lrg_north, lrg_south = lrg_classes

# ADM combine LRG target bits for an LRG target based on any imaging.
lrg = (lrg_north & photsys_north) | (lrg_south & photsys_south)
lrg_lowdens = ((lrg_lowdens_north & photsys_north) |
(lrg_lowdens_south & photsys_south))

# ADM initially set everything to arrays of False for ELG selection.
# ADM zeroth element stores the northern targets bits (south=False).
Expand Down Expand Up @@ -2686,23 +2649,20 @@ def set_target_bits(photsys_north, photsys_south, obs_rflux,

# Construct the targetflag bits for DECaLS (i.e. South).
desi_target = lrg_south * desi_mask.LRG_SOUTH
desi_target |= lrg_lowdens_south * desi_mask.LRG_LOWDENS_SOUTH
desi_target |= elg_south * desi_mask.ELG_SOUTH
desi_target |= elg_vlo_south * desi_mask.ELG_VLO_SOUTH
desi_target |= elg_lop_south * desi_mask.ELG_LOP_SOUTH
desi_target |= qso_south * desi_mask.QSO_SOUTH

# Construct the targetflag bits for MzLS and BASS (i.e. North).
desi_target |= lrg_north * desi_mask.LRG_NORTH
desi_target |= lrg_lowdens_north * desi_mask.LRG_LOWDENS_NORTH
desi_target |= elg_north * desi_mask.ELG_NORTH
desi_target |= elg_vlo_north * desi_mask.ELG_VLO_NORTH
desi_target |= elg_lop_north * desi_mask.ELG_LOP_NORTH
desi_target |= qso_north * desi_mask.QSO_NORTH

# Construct the targetflag bits combining north and south.
desi_target |= lrg * desi_mask.LRG
desi_target |= lrg_lowdens * desi_mask.LRG_LOWDENS
desi_target |= elg * desi_mask.ELG
desi_target |= elg_vlo * desi_mask.ELG_VLO
desi_target |= elg_lop * desi_mask.ELG_LOP
Expand Down
8 changes: 4 additions & 4 deletions py/desitarget/test/test_cuts.py
Expand Up @@ -153,13 +153,13 @@ def test_single_cuts(self):

# ADM check for both defined fiberflux and fiberflux of None.
for ff in zfiberflux, None:
lrg1, _ = cuts.isLRG(primary=primary, gflux=gflux, rflux=rflux,
lrg1 = cuts.isLRG(primary=primary, gflux=gflux, rflux=rflux,
zflux=zflux, w1flux=w1flux, zfiberflux=ff,
gnobs=gnobs, rnobs=rnobs, znobs=znobs,
maskbits=maskbits, rfluxivar=rfluxivar,
zfluxivar=zfluxivar, w1fluxivar=w1fluxivar,
gaiagmag=gaiagmag, zfibertotflux=zfibertotflux)
lrg2, _ = cuts.isLRG(primary=None, gflux=gflux, rflux=rflux,
lrg2 = cuts.isLRG(primary=None, gflux=gflux, rflux=rflux,
zflux=zflux, w1flux=w1flux, zfiberflux=ff,
gnobs=gnobs, rnobs=rnobs, znobs=znobs,
maskbits=maskbits, rfluxivar=rfluxivar,
Expand All @@ -170,10 +170,10 @@ def test_single_cuts(self):

# ADM check color selections alone work. Tripped us up once
# ADM when the mocks called a missing isLRG_colors function.
lrg1, _ = cuts.isLRG_colors(primary=primary, gflux=gflux,
lrg1 = cuts.isLRG_colors(primary=primary, gflux=gflux,
rflux=rflux, zflux=zflux, zfiberflux=ff,
w1flux=w1flux, w2flux=w2flux)
lrg2, _ = cuts.isLRG_colors(primary=None, gflux=gflux, rflux=rflux,
lrg2 = cuts.isLRG_colors(primary=None, gflux=gflux, rflux=rflux,
zflux=zflux, zfiberflux=ff,
w1flux=w1flux, w2flux=w2flux)
self.assertTrue(np.all(lrg1 == lrg2))
Expand Down

0 comments on commit 05db498

Please sign in to comment.