Skip to content

Commit 3ff4875

Browse files
Changed interpolation to regression
1 parent 0869a6c commit 3ff4875

File tree

3 files changed

+13
-13
lines changed

3 files changed

+13
-13
lines changed

spectrometer/CCDpanelsetup.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -567,7 +567,7 @@ def updateplot(self, CCDplot):
567567
# Update spectrum background
568568
self.CCDplot.set_show_colors(self.show_colors.get())
569569

570-
# If interpolation toggle is active, compute and plot interpolated curve
570+
# If regression toggle is active, compute and plot interpolated curve
571571
try:
572572
if getattr(self, "ph_checkbox_var", None) and self.ph_checkbox_var.get() == 1:
573573
# Use the same data that was plotted (data variable)
@@ -601,7 +601,7 @@ def updateplot(self, CCDplot):
601601
# Plot interpolated curve as a distinct coloured line
602602
CCDplot.a.plot(xs_plot, ys_interp, color="red", lw=0.9, alpha=0.9, label="interpolated")
603603
except Exception:
604-
# don't let interpolation failures break the plotting
604+
# don't let regression failures break the plotting
605605
pass
606606

607607
CCDplot.canvas.draw()
@@ -832,14 +832,14 @@ def saveopenfields(self, save_row, CCDplot):
832832
self.ph_checkbox_var = tk.IntVar(value=0)
833833
self.ph_check = ttk.Checkbutton(
834834
self,
835-
text="Toggle interpolation",
835+
text="Toggle regression",
836836
variable=self.ph_checkbox_var,
837837
onvalue=1,
838838
offvalue=0,
839839
)
840840
self.ph_check.grid(column=1, row=save_row + 2, sticky="w", padx=5)
841841
# Trace the checkbox so we can enable/disable the slider dynamically
842-
# Also trigger a plot update so the interpolation overlay appears immediately
842+
# Also trigger a plot update so the regression overlay appears immediately
843843
self.ph_checkbox_var.trace_add(
844844
"write",
845845
lambda *args, CCDplot=CCDplot: (self._ph_check_changed(), self.updateplot(CCDplot)),
@@ -913,7 +913,7 @@ def _phslider_callback(self, val):
913913
except Exception:
914914
# fallback to integer display
915915
self.ph_label.config(text=str(int(round(v))))
916-
# If interpolation is enabled, update the plot so changes take effect immediately
916+
# If regression is enabled, update the plot so changes take effect immediately
917917
try:
918918
if getattr(self, "ph_checkbox_var", None) and self.ph_checkbox_var.get() == 1:
919919
try:

spectrometer/spectrum_gradient.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ def add_spectrum_gradient(ax, x_min, x_max, y_min, y_max):
7474
extent=(x_min, x_max, y_min, y_max),
7575
origin="lower",
7676
aspect="auto",
77-
interpolation="bilinear",
77+
regression="bilinear",
7878
alpha=0.6,
7979
zorder=-1,
8080
)

utils/plotgraph.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@
1616
1717
Files created inside that folder:
1818
- <prefix>_Ipixel.csv (pixel, ADC, Ipixel)
19-
- <prefix>_interpolated_sample.csv (high-res sampled interpolation)
20-
- <prefix>_plot.png (ADC + Ipixel plot with interpolation overlay)
19+
- <prefix>_interpolated_sample.csv (high-res sampled regression)
20+
- <prefix>_plot.png (ADC + Ipixel plot with regression overlay)
2121
- <prefix>_interpolator.pkl (pickled interpolator object, optional)
2222
2323
Usage:
@@ -162,14 +162,14 @@ def format_ctime_for_name(path: Path) -> str:
162162
return dt.strftime("%Y%m%d_%H%M%S")
163163

164164
def main():
165-
parser = argparse.ArgumentParser(description="Open a .dat file via dialog and produce intensity + interpolation outputs in a new timestamped folder.")
165+
parser = argparse.ArgumentParser(description="Open a .dat file via dialog and produce intensity + regression outputs in a new timestamped folder.")
166166
parser.add_argument("infile", nargs="?", default=None, help="optional path to .dat file (if omitted, a file dialog will open)")
167-
parser.add_argument("--interp", choices=["spline","cubic","linear"], default="spline", help="interpolation method for overlay and sampled CSV")
167+
parser.add_argument("--interp", choices=["spline","cubic","linear"], default="spline", help="regression method for overlay and sampled CSV")
168168
parser.add_argument("--dark-method", choices=["median","mean"], default="median", help="how to estimate ADC_dark")
169169
parser.add_argument("--samples", type=int, default=10000, help="number of points to sample the interpolated function")
170170
parser.add_argument("--smooth", type=float, default=0.2, help="smoothing multiplier for spline (larger -> smoother). Default 0.2")
171171
# Default smooths: keep only the weaker values (remove 0.1 and 0.2 as requested)
172-
parser.add_argument("--smooths", type=str, default="0.01,0.02,0.05", help="comma-separated list of smoothing multipliers to plot multiple interpolations (e.g. '0.01,0.02,0.05')")
172+
parser.add_argument("--smooths", type=str, default="0.01,0.02,0.05", help="comma-separated list of smoothing multipliers to plot multiple regressions (e.g. '0.01,0.02,0.05')")
173173
parser.add_argument("--linewidth", type=float, default=0.6, help="default line width for PNG output (thin lines)")
174174
args = parser.parse_args()
175175

@@ -225,7 +225,7 @@ def main():
225225
# Prepare sampling grid
226226
xs = np.linspace(pixels.min(), pixels.max(), max(1000, args.samples))
227227

228-
# Parse multi-smoothing values for plotting several interpolation strengths
228+
# Parse multi-smoothing values for plotting several regression strengths
229229
try:
230230
smooth_values = [float(s.strip()) for s in str(args.smooths).split(",") if s.strip()]
231231
except Exception:
@@ -263,7 +263,7 @@ def main():
263263
ax1.grid(True, alpha=0.3)
264264

265265
# Bottom: interpolated / smoothed (separate plot). Plot multiple curves with different smoothing strengths.
266-
# Plot a very faint original Ipixel trace in the interpolation panel for reference
266+
# Plot a very faint original Ipixel trace in the regression panel for reference
267267
orig_on_xs = np.interp(xs, pixels, intensities)
268268
# Slightly more visible raw trace for reference
269269
ax2.plot(xs, orig_on_xs, color="gray", lw=0.8, alpha=0.28, label="raw Ipixel (faint)")

0 commit comments

Comments
 (0)