From 32732990ac1df51597600e90eff5ee58719130bf Mon Sep 17 00:00:00 2001 From: John Moustakas Date: Thu, 7 Sep 2017 14:17:57 -0400 Subject: [PATCH 1/7] updated colorcuts_function documentation --- py/desisim/templates.py | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/py/desisim/templates.py b/py/desisim/templates.py index 5360bcf6a..7d8cbfbe2 100755 --- a/py/desisim/templates.py +++ b/py/desisim/templates.py @@ -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'). @@ -709,6 +712,8 @@ 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: + import pdb ; pdb.set_trace() + colormask = self.colorcuts_function( gflux=synthnano['decam2014-g'], rflux=synthnano['decam2014-r'], @@ -869,11 +874,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, From 89d966cf0b38efb42d16670ad0fdf919cad04682 Mon Sep 17 00:00:00 2001 From: John Moustakas Date: Thu, 7 Sep 2017 21:36:45 -0400 Subject: [PATCH 2/7] allow colorcuts_function to be a tuple --- py/desisim/templates.py | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/py/desisim/templates.py b/py/desisim/templates.py index 7d8cbfbe2..c55401d03 100755 --- a/py/desisim/templates.py +++ b/py/desisim/templates.py @@ -712,14 +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: - import pdb ; pdb.set_trace() - - 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 type(self.colorcuts_function) == tuple: + _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 From aa289ca03ca662b8c590a63da95ef3acab0c2492 Mon Sep 17 00:00:00 2001 From: John Moustakas Date: Thu, 7 Sep 2017 21:55:45 -0400 Subject: [PATCH 3/7] update changes.rst [ci skip] --- doc/changes.rst | 3 +++ 1 file changed, 3 insertions(+) diff --git a/doc/changes.rst b/doc/changes.rst index 99938b0b2..7bc532a6c 100644 --- a/doc/changes.rst +++ b/doc/changes.rst @@ -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) ------------------- From 3bf69381d165d7dcf616953d14c362be537f30f4 Mon Sep 17 00:00:00 2001 From: Stephen Bailey Date: Mon, 11 Sep 2017 16:41:28 -0700 Subject: [PATCH 4/7] isinstance to check list or tuple --- py/desisim/templates.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/py/desisim/templates.py b/py/desisim/templates.py index c55401d03..b0998e06c 100755 --- a/py/desisim/templates.py +++ b/py/desisim/templates.py @@ -712,7 +712,7 @@ 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: - if type(self.colorcuts_function) == tuple: + if isinstance(self.colorcuts_function, (tuple, list)): _colormask = [] for cf in self.colorcuts_function: _colormask.append(cf( From 670626c1db01879ff276c93d2214d7186503347b Mon Sep 17 00:00:00 2001 From: Benjamin Alan Weaver Date: Mon, 11 Sep 2017 18:28:27 -0700 Subject: [PATCH 5/7] try simple change to fix sphinx build problem --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 861167f5d..fdba3360d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -41,7 +41,7 @@ env: # to repeat them for all configurations. # - NUMPY_VERSION=1.10 # - SCIPY_VERSION=0.16 - - ASTROPY_VERSION=1.3.3 + # - ASTROPY_VERSION=1.3.3 # - SPHINX_VERSION=1.3 # - DESIUTIL_VERSION=1.8.0 - DESIUTIL_VERSION=1.9.4 From 97e97bc0673bf7863b6ef8cd394877e193df3049 Mon Sep 17 00:00:00 2001 From: Benjamin Alan Weaver Date: Mon, 11 Sep 2017 18:50:10 -0700 Subject: [PATCH 6/7] try chaniging sphinx version --- .travis.yml | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index fdba3360d..984553a4f 100644 --- a/.travis.yml +++ b/.travis.yml @@ -41,8 +41,8 @@ env: # to repeat them for all configurations. # - NUMPY_VERSION=1.10 # - SCIPY_VERSION=0.16 - # - ASTROPY_VERSION=1.3.3 - # - SPHINX_VERSION=1.3 + - ASTROPY_VERSION=1.3.3 + - SPHINX_VERSION=1.5 # - DESIUTIL_VERSION=1.8.0 - DESIUTIL_VERSION=1.9.4 # - DESIMODEL_VERSION=0.7.0 @@ -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 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. @@ -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 From a78519d39826f8be86422e312f625363c575a3e0 Mon Sep 17 00:00:00 2001 From: Benjamin Alan Weaver Date: Mon, 11 Sep 2017 19:11:01 -0700 Subject: [PATCH 7/7] install pyyaml --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 984553a4f..0f6168574 100644 --- a/.travis.yml +++ b/.travis.yml @@ -61,7 +61,7 @@ env: # These packages will always be installed. - CONDA_DEPENDENCIES="scipy pyyaml" # These packages will only be installed for documentation builds. - - CONDA_SPHINX_DEPENDENCIES="scipy sphinx==1.5" + - 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.