Skip to content

Commit

Permalink
Merge pull request #2105 from desihub/polyfit_fix
Browse files Browse the repository at this point in the history
fix incorrect use of polyfit
  • Loading branch information
julienguy authored Aug 29, 2023
2 parents bf216b2 + a4b13f2 commit b98b567
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
3 changes: 2 additions & 1 deletion py/desispec/qproc/qfiberflat.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,8 @@ def qproc_compute_fiberflat(qframe,niter_meanspec=4,nsig_clipping=3.,spline_res_
if iteration>0 :
for i in range(tflux.shape[0]) :
jj=(mflux>0)&(tivar[i]>0)
c = np.polyfit(x[jj],tflux[i,jj]/mflux[jj],1,w=mflux[jj]**2*tivar[i,jj])
c = np.polyfit(x[jj], tflux[i, jj] / mflux[jj], 1,
w=mflux[jj] * np.sqrt(tivar[i, jj]))
pol[i] = np.poly1d(c)(x)
mflux=np.median(pol*tflux,axis=0)

Expand Down
4 changes: 2 additions & 2 deletions py/desispec/trace_shifts.py
Original file line number Diff line number Diff line change
Expand Up @@ -566,7 +566,7 @@ def compute_dx_from_cross_dispersion_profiles(xcoef,ycoef,wavemin,wavemax, image
break

try :
c = np.polyfit(fy,fdx,deg,w=1/fex**2)
c = np.polyfit(fy, fdx, deg, w=1. / fex)
pol = np.poly1d(c)
chi2 = (fdx-pol(fy))**2/fex**2
mchi2 = 2*np.median(chi2)
Expand Down Expand Up @@ -756,7 +756,7 @@ def shift_ycoef_using_external_spectrum(psf,xytraceset,image,fibers,spectrum_fil

log.info("polynomial fit of shifts and modification of PSF ycoef")
# pol fit
coef = np.polyfit(wave_for_dy,dy,degyy,w=1./ey**2)
coef = np.polyfit(wave_for_dy, dy, degyy, w=1. / ey)
pol = np.poly1d(coef)

for i in range(dy.size) :
Expand Down

0 comments on commit b98b567

Please sign in to comment.