Changeset e1442d4 in sasview for src


Ignore:
Timestamp:
Jun 2, 2015 11:51:34 AM (9 years ago)
Author:
Paul Kienzle <pkienzle@…>
Branches:
master, ESS_GUI, ESS_GUI_Docs, ESS_GUI_batch_fitting, ESS_GUI_bumps_abstraction, ESS_GUI_iss1116, ESS_GUI_iss879, ESS_GUI_iss959, ESS_GUI_opencl, ESS_GUI_ordering, ESS_GUI_sync_sascalc, costrafo411, magnetic_scatt, release-4.1.1, release-4.1.2, release-4.2.2, release_4.0.1, ticket-1009, ticket-1094-headless, ticket-1242-2d-resolution, ticket-1243, ticket-1249, ticket885, unittest-saveload
Children:
b99a4552
Parents:
422e7e8
Message:

better handling of unsuccessful bumps fits

Location:
src/sas
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • src/sas/fit/BumpsFitting.py

    r9f7fbd9 re1442d4  
    271271            fitness = M.fitness 
    272272            fitted_index = [varying.index(p) for p in fitness.fitted_pars] 
     273            param_list = fitness.fitted_par_names + fitness.computed_par_names 
    273274            R = FResult(model=fitness.model, data=fitness.data, 
    274                         param_list=fitness.fitted_par_names+fitness.computed_par_names) 
     275                        param_list=param_list) 
    275276            R.theory = fitness.theory() 
    276277            R.residuals = fitness.residuals() 
     
    278279            R.fitter_id = self.fitter_id 
    279280            # TODO: should scale stderr by sqrt(chisq/DOF) if dy is unknown 
    280             R.stderr = numpy.hstack((result['stderr'][fitted_index], 
    281                                      numpy.NaN*numpy.ones(len(fitness.computed_pars)))) 
    282             R.pvec = numpy.hstack((result['value'][fitted_index], 
    283                                   [p.value for p in fitness.computed_pars])) 
    284281            R.success = result['success'] 
    285             R.fitness = numpy.sum(R.residuals**2)/(fitness.numpoints() - len(fitted_index)) 
     282            if R.success: 
     283                R.stderr = numpy.hstack((result['stderr'][fitted_index], 
     284                                         numpy.NaN*numpy.ones(len(fitness.computed_pars)))) 
     285                R.pvec = numpy.hstack((result['value'][fitted_index], 
     286                                      [p.value for p in fitness.computed_pars])) 
     287                R.fitness = numpy.sum(R.residuals**2)/(fitness.numpoints() - len(fitted_index)) 
     288            else: 
     289                R.stderr = numpy.NaN*numpy.ones(len(param_list)) 
     290                R.pvec = numpy.asarray( [p.value for p in fitness.fitted_pars+fitness.computed_pars]) 
     291                R.fitness = numpy.NaN 
    286292            R.convergence = result['convergence'] 
    287293            if result['uncertainty'] is not None: 
     
    310316    max_step = fitopts.options.get('steps', 0) + fitopts.options.get('burn', 0) 
    311317    pars = [p.name for p in problem._parameters] 
     318    #x0 = numpy.asarray([p.value for p in problem._parameters]) 
    312319    options['monitors'] = [ 
    313320        BumpsMonitor(handler, max_step, pars, problem.dof), 
     
    317324                                  abort_test=abort_test, **options) 
    318325    omp_threads = int(os.environ.get('OMP_NUM_THREADS','0')) 
    319     mapper = MPMapper if omp_threads == 1 else SerialMapper        
     326    mapper = MPMapper if omp_threads == 1 else SerialMapper 
    320327    fitdriver.mapper = mapper.start_mapper(problem, None) 
    321328    #import time; T0 = time.time() 
     
    332339    convergence = (2*numpy.asarray(convergence_list)/problem.dof 
    333340                   if convergence_list else numpy.empty((0,1),'d')) 
     341 
     342    success = best is not None 
    334343    return { 
    335         'value': best, 
    336         'stderr': fitdriver.stderr(), 
    337         'success': True, # better success reporting in bumps 
     344        'value': best if success else None, 
     345        'stderr': fitdriver.stderr() if success else None, 
     346        'success': success, 
    338347        'convergence': convergence, 
    339348        'uncertainty': getattr(fitdriver.fitter, 'state', None), 
  • src/sas/perspectives/fitting/fitting.py

    r9776c82 re1442d4  
    15111511 
    15121512        except: 
    1513             msg = "Fit completed but Following" 
    1514             msg += " warning occurred: %s" % sys.exc_value 
     1513            msg = ("Fit completed but the following error occurred: %s" 
     1514                   % sys.exc_value) 
     1515            #import traceback; msg = "\n".join((traceback.format_exc(), msg)) 
    15151516            wx.PostEvent(self.parent, StatusEvent(status=msg, info="warning", 
    15161517                                                  type="stop")) 
Note: See TracChangeset for help on using the changeset viewer.