Skip to content
Snippets Groups Projects

Use knife edge base in routine function

Merged Laurent Mercadier requested to merge use-knife-edge-base into knife-edge-base
2 unresolved threads

Merge request reports

Loading
Loading

Activity

Filter activity
  • Approvals
  • Assignees & reviewers
  • Comments (from bots)
  • Comments (from users)
  • Commits & branches
  • Edits
  • Labels
  • Lock status
  • Mentions
  • Merge request status
  • Tracking
  • 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 the erfc function, which are not accessible (not in __all__). So we would end up re-doing all the steps done in knife_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
    • Ah, this specific import of functions is what I was missing. I thought it was not possible with the packaging structure. I'll give it a try. thanks

    • Please register or sign in to reply
  • added 1 commit

    • db6cc48f - better use of base knife-edge functions

    Compare with previous version

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)
  • added 1 commit

    • 71fbc4f8 - Define base function arrays_to1d, use same code whether plotting or not

    Compare with previous version

  • LGTM, thanks for integrating the base functions :)

  • Thanks for the reviews, merging

  • mentioned in commit 87b28ade

  • Please register or sign in to reply
    Loading