Base Page for fitting
Bases: wx.lib.scrolledpanel.ScrolledPanel, sas.guiframe.panel_base.PanelBase
This class provide general structure of fitpanel page
Bases: wx._controls.TextCtrl
Text control for model and fit parameters. Binds the appropriate events for user interactions. Default callback methods can be overwritten on initialization
Parameters: |
|
---|
check if the user can already perform some action with this panel
return the current state of the page
Given the user selection, creates a 1D or 2D data Only when the page is on theory mode.
Create empty sizer for a panel
First time calls _show_combox_helper
Found all parameters current check and add them to list of parameters to fit if implemented
Get strings in the clipboard
Get copy params to clipboard
Get copy params to clipboard
Get copy params to clipboard
Get the string copies of the param names and values in the tap
Get the string copies of the param names and values in the tap
Get the string copies of the param names and values in the tap
return the current data
return the current data
Get the images of the plots corresponding this panel for report
: return graphs: list of figures : Need Move to guiframe
Paste params from the clipboard
Get the string copies of the param names and values in the tap
Get flag corresponding to a given weighting dI data if implemented
put default value in the combobox
Retrieve the state selected state
Create a custom pinhole smear object if implemented
Restore the previous action cancelled
Reset model state
highlight the current textcrtl and hide the error text control shown after fitting
Create a custom slit smear object if implemented
Create a smear object if implemented
Cancel the previous action
save history of the data and model
Copy Parameter values to the clipboad
Get key stroke event
on ‘More details’ button
Paste Parameter values to the panel if possible
Button event for PD help
Report the current fit results
On ‘Reset’ button for Q range clicked
Save the current state into file
On Set Focus, update guimanger and menu
Help for onSmear if implemented
Parameters: | update – force or not to update |
---|
Update menu1 on cliking the page tap
Store list of model
Parameters: | model_dict – dictionary containing list of models |
---|
Read two columns file
Parameters: | path – the path to the file to read |
---|
reset the state if implemented
Use page_state and change the state of existing page
Precondition: | the page is already drawn or created |
---|---|
Postcondition: | the state of the underlying data change as well as the state of the graphic interface |
Store current state
Store current state for fit_page
set to true or false all checkBox if implemented
Log checked to generate log spaced points for theory model
Select TextCtrl checked if implemented
Put the string to the clipboard
Sets data if implemented
fill sizer containing dispersity info
Index related to this page
layout
set panel manager
Parameters: | manager – instance of plugin fitting |
---|
Store a dictionary linking model name -> model object
Parameters: | model_dict – dictionary containing list of models |
---|
reset page given a model state
set owner of fitpage
Parameters: | owner – the class responsible of plotting |
---|
set some page important information at once
setValue Npts for fitting if implemented
Method to be called by sub-classes Moveit; This method doesn’t belong here
called by kill_focus on pinhole TextCntrl to update the changes if implemented
Batch panel
Bases: wx._controls.TextCtrl
Text control used to display outputs. No editing allowed. The background is grayed out. User can’t select text.
Bases: sas.perspectives.fitting.fitpage.FitPage
Batch Page
Currently no save option implemented for batch page
Currently no save option implemented for batch page
reset the current data
Bases: sas.fit.AbstractFitEngine.FitHandler
Print progress to the console.
Model had an error; print traceback
Called when a result is observed which is better than previous results from the fit.
Number of seconds between improvement updates
Record whether results improved since last update
Print result object
Report on progress.
Number of seconds between progress updates
Post event msg and stop
Bases: sas.data_util.calcthread.CalcThread
Thread performing the fit
Perform a fit
Raises KeyboardInterrupt: | |
---|---|
when the thread is interrupted |
Take an instance of a class and a function name as a string. Execute class.function and return result
FitPanel class contains fields allowing to display results when fitting a model and one data
Bases: wx._controls.TextCtrl
Text control used to display outputs. No editing allowed. The background is grayed out. User can’t select text.
Bases: sas.perspectives.fitting.basepage.BasicPage
FitPanel class contains fields allowing to display results when fitting a model and one data
Note: | For Fit to be performed the user should check at least one parameter on fit Panel window. |
---|
compute the minimum and the maximum range of the data return the npts contains in data :param data:
find the range that include all data in the set return the minimum and the maximum values
Enable or disable data source control depending on existing data
Enable fit button if data is valid and model is valid
Get a list of data and fill the corresponding combobox
Found all parameters current check and add them to list of parameters to fit
return the current chi2
return numbers of data points within qrange
Note: | This is for Park where chi2 is not normalized by Npts of fit |
---|
return the fitting range
return True if the panel allow 2D or False if 1D
Get flag corresponding to a given weighting dI data.
Create a custom pinhole smear object that will change the way residuals are compute when fitting
Note: | accuracy is given by strings’High’,’Med’, ‘Low’ FOR 2d, None for 1D |
---|
Create a custom slit smear object that will change the way residuals are compute when fitting
Create a smear object that will change the way residuals are compute when fitting
On Weighting radio button event, sets the weightbt_string
Display result chisqr on the panel :event: activated by fitting/ complete after draw
On Key down
#On q range value updated. DO not combine with qrange_click().
Get key stroke event
On_select_data
Help for onSmear
Parameters: | update – force or not to update |
---|
Build the panel from the fit result
Parameters: |
|
---|
ON Qrange focus
On Qrange textctrl click, make the qrange lines in the plot
find a short name for model
reset the state
set to true or false all checkBox given the main checkbox value cb1
Select TextCtrl checked for fitting purpose and stores them in self.param_toFit=[] list
reset the current data
Set fit button label depending on the fit_started[bool]
Build the panel from the model content
Parameters: | model – the model selected in combo box for fitting purpose |
---|
setValue Npts for fitting
called by kill_focus on pinhole TextCntrl to update the changes
Returns: | False when wrong value was entered |
---|
called by kill_focus on pinhole TextCntrl to update the changes
Returns: | False when wrong value was entered |
---|
FitPanel class contains fields allowing to fit models and data
note: | For Fit to be performed the user should check at least one parameter on fit Panel window. |
---|
Bases: wx.aui.AuiNotebook, sas.guiframe.panel_base.PanelBase
FitPanel class contains fields allowing to fit models and data
Note: | For Fit to be performed the user should check at least one parameter on fit Panel window. |
---|
add an empty page
Add the simultaneous fit page
Clear and close all panels, used by guimanager
remove all pages, used when a svs file is opened
close a fit page when its data is completely remove from the graph
Delete the given data
display the close button on tab for more than 1 tabs else remove the close button
Returns: | the current page selected |
---|
get the data in the current page
return the state of the current selected page
close page and remove all references to the closed page
calls the function when the current event handler has exited. avoiding to call panel on focus on a panel that is currently deleted
Add a fitting page on the notebook contained by fitpanel
Parameters: | data – data to fit |
---|
:return panel : page just added for further used. is used by fitting module
Add all data to a single tab when the application is on Batch mode. However all data in the set of data must be either 1D or 2D type. This method presents option to select the data type before creating a tab.
set panel manager
Parameters: | manager – instance of plugin fitting |
---|
copy a dictionary of model name -> model object
Parameters: | m_dict – dictionary linking model name -> model object |
---|
copy a dictionary of model into its own dictionary
Parameters: | m_dict – dictionnary made of model name as key and model class |
---|
as value
receive a state to reset the model in the current page
Restore state of the panel
Inferface containing information to store data, model, range of data, etc... and retreive this information. This is an inferface for a fitProblem i.e relationship between data and model.
Bases: sas.perspectives.fitting.fitproblem.FitProblemComponent
FitProblem class allows to link a model with the new name created in _on_model, a name theory created with that model and the data fitted with the model. FitProblem is mostly used as value of the dictionary by fitting module.
clear constraint info
Parameters: | flag – bool.When flag is 1 get the computer smear value. When |
---|
flag is 0 ingore smear value.
Returns: | data associate with this class |
---|
Get graph_id
Returns: | saved model |
---|
return list of couple of parameter name and value
return the list param names to fit
Returns: | fitting range |
---|
Returns: | residuals |
---|
get result
return true or false if a problem as being schedule for fitting
return smear object
Returns: | theory generated with the current model and data of this class |
---|
returns weight array
set schedule to true to decide if this fit must be performed
Store data associated with this class :param data: list of data selected
Set graph id (from data_group_id at the time the graph produced)
associates each model with its new created name :param model: model selected :param name: name created for model
Store the name and value of a parameter of this fitproblem’s model :param name: name of the given parameter :param value: value of that parameter
Store param names to fit (checked) :param list: list of the param names
set fitting range :param qmin: minimum value to consider for the fit range :param qmax: maximum value to consider for the fit range
save a copy of residual :param data: data selected
save reference of smear object on fitdata
Parameters: | smear – smear object from DataLoader |
---|
save a copy of the data select to fit
Parameters: | data – data selected |
---|
Received flag and compute error on data. :param flag: flag to transform error of data. :param is2d: flag to distinguish 1D to 2D Data
Bases: object
Inferface containing information to store data, model, range of data, etc... and retreive this information. This is an inferface for a fitProblem i.e relationship between data and model.
clear constraint info
Parameters: | flag – bool.When flag is 1 get the computer smear value. When |
---|
flag is 0 ingore smear value.
Return the caption of the page associated with object
Get graph_id
Returns: | saved model |
---|
return list of couple of parameter name and value
return the list param names to fit
Returns: | fitting range |
---|
Returns: | residuals |
---|
get result
return true or false if a problem as being schedule for fitting
return smear object
Returns: | list of data dList |
---|
get fitting weight
set schedule to true to decide if this fit must be performed
Store of list of data and create by create new fitproblem of each data id , if there was existing information about model, this information get copy to the new fitproblem
Parameters: | data – list of data selected |
---|
store the caption of the page associated with object
Set graph id (from data_group_id at the time the graph produced)
associates each model with its new created name :param model: model selected :param name: name created for model
Store the name and value of a parameter of this fitproblem’s model :param name: name of the given parameter :param value: value of that parameter
Store param names to fit (checked) :param list: list of the param names
set fitting range
save a copy of residual :param data: data selected
save a copy of the data select to fit :param data: data selected
set fitting range
Bases: sas.perspectives.fitting.fitproblem.FitProblemComponent, dict
This module implements a dictionary of fitproblem objects
Add data to the current dictionary of fitproblem. if data id does not exist create a new fit problem. :note: only data changes in the fit problem
clear constraint info
Parameters: | flag – bool.When flag is 1 get the computer smear value. When |
---|
flag is 0 ingore smear value.
get result
return data for the given fitproblem id :param fid: is key representing a fitproblem. usually extract from data
id
return fitproblem contained in this dictionary
Return the caption of the page associated with object
Get graph_id
Returns: | saved model |
---|
return list of couple of parameter name and value
return the list param names to fit
Returns: | fitting range |
---|
Returns: | residuals |
---|
get result
return true or false if a problem as being schedule for fitting
return smear object
Returns: | list of data dList |
---|
return fit weight
set schedule to true to decide if this fit must be performed
set a list of result
save a copy of the data select to fit :param data: data selected
store the caption of the page associated with object
Set graph id (from data_group_id at the time the graph produced)
associates each model with its new created name :param model: model selected :param name: name created for model
Store the name and value of a parameter of this fitproblem’s model :param name: name of the given parameter :param value: value of that parameter
Store param names to fit (checked) :param list: list of the param names
set fitting range
save a copy of residual :param data: data selected
save reference of smear object on fitdata :param smear: smear object from DataLoader
save a copy of the data select to fit :param data: data selected
fit weight
Fitting perspective
Bases: sas.guiframe.plugin_base.PluginBase
Fitting plugin is used to perform fit
adds a color as a key with a plot id as its value to a dictionary
given a data, ask to the fitting panel to create a new fitting page, get this page and store it into the page_finder of this plug-in :param data: is a list of data
Given an ID create a fitproblem container
Delete custom model file
delete the given data from panel
Given an ID create a fitproblem container
Draw model.
Parameters: |
|
---|
Get the python editor panel
Check if the plugin has a batch capability
Get the context menu items available for P(r).them allow fitting option for Data2D and Data1D only.
Parameters: | graph – the Graph object to which we attach the context menu |
---|---|
Returns: | a list of menu items with call-back function |
Note: | if Data1D was generated from Theory1D the fitting option is not allowed |
Set graph_id for fitprobelm
return self.page_finder used also by simfitpage.py
Create and return a list of panel objects
Show a general help dialog.
Make new model
Edit summodel template and make one
Get series of data, model, associates parameters and range and send then to series of fit engines. Fit data and model, display result to corresponding panels. :param uid: id related to the panel currently calling this fit function.
ask fit panel to create a new empty page
Create a page to access simultaneous fit option
switch the the notebook of batch mode or not
Set batch_reset_flag
Set_state_helper. This actually sets state after plotting data from state file.
Create a menu for the Fitting plug-in
Parameters: |
|
---|---|
Returns: | list of information to populate the main menu |
Put icon in the frame title bar
remove model plot when a fit page is closed :param uid: the id related to the fitpage to close :param fid: the id of the fitproblem(data, model, range,etc)
save fit page state into file
Set the fit problem field to 0 or 1 to schedule that problem to fit. Schedule the specified fitproblem or get the fit problem related to the current page and set value. :param value: integer 0 or 1 :param uid: the id related to a page contaning fitting information
receive a list of data to fit
Call back method that True to notify the parent that the current plug-in can be set as default perspective. when returning False, the plug-in is not candidate for an automatic default perspective setting
Set list of the edit model menu labels
help for setting list of the edit model menu labels
Set the fitting range of a given page for all its data by default. If fid is provide then set the range only for the data with fid as id :param uid: id corresponding to a fit page :param fid: id corresponding to a fit problem (data, model) :param qmin: minimum value of the fit range :param qmax: maximum value of the fit range
Set the fit weights of a given page for all its data by default. If fid is provide then set the range only for the data with fid as id :param uid: id corresponding to a fit page :param fid: id corresponding to a fit problem (data, model) :param weight: current dy data
Set ftol: Relative error desired in the sum of chi squares.
Set graph_id for fitprobelm
Used by simfitpage.py to reset a parameter given the string constrainst.
Parameters: |
|
---|---|
Note: | expecting park used for fit. |
Set the list of param names to fit for fitprobelm
Get a smear object and store it to a fit problem of fid as id. If proper flag is enable , will plot the theory with smearing information.
Parameters: |
|
---|
Call-back method for the fit page state reader. This method is called when a .fitv/.svs file is loaded.
: param state: PageState object : param datainfo: data
Dialog to select ftol for Scipy
receive a word containing dot and split it. used to split parameterset name into model name and parameter name example:
paramaterset (item) = M1.A
Will return model_name = M1 , parameter name = A
Stop the fit engine
Recieve a list of data and store them ans well as a caption of the fit page where they come from. :param uid: if related to a fit page :param data_list: list of data to fit :param caption: caption of the window related to these data
Update custom model list in the fitpage combo box
Bases: wx._windows.Dialog
The current design of Batch fit allows only of type of data in the data set. This allows the user to make a quick selection of the type of data to use in fit tab.
return 1 if user requested Data1D , 2 if user requested Data2D
Bases: wx._windows.Dialog
Allow file selection at loading time
return the selected data
Bases: wx.lib.scrolledpanel.ScrolledPanel
Dialog to set ftol for Scipy
ftol(float): Relative error desired in the sum of squares.
Help dialog
Bases: wx.lib.scrolledpanel.ScrolledPanel
Bases: wx._windows.Frame
Function to diplay Model html page related to the hyperlinktext selected
Function to diplay html page related to the hyperlinktext selected
Recover the scroll position On Size
This class provide general structure of fitpanel page
Bases: wx._windows.Frame
Bases: wx._windows.ScrolledWindow, sas.guiframe.panel_base.PanelBase
This class provide general structure of fitpanel page
Draw the page
Calculation thread for modeling
Bases: sas.data_util.calcthread.CalcThread
Compute 1D data
Compute model 1d value given qmin , qmax , x value
Send resuts of the computation
Bases: sas.data_util.calcthread.CalcThread
Compute 2D model This calculation assumes a 2-fold symmetry of the model where points are computed for one half of the detector and I(qx, qy) = I(-qx, -qy) is assumed.
Compute the data given a model function
Utilities to manage models
Bases: object
Contains dictionary of model and their type
return all the list stored in a dictionary object
Parameters: |
|
---|
Parameters: |
|
---|
Bases: object
implement model
Base class for the model manager
find plugin model in directory of plugin .recompile all file in the directory if file were modified
return dictionary linking model names to objects
return dictionary of models for fitpanel use
return regular model name list
return a dictionary of model
return a dictionary of model if new models were added else return empty dictionary
Compile a py file
Find path of the plugins directory. The plugin directory is located in the user’s home directory.
Log a message in a file located in the user’s home directory
Class that holds a fit page state
Bases: object
Contains information to reconstruct a page of the fitpanel.
Create a new copy of the current object
Load fitting state from a file
Parameters: |
|
---|
Invoke report dialog panel
: param figs: list of pylab figures [list]
Build image state that wx.html understand by plotting, putting it into wx.FileSystem image object
Get the values (strings) from __str__ for report
Writes the state of the InversionControl panel to file, as XML.
Compatible with standalone writing, or appending to an already existing XML document. In that case, the XML document is required. An optional entry node in the XML document may also be given.
Parameters: |
|
---|
Bases: sas.dataloader.readers.cansas_reader.Reader
Class to load a .fitv fitting file
Load a new P(r) inversion state from file
Parameters: | path – file path |
---|
Write the content of a Data1D as a CanSAS XML file only for standalone
Parameters: |
|
---|
Write toXML, a helper for write(), could be used by guimanager._on_save()
: return: xml doc
Create a numpy list from value extrated from the node
Parameters: |
|
---|
: return: numpy array
Dialog report panel to show and summarize the results of the invariant calculation.
Bases: wx._windows.Dialog
The report dialog box.
Create a PDF file from html source string.
: data: html string : filename: name of file to be saved
Close the Dialog
: event: Close button event
Preview
: event: Preview button event
: event: Print button event
Save
FitPanel class contains fields allowing to fit models and data
note: | For Fit to be performed the user should check at least one parameter on fit Panel window. |
---|
Bases: wx.aui.AuiNotebook, sas.guiframe.panel_base.PanelBase
FitPanel class contains fields allowing to fit models and data
Note: | For Fit to be performed the user should check at least one parameter on fit Panel window. |
---|
Simultaneous fit page
Bases: wx.lib.scrolledpanel.ScrolledPanel, sas.guiframe.panel_base.PanelBase
Simultaneous fitting panel All that needs to be defined are the two data members window_name and window_caption
check all models names
Save information related to checkbox and their states
Create empty sizer for a panel
Draw a sizer containing couples of data and model
signal for fitting
Remove constraint fields
The derivative class is on focus if implemented
layout
set panel manager
Parameters: | manager – instance of plugin fitting |
---|
return list of fittable parameters name of a model
Parameters: | model – the model used |
---|
Module contains functions frequently used in this package
Received flag and compute error on data. :param flag: flag to transform error of data. :param is2d: flag to distinguish 1D to 2D Data