From e43de3cb79a9fad846babf0ddfdca21622b903dc Mon Sep 17 00:00:00 2001 From: Blaise Thompson Date: Sun, 8 Apr 2018 18:01:07 -0500 Subject: 2018-04-08 18:01 --- processing/chapter.tex | 79 ++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 76 insertions(+), 3 deletions(-) (limited to 'processing/chapter.tex') diff --git a/processing/chapter.tex b/processing/chapter.tex index e430e1d..1ec2c37 100644 --- a/processing/chapter.tex +++ b/processing/chapter.tex @@ -1004,12 +1004,83 @@ Guess... Can be used directly... +[USERS CAN WRITE THEIR OWN FUNCTION OBJECTS] + +\begin{figure} + \includegraphics[width=0.5\textwidth]{"processing/fit_function"} + \includepython{"processing/fit_function.py"} + \caption[CAPTION TODO]{ + CAPTION TODO + } +\end{figure} + \subsection{Fitter} % ---------------------------------------------------------------------------- -Loops through... -Returns model and outs... +The Fitter class is specially made to work seamlessly with data objects. % + +WrightTools is especially good at dimensionality reduction through fitting. % +This concept is best demonstrated through an example. % + +Let’s load in some test data. % +\begin{codefragment}{python} +#import +import WrightTools as wt +from WrightTools import datasets +# create +ps = datasets.COLORS.v2p1_MoS2_TrEE_movie +data = wt.data.from_COLORS(ps) +# cleanup +data.level('ai0', 'd2', -3) +data.scale() +data.convert('eV') +data.name = 'MoS2' +\end{codefragment} +This is a three-dimensional dataset: % +\begin{codefragment}{python} +>>> data.axis_names +['w2', 'w1', 'd2'] +>>> data.shape +(41, 41, 23) +\end{codefragment} +We could create an animation to see every single pixel, but we can't see everything at once that +way. % +Instead we could imagine fitting every decay ($\tau_{21}$ trace) to an exponential. % +Then we could plot the amplitude and time constant of that exponential decay. % +This helps us get at subtle questions about the data. % +Do the lineshapes narrow with time? Does the redder feature decay slower than the bluer feature? % +Faster? % + +Using the \python{Fitter} class, it is easy to perform an exponential fit along each TAU21 trace at +each OMEGA1, OMEGA2 coordinate. % +\begin{codefragment}{python} +# isolate only relevant data +data = data.split('w1', 1.75)[1].split('d2', 0)[0] +# prepare a function +function = wt.fit.Exponential() +function.limits['amplitude'] = [0, 1] +function.limits['offset'] = [0, 0] +function.limits['tau'] = [0, 2000] +# do the fit +fitter = wt.fit.Fitter(function, data, 'd2') +outs = fitter.run() +\end{codefragment} +When we call fitter.run(), every slice of the data object will be fit according to the given +function object. Fitter automatically creates two new data objects when this happens. outs contains +the fit parameters, in this case amplitude, tau, and offset. Accordingly, outs is lower-dimensional +than the original data object. model contains the fit evaluated at each coordinate of the original +dataset—it’s really useful for inspecting the quality of your fit procedure. + +[ALSO GOOD FOR WORKUP OF TUNING DATA: SEE SECTION ...] + +\begin{figure} + \includegraphics[width=0.4\textwidth]{"processing/fit_amplitude"} + \includegraphics[width=0.4\textwidth]{"processing/fit_tau"} + \caption[CAPTION TODO]{ + CAPTION TODO + } + \label{pro:fig:fitted_movie} +\end{figure} -\clearpage \section{Construction, maintenance, and distribution} % ========================================== While WrightTools has already been useful to the work done in the WrightGroup over the last 3 @@ -1098,6 +1169,8 @@ WrightTools uses semantic versioning. % Git... +As of 2018-04-08, WrightTools has ........ commits from ..... developers + \subsection{Unit tests} % ------------------------------------------------------------------------ Unit testing... -- cgit v1.2.3