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

correctly select both "bright" and "faint" BGS templates by default #257

Merged
merged 7 commits into from
Sep 12, 2017
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
5 changes: 4 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ env:
# - NUMPY_VERSION=1.10
# - SCIPY_VERSION=0.16
- ASTROPY_VERSION=1.3.3
# - SPHINX_VERSION=1.3
- SPHINX_VERSION=1.5
# - DESIUTIL_VERSION=1.8.0
- DESIUTIL_VERSION=1.9.4
# - DESIMODEL_VERSION=0.7.0
Expand All @@ -60,6 +60,8 @@ env:
- MAIN_CMD='python setup.py'
# These packages will always be installed.
- CONDA_DEPENDENCIES="scipy pyyaml"
# These packages will only be installed for documentation builds.
- CONDA_SPHINX_DEPENDENCIES="scipy pyyaml sphinx==1.5"
# These packages will only be installed if we really need them.
- CONDA_ALL_DEPENDENCIES="scipy matplotlib coverage==3.7.1 pyyaml qt=4 healpy"
# These packages will always be installed.
Expand Down Expand Up @@ -90,6 +92,7 @@ matrix:
# runs for a long time
- os: linux
env: PYTHON_VERSION=3.5 SETUP_CMD='build_sphinx --warning-is-error'
CONDA_DEPENDENCIES=$CONDA_SPHINX_DEPENDENCIES

# OPTIONAL_DEPS needed because the plot_directive in sphinx needs them
# -w is an astropy extension
Expand Down
3 changes: 3 additions & 0 deletions doc/changes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,13 @@ desisim change log
* New plots for S/N of spectra for various objects (ELG, LRG, QSO) (`PR #254`_)
* Add BGS, MWS to z_find QA
* Miscellaneous polishing in QA (velocity, clip before RMS, extend [OII] flux, S/N per Ang)
* Bug fix: correctly select both "bright" and "faint" BGS templates by default
(`PR #257`_).

.. _`PR #250`: https://github.com/desihub/desisim/pull/250
.. _`PR #252`: https://github.com/desihub/desisim/pull/252
.. _`PR #254`: https://github.com/desihub/desisim/pull/254
.. _`PR #257`: https://github.com/desihub/desisim/pull/257

0.20.0 (2017-07-12)
-------------------
Expand Down
36 changes: 24 additions & 12 deletions py/desisim/templates.py
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,10 @@ def __init__(self, objtype='ELG', minwave=3600.0, maxwave=10000.0, cdelt=0.2,
wave (numpy.ndarray): Input/output observed-frame wavelength array,
overriding the minwave, maxwave, and cdelt arguments (Angstrom).
colorcuts_function (function name): Function to use to select
templates that pass the color-cuts for the specified objtype
templates that pass the color-cuts for the specified objtype Note
that this argument can also be a tuple of more than one selection
function to apply (e.g., desitarget.cuts.isBGS_faint and
desitarget.cuts.isBGS_bright) which will be applied in sequence
(default None).
normfilter (str): normalize each spectrum to the magnitude in this
filter bandpass (default 'decam2014-r').
Expand Down Expand Up @@ -709,12 +712,23 @@ def make_galaxy_templates(self, nmodel=100, zrange=(0.6, 1.6), magrange=(21.0, 2
if nocolorcuts or self.colorcuts_function is None:
colormask = np.repeat(1, nbasechunk)
else:
colormask = self.colorcuts_function(
gflux=synthnano['decam2014-g'],
rflux=synthnano['decam2014-r'],
zflux=synthnano['decam2014-z'],
w1flux=synthnano['wise2010-W1'],
w2flux=synthnano['wise2010-W2'])
if isinstance(self.colorcuts_function, (tuple, list)):
_colormask = []
for cf in self.colorcuts_function:
_colormask.append(cf(
gflux=synthnano['decam2014-g'],
rflux=synthnano['decam2014-r'],
zflux=synthnano['decam2014-z'],
w1flux=synthnano['wise2010-W1'],
w2flux=synthnano['wise2010-W2']))
colormask = np.any( np.ma.getdata(np.vstack(_colormask)), axis=0)
else:
colormask = self.colorcuts_function(
gflux=synthnano['decam2014-g'],
rflux=synthnano['decam2014-r'],
zflux=synthnano['decam2014-z'],
w1flux=synthnano['wise2010-W1'],
w2flux=synthnano['wise2010-W2'])

# If the color-cuts pass then populate the output flux vector
# (suitably normalized) and metadata table, convolve with the
Expand Down Expand Up @@ -869,11 +883,9 @@ def __init__(self, minwave=3600.0, maxwave=10000.0, cdelt=0.2, wave=None,

"""
if colorcuts_function is None:
try:
from desitarget.cuts import isBGS_bright as colorcuts_function
except:
from desitarget.cuts import isBGS as colorcuts_function
log.warning('You are using on old version of desitarget')
from desitarget.cuts import isBGS_bright
from desitarget.cuts import isBGS_faint
colorcuts_function = (isBGS_bright, isBGS_faint)

super(BGS, self).__init__(objtype='BGS', minwave=minwave, maxwave=maxwave,
cdelt=cdelt, wave=wave, colorcuts_function=colorcuts_function,
Expand Down