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

DM-42592: Remove np.poly1d #29

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
11 changes: 6 additions & 5 deletions python/lsst/summit/extras/focusAnalysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
from dataclasses import dataclass

import numpy as np
from numpy.polynomial import Polynomial
from scipy.optimize import curve_fit
from scipy.linalg import norm

Expand Down Expand Up @@ -344,7 +345,7 @@ def fitDataAndPlot(self, hideFit=False, hexapodZeroPoint=0):

quadFitPars = np.polyfit(focusPositions, widths, 2)
if not hideFit:
axes[1].plot(fineXs, np.poly1d(quadFitPars)(fineXs), c=self.COLORS[spectrumSlice])
axes[1].plot(fineXs, Polynomial(quadFitPars)(fineXs), c=self.COLORS[spectrumSlice])
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Polynomial and poly1d have reversed order of coefficients, so I don't think this would work (but I don't know the origin of quadFitPars etc). See https://numpy.org/doc/stable/reference/routines.polynomials.html#transition-guide

fitMin = -quadFitPars[1] / (2.0*quadFitPars[0])
bestFits.append(fitMin)
axes[1].axvline(fitMin, color=self.COLORS[spectrumSlice])
Expand Down Expand Up @@ -561,7 +562,7 @@ def fitDataAndPlot(self):
ax0 = plt.subplot(gs[0])
ax0.scatter(focusPositions, widths, c='k')
ax0.set_ylabel('FWHM (arcsec)', fontsize=labelFontSize)
ax0.plot(fineXs, np.poly1d(fwhmFitPars)(fineXs), 'b-')
ax0.plot(fineXs, Polynomial(fwhmFitPars)(fineXs), 'b-')
ax0.axvline(fwhmFitMin, c='r', ls='--')

ee90s = [fitData[seqNum]['eeRadius90'] for seqNum in seqNums]
Expand All @@ -579,9 +580,9 @@ def fitDataAndPlot(self):
ee50FitPars = np.polyfit(focusPositions, ee50s, 2)
ee50FitMin = -ee50FitPars[1] / (2.0*ee50FitPars[0])

ax1.plot(fineXs, np.poly1d(ee90FitPars)(fineXs), 'r-')
ax1.plot(fineXs, np.poly1d(ee80FitPars)(fineXs), 'g-')
ax1.plot(fineXs, np.poly1d(ee50FitPars)(fineXs), 'b-')
ax1.plot(fineXs, Polynomial(ee90FitPars)(fineXs), 'r-')
ax1.plot(fineXs, Polynomial(ee80FitPars)(fineXs), 'g-')
ax1.plot(fineXs, Polynomial(ee50FitPars)(fineXs), 'b-')

ax1.axvline(ee90FitMin, c='r', ls='--')
ax1.axvline(ee80FitMin, c='g', ls='--')
Expand Down
Loading