Skip to content

Commit

Permalink
getting closer
Browse files Browse the repository at this point in the history
  • Loading branch information
lastephey committed Jun 20, 2018
1 parent 65b42be commit 6c03a26
Showing 1 changed file with 16 additions and 9 deletions.
25 changes: 16 additions & 9 deletions py/specter/extract/ex2d.py
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,13 @@ def ex2d(image, imageivar, psf, specmin, nspec, wavelengths, xyrange=None,
wmin, wmax = ww[0], ww[-1]
nw = len(ww)

#for now let's assume we want the cached version, fix later!
####################################33
iwave_cache = np.arange(nw)
#iwave_cache = None
#print("iwave_cache is")
#print(iwave_cache)

#- include \r carriage return to prevent scrolling
if verbose:
sys.stdout.write("\rSpectra {specrange} wavelengths ({wmin:.2f}, {wmax:.2f}) -> ({wlo:.2f}, {whi:.2f})".format(\
Expand All @@ -161,7 +168,7 @@ def ex2d(image, imageivar, psf, specmin, nspec, wavelengths, xyrange=None,
ex2d_patch(subimg, subivar, psf,
specmin=speclo, nspec=spechi-speclo, wavelengths=ww,
xyrange=[xlo,xhi,ylo,yhi], regularize=regularize, ndecorr=ndecorr,
full_output=True)
full_output=True, iwave_cache=iwave_cache)

specflux = results['flux']
specivar = results['ivar']
Expand Down Expand Up @@ -246,7 +253,7 @@ def ex2d(image, imageivar, psf, specmin, nspec, wavelengths, xyrange=None,


def ex2d_patch(image, ivar, psf, specmin, nspec, wavelengths, xyrange=None,
full_output=False, regularize=0.0, ndecorr=False):
full_output=False, regularize=0.0, ndecorr=False, iwave_cache=None):
"""
2D PSF extraction of flux from image patch given pixel inverse variance.
Expand Down Expand Up @@ -292,14 +299,8 @@ def ex2d_patch(image, ivar, psf, specmin, nspec, wavelengths, xyrange=None,
#print(nwave)
#- Solve AT W pix = (AT W A)flux

#for now let's assume we want the cached version, fix later!
####################################33
iwave_cache = np.arange(nwave)
#print("iwave_cache is")
#print(iwave_cache)

#- Projection matrix and inverse covariance
A = psf.projection_matrix(specrange, wavelengths, xyrange)
A = psf.projection_matrix(specrange, wavelengths, xyrange, iwave_cache=iwave_cache)

#- Pixel weights matrix
w = ivar.ravel()
Expand Down Expand Up @@ -401,6 +402,9 @@ def cache_params(psf, spec_range, wavelengths):
psf.tailcore_cache = legval_cache(psf, psf.coeff['TAILCORE'], spec_range, wavelengths)
psf.tailinde_cache = legval_cache(psf, psf.coeff['TAILINDE'], spec_range, wavelengths)

#print("psf.x_cache.shape")
#print(psf.x_cache.shape)

#modified version of eval in specter/traceset that can handle
#multiple spectra hopefully?
def legval_cache(psf, traceset, spec_range, wavelengths):
Expand Down Expand Up @@ -430,6 +434,9 @@ def legval_cache(psf, traceset, spec_range, wavelengths):
for i in ispec:
y[i,:]=legval_numba(xx, cc_numba[i])


#print("y.shape")
#print(y.shape)
return y


Expand Down

0 comments on commit 6c03a26

Please sign in to comment.