ADR: Analysis
#173
henrikjacobsenfys
started this conversation in
Ideas
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
General
The
Analysisclass is where fitting takes place. It was discussed in easyscience/dynamics#5This ADR records the current implementation
Current implementation
There are three
Analysisclasses:AnalysisBase,Analysis1dandAnalysis. The base class handles all shared logic, of course.Analysis1dhas aQ_indexproperty, and will work with data (intensity with variances as function of energy) for that singleQ_index. TheAnalysisclass contains a list ofAnalysis1dobjects; one for eachQ_indexin the underlying experimental data.AnalysisBaseAnalysisBaseinherits fromModelBase.It takes the following input:
display_nameandunique_nameexperiment: An EasyDynamicsExperimentobject, which contains a scipp DataArray with coordinatesenergyandQ. TheQfrom theExperimentwill be used as the trueQ(e.g. the one that theAnalysisgetters will refer to)sample_model: An EasyDynamicsSampleModelobject, which contains aComponentCollectionfor eachQ_indexinstrument_model: An EasyDynamicsInstrumentModelobject, which contains an optionalResolutionModelandBackgroundModel(similar to theSampleModel), and a list ofenergy_offsetParameters, one for eachQ.convolution_settings`: settings for the convolution class to improve accuracy.It contains setters and getters for all these models.
Analysis1dIt also takes the following two inputs:
a
Q_index, which selects a particularQof the data and all the attached models.extra_parameters: AParameteror a list ofParameter, which the user can define as they please. I do not know exactly how users will use this, but they may, for example, decide that the widths of the Lorentzians in their model should be dependentParameters with some custom dependency on anotherParameter. Most users will not touch it, but it's there to allow flexibility for advanced users.Other methods:
get_all_variables(): gets all the variables of the relevant models atself._Q_index, all sharedParameters like the temperature of theSampleModeland anyParameters fromDiffusionModels. And of course the extraParameters that users can pass to itcalculate: Calculate the scattering atself._Q_index. Includes checks and may regenerate theConvolutionobject if needed_calculate: do the actual calculation with minimal checks for speed for thefit: uses the EasyScienceFitterto fit the data at the givenQ_indexcalculate_individual_component: calculates individual components including resolution abd background contributions forplot_data_and_model_create_convolvermethod, which creates a EasyDynamicsConvolutionobject for a givenQ_index, which handles the convolution of the sampleComponentCollectionwith the instrument resolutionComponentCollectionAnalysisContains a list of
Analysis1dobjects and the following primary methods:fit: fits the data with various settings, calling various sub-functions, such as_fit_single_Q: calls the relevantAnalysis1d._fit_all_Q_independently: calls all the relevantAnalysis1dobjects one after the other_fit_all_Q_simultaneously: This is the fun one! It passes all theAnalysis1dobjects and the correct fit functions to do what the name implies, allowing fits of full diffusion modelsplot_data_and_model: uses a Scipp Dataset and plopp to make slicers and other types of plots easilyplot_fit_parameter: plot e.g. the width of one (or more) of the Lorentzians.parameters_to_dataset: extract the value and vaariance of all parameters and create a scipp Dataset to hold themExtensions:
For the fitting I also want utility such as:
Q_index, then copy the values of the fit to the other ones to have better start guessesQindependently, but use the previous fit as the start guess for the next oneParameters acrossQ, and to makeParameters dependent on each other.Beta Was this translation helpful? Give feedback.
All reactions