Ignore:
Timestamp:
Nov 15, 2017 4:33:09 AM (7 years ago)
Author:
Piotr Rozyczko <rozyczko@…>
Branches:
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
Children:
d4881f6a
Parents:
7c487846
Message:

Initial commit of the P(r) inversion perspective.
Code merged from Jeff Krzywon's ESS_GUI_Pr branch.
Also, minor 2to3 mods to sascalc/sasgui to enble error free setup.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/sas/sasgui/perspectives/fitting/fitting.py

    • Property mode changed from 100644 to 100755
    rc416a17 rfa81e94  
    1111#copyright 2009, University of Tennessee 
    1212################################################################################ 
    13 from __future__ import print_function 
     13 
    1414 
    1515import re 
     
    142142        Given an ID create a fitproblem container 
    143143        """ 
    144         if page_id in self.page_finder.iterkeys(): 
     144        if page_id in iter(self.page_finder.keys()): 
    145145            del self.page_finder[page_id] 
    146146 
     
    335335            if temp: 
    336336                # Set the new plugin model list for all fit pages 
    337                 for uid, page in self.fit_panel.opened_pages.iteritems(): 
     337                for uid, page in self.fit_panel.opened_pages.items(): 
    338338                    if hasattr(page, "formfactorbox"): 
    339339                        page.model_list_box = temp 
     
    350350                                page.formfactorbox.SetLabel(current_val) 
    351351        except: 
    352             logger.error("update_custom_combo: %s", sys.exc_value) 
     352            logger.error("update_custom_combo: %s", sys.exc_info()[1]) 
    353353 
    354354    def set_edit_menu(self, owner): 
     
    556556        else: 
    557557            if len(data_list) > MAX_NBR_DATA: 
    558                 from fitting_widgets import DataDialog 
     558                from .fitting_widgets import DataDialog 
    559559                dlg = DataDialog(data_list=data_list, nb_data=MAX_NBR_DATA) 
    560560                if dlg.ShowModal() == wx.ID_OK: 
     
    576576                        self.add_fit_page(data=[data]) 
    577577            except: 
    578                 msg = "Fitting set_data: " + str(sys.exc_value) 
     578                msg = "Fitting set_data: " + str(sys.exc_info()[1]) 
    579579                wx.PostEvent(self.parent, StatusEvent(status=msg, info="error")) 
    580580 
     
    590590                msg = "Fitting: cannot deal with the theory received" 
    591591                evt = StatusEvent(status=msg, info="error") 
    592                 logger.error("set_theory " + msg + "\n" + str(sys.exc_value)) 
     592                logger.error("set_theory " + msg + "\n" + str(sys.exc_info()[1])) 
    593593                wx.PostEvent(self.parent, evt) 
    594594 
     
    602602        """ 
    603603        from pagestate import PageState 
    604         from simfitpage import SimFitPageState 
     604        from .simfitpage import SimFitPageState 
    605605        if isinstance(state, PageState): 
    606606            state = state.clone() 
     
    713713        if fid is None: 
    714714            return 
    715         if uid in self.page_finder.keys(): 
     715        if uid in list(self.page_finder.keys()): 
    716716            self.page_finder[uid].set_weight(flag=flag, is2d=is2d) 
    717717 
     
    726726        :param qmax: maximum  value of the fit range 
    727727        """ 
    728         if uid in self.page_finder.keys(): 
     728        if uid in list(self.page_finder.keys()): 
    729729            self.page_finder[uid].set_range(qmin=qmin, qmax=qmax, fid=fid) 
    730730 
     
    737737        :param uid: the id related to a page contaning fitting information 
    738738        """ 
    739         if uid in self.page_finder.keys(): 
     739        if uid in list(self.page_finder.keys()): 
    740740            self.page_finder[uid].schedule_tofit(value) 
    741741 
     
    756756        """ 
    757757        sim_page_id = self.sim_page.uid 
    758         for uid, value in self.page_finder.iteritems(): 
     758        for uid, value in self.page_finder.items(): 
    759759            if uid != sim_page_id and uid != self.batch_page.uid: 
    760760                model_list = value.get_model() 
     
    821821        Stop the fit 
    822822        """ 
    823         if uid in self.fit_thread_list.keys(): 
     823        if uid in list(self.fit_thread_list.keys()): 
    824824            calc_fit = self.fit_thread_list[uid] 
    825825            if calc_fit is not  None and calc_fit.isrunning(): 
     
    833833        batch_flag = self.batch_page is not None and uid == self.batch_page.uid 
    834834        if sim_flag or batch_flag: 
    835             for uid, value in self.page_finder.iteritems(): 
     835            for uid, value in self.page_finder.items(): 
    836836                if value.get_scheduled() == 1: 
    837                     if uid in self.fit_panel.opened_pages.keys(): 
     837                    if uid in list(self.fit_panel.opened_pages.keys()): 
    838838                        panel = self.fit_panel.opened_pages[uid] 
    839839                        panel._on_fit_complete() 
     
    852852        :param draw: Determine if the theory needs to be plot 
    853853        """ 
    854         if uid not in self.page_finder.keys(): 
     854        if uid not in list(self.page_finder.keys()): 
    855855            return 
    856856        self.page_finder[uid].enable_smearing(flag=enable_smearer) 
     
    964964        list_page_id = [] 
    965965        fit_id = 0 
    966         for page_id, page_info in self.page_finder.iteritems(): 
     966        for page_id, page_info in self.page_finder.items(): 
    967967            # For simulfit (uid give with None), do for-loop 
    968968            # if uid is specified (singlefit), do it only on the page. 
     
    991991 
    992992                    pars = [str(element[1]) for element in page.param_toFit] 
    993                     fitproblem_list = page_info.values() 
     993                    fitproblem_list = list(page_info.values()) 
    994994                    for fitproblem in  fitproblem_list: 
    995995                        if sim_fitter is None: 
     
    10131013            except: 
    10141014                raise 
    1015                 msg = "Fitting error: %s" % str(sys.exc_value) 
     1015                msg = "Fitting error: %s" % str(sys.exc_info()[1]) 
    10161016                evt = StatusEvent(status=msg, info="error", type="stop") 
    10171017                wx.PostEvent(self.parent, evt) 
     
    10701070        :param fid: the id of the fitproblem(data, model, range,etc) 
    10711071        """ 
    1072         if uid not in self.page_finder.keys(): 
     1072        if uid not in list(self.page_finder.keys()): 
    10731073            return 
    10741074        fitproblemList = self.page_finder[uid].get_fit_problem(fid) 
     
    11161116                wx.PostEvent(self.parent, evt) 
    11171117        except: 
    1118             msg = "Creating Fit page: %s" % sys.exc_value 
     1118            msg = "Creating Fit page: %s" % sys.exc_info()[1] 
    11191119            wx.PostEvent(self.parent, StatusEvent(status=msg, info="error")) 
    11201120 
     
    11961196        # case that uid is not specified 
    11971197        if uid is None: 
    1198             for page_id in self.page_finder.keys(): 
     1198            for page_id in list(self.page_finder.keys()): 
    11991199                self.page_finder[page_id].schedule_tofit(value) 
    12001200        # when uid is given 
    12011201        else: 
    1202             if uid in self.page_finder.keys(): 
     1202            if uid in list(self.page_finder.keys()): 
    12031203                self.page_finder[uid].schedule_tofit(value) 
    12041204 
     
    12341234        panel = self.plot_panel 
    12351235        if panel is None: 
    1236             raise ValueError, "Fitting:_onSelect: NonType panel" 
     1236            raise ValueError("Fitting:_onSelect: NonType panel") 
    12371237        Plugin.on_perspective(self, event=event) 
    12381238        self.select_data(panel) 
     
    12671267        """ 
    12681268        uid = page_id[0] 
    1269         if uid in self.fit_thread_list.keys(): 
     1269        if uid in list(self.fit_thread_list.keys()): 
    12701270            del self.fit_thread_list[uid] 
    12711271 
     
    12931293                #get all fittable parameters of the current model 
    12941294                for param in  model.getParamList(): 
    1295                     if param  not in batch_outputs.keys(): 
     1295                    if param  not in list(batch_outputs.keys()): 
    12961296                        batch_outputs[param] = [] 
    12971297                for param in model.getDispParamList(): 
    12981298                    if not model.is_fittable(param) and \ 
    1299                         param in batch_outputs.keys(): 
     1299                        param in list(batch_outputs.keys()): 
    13001300                        del batch_outputs[param] 
    13011301                # Add fitted parameters and their error 
    13021302                for param in res.param_list: 
    1303                     if param not in batch_outputs.keys(): 
     1303                    if param not in list(batch_outputs.keys()): 
    13041304                        batch_outputs[param] = [] 
    13051305                    err_param = "error on %s" % str(param) 
    1306                     if err_param not in batch_inputs.keys(): 
     1306                    if err_param not in list(batch_inputs.keys()): 
    13071307                        batch_inputs[err_param] = [] 
    13081308        msg = "" 
     
    13891389                #model 
    13901390                EMPTY = "-" 
    1391                 for key in batch_outputs.keys(): 
     1391                for key in list(batch_outputs.keys()): 
    13921392                    if key not in param_list and key not in ["Chi2", "Data"]: 
    13931393                        batch_outputs[key].append(EMPTY) 
     
    14321432        tbatch_outputs = {} 
    14331433        shownkeystr = cpage.get_copy_params() 
    1434         for key in batch_outputs.keys(): 
     1434        for key in list(batch_outputs.keys()): 
    14351435            if key in ["Chi2", "Data"] or shownkeystr.count(key) > 0: 
    14361436                tbatch_outputs[key] = batch_outputs[key] 
     
    14521452        model = fitproblem.get_model() 
    14531453        #fill batch result information 
    1454         if "Data" not in batch_outputs.keys(): 
     1454        if "Data" not in list(batch_outputs.keys()): 
    14551455            batch_outputs["Data"] = [] 
    14561456        from sas.sasgui.guiframe.data_processor import BatchCell 
     
    14821482        cell.object = [data, theory_data] 
    14831483        batch_outputs["Data"].append(cell) 
    1484         for key, value in data.meta_data.iteritems(): 
    1485             if key not in batch_inputs.keys(): 
     1484        for key, value in data.meta_data.items(): 
     1485            if key not in list(batch_inputs.keys()): 
    14861486                batch_inputs[key] = [] 
    14871487            #if key.lower().strip() != "loader": 
     
    14891489        param = "temperature" 
    14901490        if hasattr(data.sample, param): 
    1491             if param not in  batch_inputs.keys(): 
     1491            if param not in  list(batch_inputs.keys()): 
    14921492                batch_inputs[param] = [] 
    14931493            batch_inputs[param].append(data.sample.temperature) 
     
    15621562        except: 
    15631563            msg = ("Fit completed but the following error occurred: %s" 
    1564                    % sys.exc_value) 
     1564                   % sys.exc_info()[1]) 
    15651565            #import traceback; msg = "\n".join((traceback.format_exc(), msg)) 
    15661566            evt = StatusEvent(status=msg, info="warning", type="stop") 
     
    16501650        if model is None: 
    16511651            return 
    1652         if uid not in self.page_finder.keys(): 
     1652        if uid not in list(self.page_finder.keys()): 
    16531653            return 
    16541654        # save the name containing the data name with the appropriate model 
     
    19031903            return None 
    19041904        try: 
    1905             from model_thread import Calc2D 
     1905            from .model_thread import Calc2D 
    19061906            ## If a thread is already started, stop it 
    19071907            if (self.calc_2D is not None) and self.calc_2D.isrunning(): 
     
    19501950            return 
    19511951        try: 
    1952             from model_thread import Calc1D 
     1952            from .model_thread import Calc1D 
    19531953            ## If a thread is already started, stop it 
    19541954            if (self.calc_1D is not None) and self.calc_1D.isrunning(): 
     
    19891989        except: 
    19901990            msg = " Error occurred when drawing %s Model 1D: " % model.name 
    1991             msg += " %s" % sys.exc_value 
     1991            msg += " %s" % sys.exc_info()[1] 
    19921992            wx.PostEvent(self.parent, StatusEvent(status=msg)) 
    19931993 
Note: See TracChangeset for help on using the changeset viewer.