From 1246602288b77daefa16b225db83a4505f0d9fa0 Mon Sep 17 00:00:00 2001 From: Stephen Bailey Date: Tue, 14 Apr 2015 23:28:38 -0700 Subject: [PATCH 1/3] replace deprecated resolution_data_to_spare_matrix_this_is_too_long with Resolution --- py/desispec/fluxcalibration.py | 12 ++++++------ py/desispec/sky.py | 10 +++++----- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/py/desispec/fluxcalibration.py b/py/desispec/fluxcalibration.py index 32ce92d24..11d56628b 100644 --- a/py/desispec/fluxcalibration.py +++ b/py/desispec/fluxcalibration.py @@ -5,7 +5,7 @@ import numpy as np -from desispec.io.frame import resolution_data_to_sparse_matrix +from desispec.resolution import Resolution from desispec.linalg import cholesky_solve from desispec.linalg import cholesky_solve_and_invert from desispec.linalg import spline_fit @@ -234,7 +234,7 @@ def compute_flux_calibration(wave,flux,ivar,resolution_data,input_model_wave,inp # pylab.plot(input_model_wave,input_model_flux[fiber]) # pylab.plot(wave,model_flux[fiber],c="g") - R = resolution_data_to_sparse_matrix(resolution_data,fiber) + R = Resolution(resolution_data[fiber]) model_flux[fiber]=R.dot(model_flux[fiber]) # debug @@ -269,7 +269,7 @@ def compute_flux_calibration(wave,flux,ivar,resolution_data,input_model_wave,inp for fiber in range(nfibers) : if fiber%10==0 : log.info("iter %d fiber %d"%(iteration,fiber)) - R = resolution_data_to_sparse_matrix(resolution_data,fiber) + R = Resolution(resolution_data[fiber]) # diagonal sparse matrix with content = sqrt(ivar)*flat SD.setdiag(sqrtwmodel[fiber]) @@ -293,7 +293,7 @@ def compute_flux_calibration(wave,flux,ivar,resolution_data,input_model_wave,inp if fiber%10==0 : log.info("iter %d fiber %d(smooth)"%(iteration,fiber)) - R = resolution_data_to_sparse_matrix(resolution_data,fiber) + R = Resolution(resolution_data[fiber]) #M = np.array(np.dot(R.todense(),mean_spectrum)).flatten() M = R.dot(calibration)*model_flux[fiber] @@ -378,7 +378,7 @@ def compute_flux_calibration(wave,flux,ivar,resolution_data,input_model_wave,inp # we also want to save the convolved calibration and calibration variance # first compute average resolution mean_res_data=np.mean(resolution_data,axis=0) - R = resolution_data_to_sparse_matrix(mean_res_data,0) + R = Resolution(mean_res_data) # compute convolved calib and ivar ccalibration=R.dot(calibration) ccalibcovar=R.dot(calibcovar).dot(R.T.todense()) @@ -410,7 +410,7 @@ def apply_flux_calibration(flux,ivar,resolution_data,wave,calibration,civar,cmas for fiber in range(nfibers) : - R = resolution_data_to_sparse_matrix(resolution_data,fiber) + R = Resolution(resolution_data[fiber]) C = R.dot(calibration) """ diff --git a/py/desispec/sky.py b/py/desispec/sky.py index 0684c6d25..553a94d18 100644 --- a/py/desispec/sky.py +++ b/py/desispec/sky.py @@ -4,7 +4,7 @@ import numpy as np -from desispec.io.frame import resolution_data_to_sparse_matrix +from desispec.resolution import Resolution from desispec.linalg import cholesky_solve from desispec.linalg import cholesky_solve_and_invert from desispec.linalg import spline_fit @@ -57,7 +57,7 @@ def compute_sky(wave,flux,ivar,resolution_data,nsig_clipping=4.) : for fiber in range(nfibers) : if fiber%10==0 : log.info("iter %d fiber %d"%(iteration,fiber)) - R = resolution_data_to_sparse_matrix(resolution_data,fiber) + R = Resolution(resolution_data[fiber]) # diagonal sparse matrix with content = sqrt(ivar) SD.setdiag(sqrtw[fiber]) @@ -75,7 +75,7 @@ def compute_sky(wave,flux,ivar,resolution_data,nsig_clipping=4.) : for fiber in range(nfibers) : - R = resolution_data_to_sparse_matrix(resolution_data,fiber) + R = Resolution(resolution_data[fiber]) S = R.dot(skyflux) chi2[fiber]=current_ivar[fiber]*(flux[fiber]-S)**2 @@ -129,7 +129,7 @@ def compute_sky(wave,flux,ivar,resolution_data,nsig_clipping=4.) : # first compute average resolution mean_res_data=np.mean(resolution_data,axis=0) - R = resolution_data_to_sparse_matrix(mean_res_data,0) + R = Resolution(mean_res_data) # compute convolved sky and ivar cskyflux=R.dot(skyflux) cskycovar=R.dot(skycovar).dot(R.T.todense()) @@ -165,7 +165,7 @@ def subtract_sky(flux,ivar,resolution_data,wave,skyflux,convolved_skyivar,skymas #if fiber%10==0 : # log.info("fiber %d"%fiber) - R = resolution_data_to_sparse_matrix(resolution_data,fiber) + R = Resolution(resolution_data[fiber]) S = R.dot(skyflux) flux[fiber] -= S From 1ebf9edefef3382ba45c8fe4a35262febe1c65da Mon Sep 17 00:00:00 2001 From: Stephen Bailey Date: Tue, 14 Apr 2015 23:29:06 -0700 Subject: [PATCH 2/3] more printouts while copying --- bin/copyprod.py | 1 + 1 file changed, 1 insertion(+) diff --git a/bin/copyprod.py b/bin/copyprod.py index 84ea5015f..6afa19b2a 100755 --- a/bin/copyprod.py +++ b/bin/copyprod.py @@ -28,6 +28,7 @@ #- Copy exposures for indir, subdirs, filenames in os.walk(inroot+'/exposures'): outdir = indir.replace(inroot, outroot) + print outdir if not os.path.exists(outdir): os.makedirs(outdir) From d4f9134056dfa44e021d3ff52633a31fdd4ad5d0 Mon Sep 17 00:00:00 2001 From: Stephen Bailey Date: Thu, 16 Apr 2015 02:19:59 -0700 Subject: [PATCH 3/3] zfind cleanup --- bin/desi_zfind.py | 2 +- py/desispec/zfind.py | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/bin/desi_zfind.py b/bin/desi_zfind.py index 09422481f..db78da6e2 100755 --- a/bin/desi_zfind.py +++ b/bin/desi_zfind.py @@ -19,7 +19,7 @@ parser.add_option("-b", "--brick", type=str, help="input brickname") parser.add_option("-n", "--nspec", type=int, help="number of spectra to fit [default: all]") parser.add_option("-o", "--outfile", type=str, help="output file name") -parser.add_option("--zspec", help="Write a zspec file with resampled spectra used for zfind", action="store_true") +parser.add_option("--zspec", help="also include spectra in output file", action="store_true") opts, args = parser.parse_args() diff --git a/py/desispec/zfind.py b/py/desispec/zfind.py index 4ff983d9c..b963fef16 100644 --- a/py/desispec/zfind.py +++ b/py/desispec/zfind.py @@ -102,7 +102,7 @@ def __init__(self, wave, flux, ivar, R=None, dloglam=1e-4): self.nspec = nspec #- list of (templatename, zmin, zmax) to fix - self.template_dir = os.getenv('REDMONSTER_DIR')+'/templates/' + self.template_dir = os.getenv('REDMONSTER')+'/templates/' self.templates = [ ('ndArch-spEigenStar-55734.fits', -0.005, 0.005), ('ndArch-ssp_em_galaxy-v000.fits', 0.6, 1.6), @@ -211,4 +211,4 @@ def __init__(self, wave, flux, ivar, dof=None): # return wave, xwave[ii], xflux[ii], xivar[ii] - \ No newline at end of file +