Use knife edge base in routine function
Merge request reports
Activity
I don't find it straightforward to use the base implementation in the original function.
The problem is that it is not easy to fully decouple the plotting from the actual calculations, because we want to plot the arrays returned by
prepare_arrays
, and theerfc
function, which are not accessible (not in__all__
). So we would end up re-doing all the steps done inknife_edge_base
to be able to plot.I'd be glad to have some suggestions.
Please feel free to put more functions in
__all__
:) I would suggest that candidates for__all__
functions are the frequent used functions (by the users), that's why I only put the two knife edge implementations as starters.We could also import the needed functions explicitly:
from toolbox_scs.base.knife_edge import erfc, prepare_arrays
Edited by Cammille Carinan
117 label='exp', s=2, alpha=0.1) 118 if fitSuccess: 119 xfit = np.linspace(positions.min(), positions.max(), 1000) 120 yfit = func(xfit, *popt) 121 plt.plot(xfit, yfit, color='C4', 122 label=r'fit $\rightarrow$ $w_0=$(%.1f $\pm$ %.1f) $\mu$m' % ( 123 popt[1]*1e3, pcov[1, 1]**0.5*1e3)) 124 leg = plt.legend() 125 for lh in leg.legendHandles: 126 lh.set_alpha(1) 127 plt.ylabel(signalKey) 128 plt.xlabel(axisKey + ' position [mm]') 129 plt.title(ds.attrs['runFolder']) 130 plt.tight_layout() 70 # Fit 71 popt, pcov = function_fit(erfc, positions, intensities, p0=p0) changed this line in version 3 of the diff
@lleguy @carinanc how about now? using
prepare_arrays
doesn't work because it restricts the arrays to the input range, but we want to plot all the data points.Edited by Laurent Mercadier
added 1 commit
- 71fbc4f8 - Define base function arrays_to1d, use same code whether plotting or not
mentioned in commit 87b28ade