- Timestamp:
- Apr 9, 2018 10:00:41 AM (7 years ago)
- Branches:
- master, magnetic_scatt, release-4.2.2, ticket-1009, ticket-1094-headless, ticket-1242-2d-resolution, ticket-1243, ticket-1249, unittest-saveload
- Children:
- 0863065
- Parents:
- 4a8d55c (diff), b09aee8 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent. - Location:
- src/sas
- Files:
-
- 7 edited
- 1 moved
Legend:
- Unmodified
- Added
- Removed
-
src/sas/sasgui/perspectives/calculator/model_editor.py
r2469df7 rc6dfb9f 391 391 self._msg_box.SetLabel(msg) 392 392 self._msg_box.SetForegroundColour(color) 393 self._set_model_list() 393 394 if self.parent.parent is not None: 394 395 from sas.sasgui.guiframe.events import StatusEvent … … 432 433 if len(main_list) > 1: 433 434 main_list.sort() 435 self.model1.Clear() 436 self.model2.Clear() 434 437 for idx in range(len(main_list)): 435 438 self.model1.Append(str(main_list[idx]), idx) -
src/sas/sasgui/perspectives/fitting/fitpage.py
rbfeb823 ra7c6f38 365 365 # StaticText for chi2, N(for fitting), Npts + Log/linear spacing 366 366 self.tcChi = BGTextCtrl(self, wx.ID_ANY, "-", size=(75, 20), style=0) 367 self.tcChi.SetToolTipString("Chi2/ Npts(Fit)")367 self.tcChi.SetToolTipString("Chi2/DOF (DOF=Npts-Npar fitted)") 368 368 self.Npts_fit = BGTextCtrl(self, wx.ID_ANY, "-", size=(75, 20), style=0) 369 369 self.Npts_fit.SetToolTipString( … … 391 391 self.points_sizer.Add(self.pointsbox) 392 392 393 box_description_1 = wx.StaticText(self, wx.ID_ANY, ' Chi2/Npts')393 box_description_1 = wx.StaticText(self, wx.ID_ANY, 'Reduced Chi2') 394 394 box_description_2 = wx.StaticText(self, wx.ID_ANY, 'Npts(Fit)') 395 395 -
src/sas/sasgui/perspectives/fitting/media/fitting_help.rst
r5005ae0 r47ace50 426 426 See :ref:`Assessing_Fit_Quality`. 427 427 428 The objective of model-fitting is to find a *physically-plausible* model, and set429 of model parameters, that generate a theory that reproduces the experimental data 430 and gives residual values as close to zero as possible.428 The objective of model-fitting is to find a *physically-plausible* model, and 429 set of model parameters, that generate a theory that reproduces the experimental 430 data and minimizes the values of the residuals. 431 431 432 432 Change the default values of the model parameters by hand until the theory line 433 starts to represent the experimental data. Then uncheck the tick boxes alongside 434 all parameters *except* the 'background' and the 'scale'. Click the *Fit* button. 435 SasView will optimise the values of the 'background' and 'scale' and also display 436 the corresponding uncertainties on the optimised values. 437 438 *NB: If no uncertainty is shown it generally means that the model is not very* 439 *dependent on the corresponding parameter (or that one or more parameters are* 440 *'correlated').* 441 442 In the bottom left corner of the *Fit Page* is a box displaying the normalised value 443 of the statistical $\chi^2$ parameter returned by the optimiser. 433 starts to represent the experimental data. Then check the tick boxes alongside 434 the 'background' and 'scale' parameters. Click the *Fit* button. SasView 435 will optimise the values of the 'background' and 'scale' and also display the 436 corresponding uncertainties on the optimised values. 437 438 .. note:: 439 If the uncertainty on a fitted parameter is unrealistically large, or if it 440 displays as NaN, the model is most likely a poor representation of the data, 441 the parameter in question is highly correlated with one or more of the other 442 fitted parameters, or the model is relatively insensitive to the value of 443 that particular parameter. 444 445 In the bottom left corner of the *Fit Page* is a box displaying a normalised 446 value of the statistical $\chi^2$ parameter (the reduced $\chi^2$, 447 See :ref:`Assessing_Fit_Quality`) returned by the optimiser. 444 448 445 449 Now check the box for another model parameter and click *Fit* again. Repeat this 446 process until most or all parameters are checked and have been optimised. As the447 fit of the theory to the experimental data improves the value of 'chi2/Npts' will 448 decrease. A good model fit should easily produce values of 'chi2/Npts' that are 449 close to one, and certainly < 100. See :ref:`Assessing_Fit_Quality`.450 process until all relevant parameters are checked and have been optimised. As 451 the fit of the theory to the experimental data improves, the value of 'Reduced 452 Chi2' will decrease. A good model fit should produce values of Reduced Chi2 453 close to one, and certainly << 100. See :ref:`Assessing_Fit_Quality`. 450 454 451 455 SasView has a number of different optimisers (see the section :ref:`Fitting_Options`). … … 462 466 *the Data Explorer is checked (see the section* :ref:`Loading_data` *).* 463 467 464 This mode is an extension of the :ref:`Single_Fit_Mode` that fits two or more data 465 sets *to the same model* simultaneously. If necessary it is possible to constrain 466 fit parameters between data sets (eg, to fix a background level, or radius, etc). 468 This mode is an extension of the :ref:`Single_Fit_Mode` that allows for some 469 relatively extensive constraints between fitted parameters in a single *FitPage* 470 or between several *FitPage*'s (eg, to constrain all fitted parameters to be the 471 same in a contrast series of *FitPages* except for the solvent sld parameter, 472 constrain the length to be twice that of the radius in a single *FitPage*, 473 fix the radius of the sphere in one *FitPage* to be the same as the radius of 474 the cylinder in a second *FitPage*, etc). 467 475 468 476 If the data to be fit are in multiple files, load each file, then select each file … … 501 509 next to *Add Constraint?* in the *Fit Constraints* box. 502 510 511 To constrain all identically named parameters to fit *simultaneously* to the 512 same value across all the *Fitpages* use the *Easy Setup* drop-down buttons in 513 the *Const & Simul Fit* page. 514 503 515 *NB: You can only constrain parameters that are set to refine.* 516 517 Constraints will generally be of the form 518 519 Mi Parameter1 = Mj.Parameter1 520 521 however the text box after the '=' sign can be used to adjust this 522 relationship; for example 523 524 Mi Parameter1 = scalar \* Mj.Parameter1 525 526 A 'free-form' constraint box is also provided. 527 528 Many constraints can be entered for a single fit. 504 529 505 530 When ready, click the *Fit* button on the *Const & Simul Fit* page, NOT the *Fit* 506 531 button on the individual *FitPage*'s. 507 532 508 Simultaneous Fits without Constraints509 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^510 511 533 The results of the model-fitting will be returned to each of the individual 512 534 *FitPage*'s. 513 535 514 Note that the chi2/Npts value returned is the SUM of the chi2/Npts of each fit. To 515 see the chi2/Npts value for a specific *FitPage*, click the *Compute* button at the 516 bottom of that *FitPage* to recalculate. Also see :ref:`Assessing_Fit_Quality`. 517 518 Simultaneous Fits with Constraints 519 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 520 521 Use the *Easy Setup* drop-down buttons in the *Const & Simul Fit* page to set 522 up constraints between *FitPage*'s. 523 524 Constraints will generally be of the form 525 526 Mi Parameter1 = Mj.Parameter1 527 528 however the text box after the '=' sign can be used to adjust this 529 relationship; for example 530 531 Mi Parameter1 = scalar \* Mj.Parameter1 532 533 A 'free-form' constraint box is also provided. 534 535 Many constraints can be entered for a single fit. 536 537 The results of the model-fitting will be returned to each of the individual 538 *FitPage*'s. 539 540 Note that the chi2/Npts value returned is the SUM of the chi2/Npts of each fit. To 541 see the chi2/Npts value for a specific *FitPage*, click the *Compute* button at the 542 bottom of that *FitPage* to recalculate. Also see :ref:`Assessing_Fit_Quality`. 536 Note that the Reduced Chi2 value returned is the SUM of the Reduced Chi2 of 537 each fit. To see the Reduced Chi2 value for a specific *FitPage*, click the 538 *Compute* button at the bottom of that *FitPage* to recalculate. Note that in 539 doing so the degrees of freedom will be set to Npts. 540 See :ref:`Assessing_Fit_Quality`. Moreover in the case of constraints the 541 degrees of freedom are less than one might think due to those constraints. 543 542 544 543 .. ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ … … 766 765 .. ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ 767 766 768 .. note:: This help document was last changed by Paul Butler, 10 September 769 2017 767 .*Document History* 768 769 | 2017-09-10 Paul Butler 770 | 2017-09-15 Steve King 771 | 2018-03-05 Paul Butler -
src/sas/sasgui/perspectives/fitting/media/residuals_help.rst
r99ded31 r84ac3f1 27 27 28 28 $\chi^2$ is a statistical parameter that quantifies the differences between 29 an observed data set and an expected dataset (or 'theory'). 30 31 When showing the a model with the data, *SasView* displays this parameter 32 normalized to the number of data points, $N_\mathrm{pts}$ such that 29 an observed data set and an expected dataset (or 'theory') calculated as 33 30 34 31 .. math:: 35 32 36 \chi^2 _N37 = \sum[(Y_i - \mathrm{theory}_i)^2 / \mathrm{error}_i^2] / N_\mathrm{pts}33 \chi^2 34 = \sum[(Y_i - \mathrm{theory}_i)^2 / \mathrm{error}_i^2] 38 35 39 When performing a fit, *SasView* instead displays the reduced $\chi^2_R$, 40 which takes into account the number of fitting parameters $N_\mathrm{par}$ 41 (to calculate the number of 'degrees of freedom'). This is computed as 36 Fitting typically minimizes the value of $\chi^2$. For assessing the quality of 37 the model and its "fit" however, *SasView* displays the traditional reduced 38 $\chi^2_R$ which normalizes this parameter by dividing it by the number of 39 degrees of freedom (or DOF). The DOF is the number of data points being 40 considered, $N_\mathrm{pts}$, reduced by the number of free (i.e. fitted) 41 parameters, $N_\mathrm{par}$. Note that model parameters that are kept fixed do 42 *not* contribute to the DOF (they are not "free"). This reduced value is then 43 given as 42 44 43 45 .. math:: … … 47 49 / [N_\mathrm{pts} - N_\mathrm{par}] 48 50 49 The normalized $\chi^2_N$ and the reduced $\chi^2_R$ are very close to each 50 other when $N_\mathrm{pts} \gg N_\mathrm{par}$. 51 Note that this means the displayed value will vary depending on the number of 52 parameters used in the fit. In particular, when doing a calculation without a 53 fit (e.g. manually changing a parameter) the DOF will now equal $N_\mathrm{pts}$ 54 and the $\chi^2_R$ will be the smallest possible for that combination of model, 55 data set, and set of parameter values. 56 57 When $N_\mathrm{pts} \gg N_\mathrm{par}$ as it should for proper fitting, the 58 value of the reduced $\chi^2_R$ will not change very much. 51 59 52 60 For a good fit, $\chi^2_R$ tends to 1. … … 90 98 | 2015-06-08 Steve King 91 99 | 2017-09-28 Paul Kienzle 100 | 2018-03-04 Paul Butler -
src/sas/sascalc/dataloader/file_reader_base_class.py
ra58b5a0 r4a8d55c 31 31 FIELDS_2D = ('data', 'qx_data', 'qy_data', 'q_data', 'err_data', 32 32 'dqx_data', 'dqy_data', 'mask') 33 33 DEPRECATION_MESSAGE = ("\rThe extension of this file suggests the data set migh" 34 "t not be fully reduced. Support for the reader associat" 35 "ed with this file type has been removed. An attempt to " 36 "load the file was made, but, should it be successful, " 37 "SasView cannot guarantee the accuracy of the data.") 34 38 35 39 class FileReader(object): … … 40 44 # List of allowed extensions 41 45 ext = ['.txt'] 46 # Deprecated extensions 47 deprecated_extensions = ['.asc', '.nxs'] 42 48 # Bypass extension check and try to load anyway 43 49 allow_all = False … … 87 93 if not self.f_open.closed: 88 94 self.f_open.close() 95 if any(filepath.lower().endswith(ext) for ext in 96 self.deprecated_extensions): 97 self.handle_error_message(DEPRECATION_MESSAGE) 89 98 if len(self.output) > 0: 90 99 # Sort the data that's been loaded … … 146 155 else: 147 156 logger.warning(msg) 157 raise NoKnownLoaderException(msg) 148 158 149 159 def send_to_output(self): -
src/sas/sascalc/dataloader/loader.py
rdc8d1c2 r4a8d55c 90 90 ascii_loader = ascii_reader.Reader() 91 91 return ascii_loader.read(path) 92 except NoKnownLoaderException: 93 pass # Try the Cansas XML reader 92 94 except DefaultReaderException: 93 95 pass # Loader specific error to try the cansas XML reader … … 100 102 cansas_loader = cansas_reader.Reader() 101 103 return cansas_loader.read(path) 104 except NoKnownLoaderException: 105 pass # Try the NXcanSAS reader 102 106 except DefaultReaderException: 103 107 pass # Loader specific error to try the NXcanSAS reader -
src/sas/sasgui/guiframe/local_perspectives/data_loader/data_loader.py
r20fa5fe r2924532 185 185 try: 186 186 message = "Loading {}...\n".format(p_file) 187 self.load_update( output=output,message=message, info="info")187 self.load_update(message=message, info="info") 188 188 temp = self.loader.load(p_file, format) 189 189 if not isinstance(temp, list): … … 201 201 else: 202 202 file_errors[basename] = [error_message] 203 self.load_update(output=output, 204 message=error_message, info="warning") 205 206 self.load_update(output=output, 207 message="Loaded {}\n".format(p_file), 208 info="info") 203 204 self.load_update(message="Loaded {}\n".format(p_file), 205 info="info") 209 206 210 207 except NoKnownLoaderException as e: 211 208 exception_occurred = True 212 logger.error(e.message)213 214 209 error_message = "Loading data failed!\n" + e.message 215 self.load_update(output=None, message=e.message, info="warning") 210 self.load_complete(output=None, 211 message=error_message, 212 info="warning") 216 213 217 214 except Exception as e: 218 215 exception_occurred = True 219 logger.error(e.message)220 221 216 file_err = "The Data file you selected could not be " 222 217 file_err += "loaded.\nMake sure the content of your file" … … 225 220 file_err += " following:\n" 226 221 file_err += e.message 227 file_errors[basename] = [file_err] 222 self.load_complete(output=None, 223 message=file_err, 224 info="error") 228 225 229 226 if len(file_errors) > 0: 230 227 error_message = "" 231 228 for filename, error_array in file_errors.iteritems(): 232 error_message += "The following errors occured whilst "229 error_message += "The following issues were found whilst " 233 230 error_message += "loading {}:\n".format(filename) 234 231 for message in error_array: 235 232 error_message += message + "\n" 236 error_message += "\n" 237 if not exception_occurred: # Some data loaded but with errors 238 self.load_update(output=output, message=error_message, info="error") 239 240 if not exception_occurred: # Everything loaded as expected 233 error_message = error_message[:-1] 234 self.load_complete(output=output, 235 message=error_message, 236 info="error") 237 238 elif not exception_occurred: # Everything loaded as expected 241 239 self.load_complete(output=output, message="Loading data complete!", 242 240 info="info") … … 244 242 self.load_complete(output=None, message=error_message, info="error") 245 243 246 247 def load_update(self, output=None, message="", info="warning"): 244 def load_update(self, message="", info="warning"): 248 245 """ 249 246 print update on the status bar 250 247 """ 251 248 if message != "": 252 wx.PostEvent(self.parent, StatusEvent(status=message, info=info, 249 wx.PostEvent(self.parent, StatusEvent(status=message, 250 info=info, 253 251 type="progress")) 254 252 … … 257 255 post message to status bar and return list of data 258 256 """ 259 wx.PostEvent(self.parent, StatusEvent(status=message, info=info, 257 wx.PostEvent(self.parent, StatusEvent(status=message, 258 info=info, 260 259 type="stop")) 261 260 if output is not None:
Note: See TracChangeset
for help on using the changeset viewer.