Ticket #7182 (closed: fixed)
Add option to ignore data points which guarantee failure of Fit
Reported by: | Roman Tolchenov | Owned by: | Roman Tolchenov |
---|---|---|---|
Priority: | critical | Milestone: | Release 2.6 |
Component: | Framework | Keywords: | |
Cc: | Blocked By: | ||
Blocking: | #6981 | Tester: | Anders Markvardsen |
Description
Add a bool property to Fit to ignore NaNs, infinities and points with 0 error.
Change History
comment:2 Changed 7 years ago by Roman Tolchenov
Added option to ignore invalid data in Fit. Re #7182.
Changeset: 0cca0b95f97b4f6abbd7d54f3765c4d67f0ce557
comment:3 Changed 7 years ago by Roman Tolchenov
Merge branch 'feature/7182_fit_ignore_option' into develop
comment:4 Changed 7 years ago by Roman Tolchenov
Disable windows warning. Re #7182.
Changeset: fe567e46eed87f9b69ea81905d1766bf5df6cc5f
comment:5 Changed 7 years ago by Roman Tolchenov
Merge branch 'feature/7182_fit_ignore_option' into develop
comment:7 Changed 7 years ago by Roman Tolchenov
- Status changed from accepted to verify
- Resolution set to fixed
comment:8 Changed 7 years ago by Gesner Passos
- Status changed from verify to verifying
- Tester set to Gesner Passos
comment:9 Changed 7 years ago by Gesner Passos
- Status changed from verifying to reopened
- Resolution fixed deleted
Run this code and you will see that for error = nan the fit fail to give the desired result.
import numpy import math import sys x = numpy.arange(5.0) y = numpy.arange(5.0) e = numpy.ones(5.0) y[3] = 30 e[3] = numpy.inf data = CreateWorkspace(x,y,e) lin = Linear(data) #data = Load('/home/gesner/fit_linear/linear_executed_over_this_input_workspace.nxs') lin = Linear(data) fit = Fit("name=LinearBackground",data,CreateOutput=True,IgnoreInvalidData=True) print fit
Besides, Add the option IgnoreInvalidData to the FitDialog and to FitFunction dockwidget.
comment:11 Changed 7 years ago by Roman Tolchenov
Added checks for error being nan or inf. Re #7182.
Changeset: 3a18cc7dc850cfb94516dbd1b21bcd8ed27e25b2
comment:12 Changed 7 years ago by Roman Tolchenov
- Status changed from accepted to verify
- Resolution set to fixed
comment:13 Changed 7 years ago by Alex Buts
- Status changed from verify to verifying
- Tester changed from Gesner Passos to Alex Buts
comment:14 Changed 7 years ago by Alex Buts
- Status changed from verifying to reopened
- Resolution fixed deleted
no option to remove NaNs availible on interface and script:
from mantid.simpleapi import * import numpy as np Load(Filename=r'd:\Data\Mantid_GIT\Test\AutoTestData\MAR11001.raw',OutputWorkspace='MAR11001',LoadMonitors='Separate') ws = mtd['MAR11001_Monitors'] xx = ws.dataX(1); yy = ws.dataY(1); ee = ws.dataE(1); for i in xrange(0, len(xx)) : if xx[i]>6346 and xx[i]<6685: yy[i] = np.nan
does not work when trying to fit data around the pick from GUI
comment:16 Changed 7 years ago by Roman Tolchenov
Added the option to ignore invalid data to fit browser. Re #7182.
Changeset: ac202b62a4d7737521548954a2bd1133b8b0bfd8
comment:17 Changed 7 years ago by Roman Tolchenov
- Status changed from accepted to verify
- Resolution set to fixed
comment:18 Changed 7 years ago by Anders Markvardsen
- Status changed from verify to verifying
- Tester changed from Alex Buts to Anders Markvardsen
comment:19 Changed 7 years ago by Anders Markvardsen
- Status changed from verifying to closed
When fitting a spectrum with NaN get error message when NOT ignore invalid...:
Error in execution of algorithm Fit: Infinte number or NaN found in input data.
When ignore invalid... does correctly ignore NaN
comment:21 Changed 5 years ago by Stuart Campbell
This ticket has been transferred to github issue 8028
(In #6981) It was found that some requirements from Linear were different from Fit. After some discussion, it was agreed that implementing #7182 allows us to use Fit algorithm.
But, the error from the Linear and Fit using function LinearBackground are different, the reason is that Linear, calculates the errors as:
err = sqrt(s02 + x2s12 + 2s012)
while fit calculates the erros as:
err = sqrt(s02 + x2s12)
Where s02 is the covariance of the first parameter(c0), s12 is the covariance of the second parameter(c1), and s012 is the covariance between these two parameters. For the liner equation:
y = c0 + c1 x
The fit does the simplification of considering the parameters independent, which is acceptable for the generic approach that fit offers. So, changing from Linear to Fit will cause us to update the systemtests that used to use Linear mainly because the errors are different right now.