Ticket #2446 (closed: fixed)

Opened 10 years ago

Last modified 5 years ago

IkedaCarpenterPV function evaluation

Reported by: Vickie Lynch Owned by: Anders Markvardsen
Priority: major Milestone: Iteration 28
Component: Mantid Keywords:
Cc: Blocked By:
Blocking: Tester: Vickie Lynch

Description

When I try to evaluate the function optimized by Fit using IkedaCarpenterPV, I get a segfault. I traced it to this line where m_workspace and m_workspaceIndex are undefined in IkedaCarpenterPV.cpp.

convertValue(m_waveLength, wavelength, m_workspace, m_workspaceIndex);

Change History

comment:1 Changed 10 years ago by Vickie Lynch

The last line of this example coding from SingleCrystalTOFIntegration is where I get a segfault:

IAlgorithm_sptr fit_alg; try {

fit_alg = createSubAlgorithm("Fit",-1,-1,false);

} catch (Exception::NotFoundError&) {

g_log.error("Can't locate Fit algorithm"); throw ;

} fit_alg->setProperty("InputWorkspace",outputW); fit_alg->setProperty("WorkspaceIndex",s); fit_alg->setProperty("StartX",X[TOFmin]); fit_alg->setProperty("EndX",X[TOFmax]); fit_alg->setProperty("MaxIterations",200); fit_alg->setProperty("Output","fit"); std::ostringstream fun_str; fun_str << "name=IkedaCarpenterPV,I="<<peakHeight<<",Alpha0=14.7462,Alpha1=24.3363,Beta0=1.34607,Kappa=1.64341,SigmaSquared=1.15138,Gamma=50.0872," << "X0="<<peakLoc; fun_str << "name=Gaussian,Height="<<peakHeight<<",Sigma=17.5221,PeakCentre="<<peakLoc; fit_alg->setProperty("Function",fun_str.str());

try {

fit_alg->execute();

} catch (std::runtime_error&) {

g_log.error("Unable to successfully run Fit sub-algorithm"); throw;

}

if ( ! fit_alg->isExecuted() ) {

g_log.error("Unable to successfully run Fit sub-algorithm"); throw std::runtime_error("Unable to successfully run Fit sub-algorithm");

} MatrixWorkspace_sptr ws = fit_alg->getProperty("OutputWorkspace"); const MantidVec & DataValues = ws->readY(0);

IFitFunction *out = FunctionFactory::Instance().createInitialized(fit_alg->getPropertyValue("Function")); params = fit_alg->getProperty("Parameters"); std::string funct = fit_alg->getPropertyValue("Function"); IPeakFunction *pk = dynamic_cast<IPeakFunction *>(out); const int n=1000; double *x = new double[n]; double *y = new double[n]; double dx=(X[TOFmax]-X[TOFmin])/double(n-1); for (int i=0; i < n; i++) {

x[i] = X[TOFmin]+i*dx;

} pk->function(y,x,n);

comment:2 Changed 10 years ago by Roman Tolchenov

(In [10190]) Fixed the missing last data point issue. re #2446

comment:3 Changed 10 years ago by Roman Tolchenov

(In [10191]) Fixing the tests. re #2446

comment:4 Changed 10 years ago by Anders Markvardsen

(In [10302]) When workspace not set default wavelength in IkedaCarpenter (IC) to one.

Introduced a number places where if the workspace or instrument of the workspace is not set properly that warnings are displayed.

Removed now obsolete constant wavelength option in IC code.

Re-enable the IC test and further improve it.

Note workspace of fitting function will normally automatically be set. But for now one exception is when using

IFitFunction *out = FunctionFactory::Instance().createInitialized(alg2.getPropertyValue("Function")); IPeakFunction *pk = dynamic_cast<IPeakFunction *>(out);

To set the workspace for pk add a line like:

pk->setMatrixWorkspace(ws2D, 0,-1,-1);

re #2446

comment:5 Changed 10 years ago by Russell Taylor

(In [10311]) Comment out failing assert for now. Re #2446.

comment:6 Changed 10 years ago by Vickie Lynch

(In [10338]) Refs #2379 #2446 Integrate peaks using pf->function for IkeidaCarpenter

comment:7 Changed 10 years ago by Anders Markvardsen

(In [10387]) Uncomment failing assert and increase tolerance to 48.229+-0.1. Should hopefully now pass on all platforms. This test fitting an IkedaCarpenter to a Gaussian peak and at on Linux and Win64 appears to do a reasonable good job. re #2446

comment:8 Changed 10 years ago by Nick Draper

  • Status changed from new to assigned
  • Owner set to Anders Markvardsen

comment:9 Changed 9 years ago by Anders Markvardsen

  • Status changed from assigned to accepted

comment:10 Changed 9 years ago by Anders Markvardsen

  • Status changed from accepted to verify
  • Resolution set to fixed

Believe this one fixed...

comment:11 Changed 9 years ago by Vickie Lynch

  • Status changed from verify to verifying
  • Tester set to Vickie Lynch

comment:12 Changed 9 years ago by Vickie Lynch

  • Status changed from verifying to closed

Works with my peak integration. Thanks!

comment:13 Changed 5 years ago by Stuart Campbell

This ticket has been transferred to github issue 3293

Note: See TracTickets for help on using tickets.