Changeset 0688888 in sasview for src/sas/sasgui


Ignore:
Timestamp:
Jan 30, 2017 11:36:25 AM (7 years ago)
Author:
GitHub <noreply@…>
Parents:
c6f3aec (diff), 12361fd (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.
git-author:
Jeff Krzywon <krzywon@…> (01/30/17 11:36:25)
git-committer:
GitHub <noreply@…> (01/30/17 11:36:25)
Message:

Merge 12361fdbc5e39477eb96b1b8744cf20d36a4f405 into c6f3aec14a3a1dac9b891b8f3a61aeecf0ebe5dd

Location:
src/sas/sasgui
Files:
1 added
18 edited

Legend:

Unmodified
Added
Removed
  • src/sas/sasgui/guiframe/local_perspectives/plotting/plotting.py

    r6ffa0dd rca224b1  
    134134        """ 
    135135        for group_id in self.plot_panels.keys(): 
    136             panel = self.plot_panels[group_id] 
    137             panel.graph.reset() 
    138             self.hide_panel(group_id) 
     136            self.clear_panel_by_id(group_id) 
    139137        self.plot_panels = {} 
    140138 
  • src/sas/sasgui/perspectives/fitting/basepage.py

    r505706a ra6fccd7  
    11051105        """ 
    11061106        for key, value in self.master_category_dict.iteritems(): 
     1107            formfactor = state.formfactorcombobox.split(":") 
     1108            if isinstance(formfactor, list): 
     1109                formfactor = formfactor[0] 
    11071110            for list_item in value: 
    1108                 if state.formfactorcombobox in list_item: 
     1111                if formfactor in list_item: 
    11091112                    return self.categorybox.Items.index(key) 
    11101113        return 0 
     
    11521155        self._show_combox_helper() 
    11531156        # select the current model 
    1154         try: 
    1155             # to support older version 
    1156             category_pos = int(state.categorycombobox) 
    1157         except: 
    1158             state.formfactorcombobox = state.formfactorcombobox.lower() 
    1159             state.formfactorcombobox = \ 
    1160                 state.formfactorcombobox.replace('model', '') 
    1161             state.formfactorcombobox = unicode(state.formfactorcombobox) 
    1162             state.categorycombobox = unicode(state.categorycombobox) 
    1163             if state.categorycombobox in self.categorybox.Items: 
    1164                 category_pos = self.categorybox.Items.index( 
    1165                     state.categorycombobox) 
    1166             else: 
    1167                 # Look in master list for model name (model.lower) 
    1168                 category_pos = self.get_cat_combo_box_pos(state) 
     1157        state._convert_to_sasmodels() 
     1158        state.categorycombobox = unicode(state.categorycombobox) 
     1159        if state.categorycombobox in self.categorybox.Items: 
     1160            category_pos = self.categorybox.Items.index( 
     1161                state.categorycombobox) 
     1162        else: 
     1163            # Look in master list for model name (model.lower) 
     1164            category_pos = self.get_cat_combo_box_pos(state) 
    11691165 
    11701166        self.categorybox.Select(category_pos) 
    11711167        self._show_combox(None) 
    1172         try: 
    1173             # to support older version 
    1174             formfactor_pos = int(state.formfactorcombobox) 
    1175         except: 
    1176             formfactor_pos = 0 
    1177             for ind_form in range(self.formfactorbox.GetCount()): 
    1178                 if self.formfactorbox.GetString(ind_form) == \ 
    1179                                                     (state.formfactorcombobox): 
    1180                     formfactor_pos = int(ind_form) 
     1168        from models import PLUGIN_NAME_BASE 
     1169        if self.categorybox.GetValue() == 'Customized Models' \ 
     1170                and PLUGIN_NAME_BASE not in state.formfactorcombobox: 
     1171            state.formfactorcombobox = \ 
     1172                PLUGIN_NAME_BASE + state.formfactorcombobox 
     1173        formfactor_pos = 0 
     1174        for ind_form in range(self.formfactorbox.GetCount()): 
     1175            if self.formfactorbox.GetString(ind_form) == \ 
     1176                                                (state.formfactorcombobox): 
     1177                formfactor_pos = int(ind_form) 
     1178                break 
     1179 
     1180        self.formfactorbox.Select(formfactor_pos) 
     1181 
     1182        structfactor_pos = 0 
     1183        if state.structurecombobox is not None: 
     1184            state.structurecombobox = unicode(state.structurecombobox) 
     1185            for ind_struct in range(self.structurebox.GetCount()): 
     1186                if self.structurebox.GetString(ind_struct) == \ 
     1187                                                (state.structurecombobox): 
     1188                    structfactor_pos = int(ind_struct) 
    11811189                    break 
    1182  
    1183         self.formfactorbox.Select(formfactor_pos) 
    1184  
    1185         structfactor_pos = 0 
    1186         try: 
    1187             # to support older version 
    1188             structfactor_pos = int(state.structurecombobox) 
    1189         except: 
    1190             if state.structurecombobox is not None: 
    1191                 state.structurecombobox = unicode(state.structurecombobox) 
    1192                 for ind_struct in range(self.structurebox.GetCount()): 
    1193                     if self.structurebox.GetString(ind_struct) == \ 
    1194                                                     (state.structurecombobox): 
    1195                         structfactor_pos = int(ind_struct) 
    1196                         break 
    11971190 
    11981191        self.structurebox.SetSelection(structfactor_pos) 
     
    13841377        # self.state.struct_rbutton = self.struct_rbutton.GetValue() 
    13851378        # self.state.plugin_rbutton = self.plugin_rbutton.GetValue() 
    1386         self.state.structurecombobox = self.structurebox.GetLabel() 
    1387         self.state.formfactorcombobox = self.formfactorbox.GetLabel() 
    1388         self.state.categorycombobox = self.categorybox.GetLabel() 
     1379        self.state.structurecombobox = self.structurebox.GetValue() 
     1380        self.state.formfactorcombobox = self.formfactorbox.GetValue() 
     1381        self.state.categorycombobox = self.categorybox.GetValue() 
    13891382 
    13901383        # post state to fit panel 
     
    15871580        if len(statelist) == 0 or len(listtorestore) == 0: 
    15881581            return 
    1589         if len(statelist) != len(listtorestore): 
    1590             return 
    15911582 
    15921583        for j in range(len(listtorestore)): 
    1593             item_page = listtorestore[j] 
    1594             item_page_info = statelist[j] 
    1595             # change the state of the check box for simple parameters 
    1596             if item_page[0] is not None: 
    1597                 item_page[0].SetValue(item_page_info[0]) 
    1598             if item_page[2] is not None: 
    1599                 item_page[2].SetValue(item_page_info[2]) 
    1600                 if item_page[2].__class__.__name__ == "ComboBox": 
    1601                     if item_page_info[2] in self.model.fun_list: 
    1602                         fun_val = self.model.fun_list[item_page_info[2]] 
    1603                         self.model.setParam(item_page_info[1], fun_val) 
    1604             if item_page[3] is not None: 
    1605                 # show or hide text +/- 
    1606                 if item_page_info[2]: 
    1607                     item_page[3].Show(True) 
    1608                 else: 
    1609                     item_page[3].Hide() 
    1610             if item_page[4] is not None: 
    1611                 # show of hide the text crtl for fitting error 
    1612                 if item_page_info[4][0]: 
    1613                     item_page[4].Show(True) 
    1614                     item_page[4].SetValue(item_page_info[4][1]) 
    1615                 else: 
    1616                     item_page[3].Hide() 
    1617             if item_page[5] is not None: 
    1618                 # show of hide the text crtl for fitting error 
    1619                 item_page[5].Show(item_page_info[5][0]) 
    1620                 item_page[5].SetValue(item_page_info[5][1]) 
    1621  
    1622             if item_page[6] is not None: 
    1623                 # show of hide the text crtl for fitting error 
    1624                 item_page[6].Show(item_page_info[6][0]) 
    1625                 item_page[6].SetValue(item_page_info[6][1]) 
     1584            for param in statelist: 
     1585                if param[1] == listtorestore[j][1]: 
     1586                    item_page = listtorestore[j] 
     1587                    item_page_info = param 
     1588                    if (item_page_info[1] == "theta" or item_page_info[1] == 
     1589                            "phi") and not self._is_2D(): 
     1590                        break 
     1591                    # change the state of the check box for simple parameters 
     1592                    if item_page[0] is not None: 
     1593                        item_page[0].SetValue(item_page_info[0]) 
     1594                    if item_page[2] is not None: 
     1595                        item_page[2].SetValue(item_page_info[2]) 
     1596                        if item_page[2].__class__.__name__ == "ComboBox": 
     1597                            if item_page_info[2] in self.model.fun_list: 
     1598                                fun_val = self.model.fun_list[item_page_info[2]] 
     1599                                self.model.setParam(item_page_info[1], fun_val) 
     1600                    if item_page[3] is not None: 
     1601                        # show or hide text +/- 
     1602                        if item_page_info[2]: 
     1603                            item_page[3].Show(True) 
     1604                        else: 
     1605                            item_page[3].Hide() 
     1606                    if item_page[4] is not None: 
     1607                        # show of hide the text crtl for fitting error 
     1608                        if item_page_info[4][0]: 
     1609                            item_page[4].Show(True) 
     1610                            item_page[4].SetValue(str(item_page_info[4][1])) 
     1611                        else: 
     1612                            item_page[3].Hide() 
     1613                    if item_page[5] is not None: 
     1614                        # show of hide the text crtl for fitting error 
     1615                        item_page[5].Show(True) 
     1616                        item_page[5].SetValue(str(item_page_info[5][1])) 
     1617                    if item_page[6] is not None: 
     1618                        # show of hide the text crtl for fitting error 
     1619                        item_page[6].Show(True) 
     1620                        item_page[6].SetValue(str(item_page_info[6][1])) 
     1621                    break 
    16261622 
    16271623    def _reset_strparam_state(self, listtorestore, statelist): 
  • src/sas/sasgui/perspectives/fitting/fitpage.py

    r24fd27a ra6fccd7  
    11901190        self.state.slit_smearer = self.slit_smearer.GetValue() 
    11911191 
    1192         self.state.structurecombobox = self.structurebox.GetLabel() 
    1193         self.state.formfactorcombobox = self.formfactorbox.GetLabel() 
     1192        self.state.structurecombobox = self.structurebox.GetValue() 
     1193        self.state.formfactorcombobox = self.formfactorbox.GetValue() 
     1194        self.state.categorycombobox = self.categorybox.GetValue() 
    11941195        self.enable_fit_button() 
    11951196        if self.model is not None: 
  • src/sas/sasgui/perspectives/fitting/models.py

    r313c5c9 r0de74af  
    2323PLUGIN_LOG = os.path.join(os.path.expanduser("~"), '.sasview', PLUGIN_DIR, 
    2424                          "plugins.log") 
     25PLUGIN_NAME_BASE = '[plug-in] ' 
    2526 
    2627def get_model_python_path(): 
     
    181182            try: 
    182183                model = load_custom_model(path) 
    183                 model.name = "[plug-in] "+model.name 
     184                model.name = PLUGIN_NAME_BASE + model.name 
    184185                plugins[model.name] = model 
    185186            except Exception: 
  • src/sas/sasgui/perspectives/fitting/pagestate.py

    rc8e1996 r12361fd  
    2525from lxml import etree 
    2626 
     27from sasmodels import convert 
    2728import sasmodels.weights 
    2829 
     
    271272        # store value of chisqr 
    272273        self.tcChi = None 
     274        self.version = (1,0,0) 
    273275 
    274276    def clone(self): 
     
    349351        obj.cb1 = copy.deepcopy(self.cb1) 
    350352        obj.smearer = copy.deepcopy(self.smearer) 
     353        obj.version = copy.deepcopy(self.version) 
    351354 
    352355        for name, state in self.saved_states.iteritems(): 
     
    355358            obj.saved_states[copy_name] = copy_state 
    356359        return obj 
     360 
     361    def _old_first_model(self): 
     362        """ 
     363        Handle save states from 4.0.1 and before where the first item in the 
     364        selection boxes of category, formfactor and structurefactor were not 
     365        saved. 
     366        :return: None 
     367        """ 
     368        if self.formfactorcombobox == '': 
     369            if self.categorycombobox == '' and len(self.parameters) == 3: 
     370                self.categorycombobox = "Shape-Independent" 
     371                self.formfactorcombobox = 'PowerLawAbsModel' 
     372            elif self.categorycombobox == '' and len(self.parameters) == 9: 
     373                self.categorycombobox = 'Cylinder' 
     374                self.formfactorcombobox = 'barbell' 
     375            elif self.categorycombobox == 'Shapes': 
     376                self.formfactorcombobox = 'BCCrystalModel' 
     377            elif self.categorycombobox == 'Uncategorized': 
     378                self.formfactorcombobox = 'LineModel' 
     379            elif self.categorycombobox == 'StructureFactor': 
     380                self.structurecombobox = 'HardsphereStructure' 
     381            elif self.categorycombobox == 'Customized Models': 
     382                self.formfactorcombobox = 'MySumFunction' 
     383            elif self.categorycombobox == 'Ellipsoid': 
     384                self.formfactorcombobox = 'core_shell_ellipsoid' 
     385            elif self.categorycombobox == 'Lamellae': 
     386                self.formfactorcombobox = 'lamellar' 
     387            elif self.categorycombobox == 'Paracrystal': 
     388                self.formfactorcombobox = 'bcc_paracrystal' 
     389            elif self.categorycombobox == 'Parallelepiped': 
     390                self.formfactorcombobox = 'core_shell_parallelepiped' 
     391            elif self.categorycombobox == 'Shape Independent': 
     392                self.formfactorcombobox = 'be_polyelectrolyte' 
     393            elif self.categorycombobox == 'Sphere': 
     394                self.formfactorcombobox = 'adsorbed_layer' 
     395            elif self.categorycombobox == 'Structure Factor': 
     396                self.formfactorcombobox = 'hardsphere' 
     397 
     398    @staticmethod 
     399    def param_remap_to_sasmodels_convert(params, is_string=False): 
     400        """ 
     401        Remaps the parameters for sasmodels conversion 
     402 
     403        :param params: list of parameters (likely self.parameters) 
     404        :return: remapped dictionary of parameters 
     405        """ 
     406        p = dict() 
     407        for fittable, name, value, _, uncert, lower, upper, units in params: 
     408            if not value: 
     409                value = numpy.nan 
     410            if not uncert or uncert[1] == '' or uncert[1] == 'None': 
     411                uncert[0] = False 
     412                uncert[1] = numpy.nan 
     413            if not upper or upper[1] == '' or upper[1] == 'None': 
     414                upper[0] = False 
     415                upper[1] = numpy.nan 
     416            if not lower or lower[1] == '' or lower[1] == 'None': 
     417                lower[0] = False 
     418                lower[1] = numpy.nan 
     419            if is_string: 
     420                p[name] = str(value) 
     421            else: 
     422                p[name] = float(value) 
     423            p[name + ".fittable"] = bool(fittable) 
     424            p[name + ".std"] = float(uncert[1]) 
     425            p[name + ".upper"] = float(upper[1]) 
     426            p[name + ".lower"] = float(lower[1]) 
     427            p[name + ".units"] = units 
     428        return p 
     429 
     430    @staticmethod 
     431    def param_remap_from_sasmodels_convert(params): 
     432        """ 
     433        Converts {name : value} map back to [] param list 
     434        :param params: parameter map returned from sasmodels 
     435        :return: None 
     436        """ 
     437        p_map = [] 
     438        for name, info in params.iteritems(): 
     439            if ".fittable" in name or ".std" in name or ".upper" in name or \ 
     440                            ".lower" in name or ".units" in name: 
     441                pass 
     442            else: 
     443                fittable = params.get(name + ".fittable", True) 
     444                std = params.get(name + ".std", '0.0') 
     445                upper = params.get(name + ".upper", 'inf') 
     446                lower = params.get(name + ".lower", '-inf') 
     447                units = params.get(name + ".units") 
     448                if std is not None and std is not numpy.nan: 
     449                    std = [True, str(std)] 
     450                else: 
     451                    std = [False, ''] 
     452                if lower is not None and lower is not numpy.nan: 
     453                    lower = [True, str(lower)] 
     454                else: 
     455                    lower = [True, '-inf'] 
     456                if upper is not None and upper is not numpy.nan: 
     457                    upper = [True, str(upper)] 
     458                else: 
     459                    upper = [True, 'inf'] 
     460                param_list = [bool(fittable), str(name), str(info), 
     461                              "+/-", std, lower, upper, str(units)] 
     462                p_map.append(param_list) 
     463        return p_map 
     464 
     465    def _convert_to_sasmodels(self): 
     466        """ 
     467        Convert parameters to a form usable by sasmodels converter 
     468 
     469        :return: None 
     470        """ 
     471        # Create conversion dictionary to send to sasmodels 
     472        self._old_first_model() 
     473        p = self.param_remap_to_sasmodels_convert(self.parameters) 
     474        structurefactor, params = convert.convert_model(self.structurecombobox, 
     475                                                        p, False, self.version) 
     476        formfactor, params = convert.convert_model(self.formfactorcombobox, 
     477                                                   params, False, self.version) 
     478        if len(self.str_parameters) > 0: 
     479            str_pars = self.param_remap_to_sasmodels_convert( 
     480                self.str_parameters, True) 
     481            formfactor, str_params = convert.convert_model( 
     482                self.formfactorcombobox, str_pars, False, self.version) 
     483            for key, value in str_params.iteritems(): 
     484                params[key] = value 
     485 
     486        if self.formfactorcombobox == 'SphericalSLDModel': 
     487            self.multi_factor += 1 
     488        self.formfactorcombobox = formfactor 
     489        self.structurecombobox = structurefactor 
     490        self.parameters = [] 
     491        self.parameters = self.param_remap_from_sasmodels_convert(params) 
    357492 
    358493    def _repr_helper(self, list, rep): 
     
    682817 
    683818        attr = newdoc.createAttribute("version") 
    684         attr.nodeValue = '1.0' 
     819        import sasview 
     820        attr.nodeValue = sasview.__version__ 
     821        # attr.nodeValue = '1.0' 
    685822        top_element.setAttributeNode(attr) 
    686823 
     
    8751012            raise RuntimeError, msg 
    8761013 
    877         if node.get('version') and node.get('version') == '1.0': 
     1014        if node.get('version'): 
     1015            # Get the version for model conversion purposes 
     1016            self.version = tuple(int(e) for e in 
     1017                                 str.split(node.get('version'), ".")) 
     1018            # The tuple must be at least 3 items long 
     1019            while len(self.version) < 3: 
     1020                ver_list = list(self.version) 
     1021                ver_list.append(0) 
     1022                self.version = tuple(ver_list) 
    8781023 
    8791024            # Get file name 
     
    16921837                        name = original_fname 
    16931838                    state.data.group_id = name 
     1839                    state.version = fitstate.version 
    16941840                    # store state in fitting 
    16951841                    self.call_back(state=state, 
  • src/sas/sasgui/perspectives/invariant/invariant_state.py

    rcb93b40 rdb5294e  
    423423                    for item in DEFAULT_STATE: 
    424424                        input_field = get_content('ns:%s' % item, entry) 
    425                         val = str(input_field.text.strip()) 
     425                        if input_field.text is not None: 
     426                            val = str(input_field.text.strip()) 
     427                        else: 
     428                            val = '' 
    426429                        if input_field is not None: 
    427430                            temp_state[item] = val 
     
    433436                for item in DEFAULT_STATE: 
    434437                    input_field = get_content('ns:%s' % item, entry) 
    435                     val = str(input_field.text.strip()) 
     438                    if input_field.text is not None: 
     439                        val = str(input_field.text.strip()) 
     440                    else: 
     441                        val = '' 
    436442                    if input_field is not None: 
    437443                        self.set_saved_state(name=item, value=val) 
  • src/sas/sasgui/guiframe/customdir.py

    r212bfc2 r73cbeec  
    3434        if not os.path.isfile(config_file): 
    3535            shutil.copyfile(os.path.join(path, "custom_config.py"), config_file) 
     36 
     37        #Adding SAS_OPENCL if it doesn't exist in the config file 
     38        # - to support backcompability 
     39        if not "SAS_OPENCL" in open(config_file).read(): 
     40            open(config_file,"a+").write("SAS_OPENCL = \"None\"\n") 
    3641    except: 
    3742        # Check for data path next to exe/zip file. 
  • src/sas/sasgui/guiframe/gui_manager.py

    r505706a r73cbeec  
    152152SPLASH_SCREEN_HEIGHT = config.SPLASH_SCREEN_HEIGHT 
    153153SS_MAX_DISPLAY_TIME = config.SS_MAX_DISPLAY_TIME 
     154SAS_OPENCL = config.SAS_OPENCL 
    154155if not WELCOME_PANEL_ON: 
    155156    WELCOME_PANEL_SHOW = False 
     
    176177    else: 
    177178        DEFAULT_OPEN_FOLDER = PATH_APP 
     179    SAS_OPENCL = custom_config.SAS_OPENCL 
    178180except: 
    179181    DATALOADER_SHOW = True 
     
    190192    CLEANUP_PLOT = False 
    191193    DEFAULT_OPEN_FOLDER = PATH_APP 
    192  
     194    SAS_OPENCL = None 
    193195DEFAULT_STYLE = config.DEFAULT_STYLE 
    194196 
     
    225227        CHILD_FRAME = wx.Frame 
    226228 
     229#Initiliaze enviromental variable with custom setting but only if variable not set 
     230if SAS_OPENCL and not "SAS_OPENCL" in os.environ: 
     231    os.environ["SAS_OPENCL"] = SAS_OPENCL 
    227232 
    228233class ViewerFrame(PARENT_FRAME): 
     
    21042109        Quit the application 
    21052110        """ 
     2111        #IF SAS_OPENCL is set, settings are stored in the custom config file 
     2112        self._write_opencl_config_file() 
    21062113        logging.info(" --- SasView session was closed --- \n") 
    21072114        wx.Exit() 
    21082115        sys.exit() 
     2116 
     2117    def _write_opencl_config_file(self): 
     2118        """ 
     2119        Writes OpenCL settings to custom config file, so they can be remmbered 
     2120        from session to session 
     2121        """ 
     2122        if custom_config is not None: 
     2123            sas_opencl = os.environ.get("SAS_OPENCL",None) 
     2124            new_config_lines = [] 
     2125            config_file = open(custom_config.__file__) 
     2126            config_lines = config_file.readlines() 
     2127            for line in config_lines: 
     2128                if "SAS_OPENCL" in line: 
     2129                    if sas_opencl: 
     2130                        new_config_lines.append("SAS_OPENCL = \""+sas_opencl+"\"") 
     2131                    else: 
     2132                        new_config_lines.append("SAS_OPENCL = None") 
     2133                else: 
     2134                    new_config_lines.append(line) 
     2135            config_file.close() 
     2136 
     2137            #If custom_config is None, settings will not be remmbered 
     2138            new_config_file = open(custom_config.__file__,"w") 
     2139            new_config_file.writelines(new_config_lines) 
     2140            new_config_file.close() 
     2141        else: 
     2142            logging.info("Failed to save OPENCL settings in custom config file") 
     2143 
    21092144 
    21102145    def _check_update(self, event=None): 
  • src/sas/sasgui/guiframe/startup_configuration.py

    rd85c194 r73cbeec  
    3131                   'CLEANUP_PLOT':False, 
    3232                   'DEFAULT_PERSPECTIVE':'Fitting', 
    33                    'DEFAULT_OPEN_FOLDER': None} 
     33                   'DEFAULT_OPEN_FOLDER': None, 
     34                   'SAS_OPENCL': None} 
    3435try: 
    3536    CURRENT_STRINGS = {'GUIFRAME_WIDTH':CURRENT.GUIFRAME_WIDTH, 
     
    4546                       'CLEANUP_PLOT':CURRENT.CLEANUP_PLOT, 
    4647                       'DEFAULT_PERSPECTIVE':CURRENT.DEFAULT_PERSPECTIVE, 
    47                        'DEFAULT_OPEN_FOLDER':CURRENT.DEFAULT_OPEN_FOLDER} 
     48                       'DEFAULT_OPEN_FOLDER':CURRENT.DEFAULT_OPEN_FOLDER, 
     49                       'SAS_OPENCL': None} 
    4850except: 
    4951    CURRENT_STRINGS = DEFAULT_STRINGS 
  • src/sas/sasgui/perspectives/corfunc/corfunc.py

    r96d293da r1dc8ec9  
    3232        self._always_active = True 
    3333        self.state_reader = Reader(self.set_state) 
    34         self._extensions = '.cor' 
     34        self._extensions = '.crf' 
    3535 
    3636    def get_panels(self, parent): 
     
    4848 
    4949        l = Loader() 
    50         l.associate_file_reader('.cor', self.state_reader) 
     50        l.associate_file_reader('.crf', self.state_reader) 
    5151 
    5252        return [self.corfunc_panel] 
     
    6767            return [] 
    6868        data = plotpanel.plots[graph.selected_plottable] 
    69         if data.id == IQ_DATA_LABEL or data.id == IQ_EXTRAPOLATED_DATA_LABEL or data.id == TRANSFORM_LABEL: 
     69        if data.id == IQ_DATA_LABEL or data.id == IQ_EXTRAPOLATED_DATA_LABEL or data.id == TRANSFORM_LABEL1 or data.id == TRANSFORM_LABEL3: 
    7070            return [] 
    7171        item = plotpanel.plots[graph.selected_plottable] 
     
    8181    def set_state(self, state=None, datainfo=None): 
    8282        """ 
    83         Callback for CorfuncState reader. Called when a .cor file is loaded 
     83        Callback for CorfuncState reader. Called when a .crf file is loaded 
    8484        """ 
    8585        if isinstance(datainfo, list): 
     
    179179                # Show the extrapolation as a curve instead of points 
    180180                new_plot.symbol = GUIFRAME_ID.CURVE_SYMBOL_NUM 
    181         elif label == TRANSFORM_LABEL: 
     181        elif label == TRANSFORM_LABEL1 or label == TRANSFORM_LABEL3: 
    182182            new_plot.xaxis("{x}", 'A') 
    183183            new_plot.yaxis("{\\Gamma}", '') 
  • src/sas/sasgui/perspectives/corfunc/corfunc_panel.py

    rd45d590 r1dc8ec9  
    274274        plot_x = transform.x[np.where(transform.x <= 200)] 
    275275        plot_y = transform.y[np.where(transform.x <= 200)] 
    276         self._manager.show_data(Data1D(plot_x, plot_y), TRANSFORM_LABEL) 
     276        self._manager.show_data(Data1D(plot_x, plot_y), TRANSFORM_LABEL1) 
    277277        # Only enable extract params button if a fourier trans. has been done 
    278278        if self.transform_type == 'fourier': 
     
    325325        dlg = wx.FileDialog(self, "Choose a file", 
    326326                            default_save_location, \ 
    327                             self.window_caption, "*.cor", wx.SAVE) 
     327                            self.window_caption, "*.crf", wx.SAVE) 
    328328        if dlg.ShowModal() == wx.ID_OK: 
    329329            path = dlg.GetPath() 
     
    336336        dlg.Destroy() 
    337337        # MAC always needs the extension for saving 
    338         extens = ".cor" 
     338        extens = ".crf" 
    339339        # Make sure the ext included in the file name 
    340340        f_name = os.path.splitext(path)[0] + extens 
  • src/sas/sasgui/perspectives/corfunc/corfunc_state.py

    rd45d590 rae9b8bf  
    9696            self.background = value 
    9797 
    98     def toXML(self, filename='corfunc_state.cor', doc=None, entry_node=None): 
     98    def toXML(self, filename='corfunc_state.crf', doc=None, entry_node=None): 
    9999        """ 
    100100        Writes the state of the CorfuncPanel panel to file, as XML. 
     
    257257    type_name = "Corfunc" 
    258258 
    259     type = ["Corfunc file (*.cor)|*.cor", 
     259    type = ["Corfunc file (*.crf)|*.crf", 
    260260            "SASView file (*.svs)|*.svs"] 
    261261 
    262     ext = ['.cor', '.COR', '.svs', '.SVS'] 
     262    ext = ['.crf', '.CRF', '.svs', '.SVS'] 
    263263 
    264264    def __init__(self, callback): 
  • src/sas/sasgui/perspectives/corfunc/plot_labels.py

    rff11b21 r1dc8ec9  
    44 
    55GROUP_ID_TRANSFORM = r"$\Gamma(x)$" 
    6 TRANSFORM_LABEL = r"$\Gamma(x)$" 
     6TRANSFORM_LABEL1 = r"$\Gamma1(x)$" 
     7TRANSFORM_LABEL3 = r"$\Gamma3(x)$" 
  • src/sas/sasgui/perspectives/fitting/fitting.py

    r06a4306 r73cbeec  
    4545from sas.sasgui.guiframe.gui_manager import MDIFrame 
    4646from sas.sasgui.guiframe.documentation_window import DocumentationWindow 
     47from sas.sasgui.perspectives.fitting.gpu_options import GpuOptions 
    4748 
    4849from . import models 
     
    192193        self.bumps_options_menu = self.menu1.FindItemById(self.id_bumps_options) 
    193194        self.bumps_options_menu.Enable(True) 
     195 
     196        self.id_gpu_options_panel = wx.NewId() 
     197        self.menu1.Append(self.id_gpu_options_panel, "OpenCL Options", "Choose OpenCL driver or turn it off") 
     198        wx.EVT_MENU(owner, self.id_gpu_options_panel, self.on_gpu_options) 
    194199 
    195200        self.id_result_panel = wx.NewId() 
     
    801806        self.result_frame.Show() 
    802807        self.result_frame.Raise() 
     808 
     809    def on_gpu_options(self, event=None): 
     810        """ 
     811        Make the Fit Results panel visible. 
     812        """ 
     813        dialog = GpuOptions(None, wx.ID_ANY, "") 
     814        dialog.Show() 
    803815 
    804816    def stop_fit(self, uid): 
  • src/sas/sasgui/perspectives/fitting/media/plugin.rst

    rca1eaeb rca6cbc1c  
    568568    cube(x): 
    569569        $x^3$ 
    570     sinc(x): 
     570    sas_sinx_x(x): 
    571571        $\sin(x)/x$, with limit $\sin(0)/0 = 1$. 
    572572    powr(x, y): 
     
    669669        (`link to Bessel function's code <https://github.com/SasView/sasmodels/tree/master/sasmodels/models/lib/sas_JN.c>`_) 
    670670 
    671     Si(x): 
     671    sas_Si(x): 
    672672        Sine integral $\text{Si}(x) = \int_0^x \tfrac{\sin t}{t}\,dt$. 
    673673 
     
    693693        (`link to code <https://github.com/SasView/sasmodels/tree/master/sasmodels/models/lib/Si.c>`_) 
    694694 
    695     sph_j1c(x): 
     695    sas_3j1x_x(x): 
    696696        Spherical Bessel form 
    697697        $\text{sph_j1c}(x) = 3 j_1(x)/x = 3 (\sin(x) - x \cos(x))/x^3$, 
     
    701701        This function uses a Taylor series for small $x$ for numerical accuracy. 
    702702 
    703         :code:`source = ["lib/sph_j1c.c", ...]` 
    704         (`link to code <https://github.com/SasView/sasmodels/tree/master/sasmodels/models/lib/sph_j1c.c>`_) 
    705  
    706  
    707     sas_J1c(x): 
     703        :code:`source = ["lib/sas_3j1x_x.c", ...]` 
     704        (`link to code <https://github.com/SasView/sasmodels/tree/master/sasmodels/models/lib/sas_3j1x_x.c>`_) 
     705 
     706 
     707    sas_2J1x_x(x): 
    708708        Bessel form $\text{sas_J1c}(x) = 2 J_1(x)/x$, with a limiting value 
    709709        of 1 at $x=0$, where $J_1(x)$ is the Bessel function of first kind 
  • src/sas/sasgui/perspectives/fitting/media/sm_help.rst

    r7805458 r27aabc1  
    2020================== 
    2121 
    22 Sometimes it will be necessary to correct reduced experimental data for the 
    23 physical effects of the instrumental geometry in use. This process is called 
    24 *desmearing*. However, calculated/simulated data - which by definition will be 
    25 perfect/exact - can be *smeared* to make it more representative of what might 
    26 actually be measured experimentally. 
    27  
    28 SasView provides the following three smearing algorithms: 
     22Sometimes the instrumental geometry used to acquire the experimental data has  
     23an impact on the clarity of features in the reduced scattering curve. For  
     24example, peaks or fringes might be slightly broadened. This is known as  
     25*Q resolution smearing*. To compensate for this effect one can either try and  
     26remove the resolution contribution - a process called *desmearing* - or add the  
     27resolution contribution into a model calculation/simulation (which by definition  
     28will be exact) to make it more representative of what has been measured  
     29experimentally - a process called *smearing*. SasView will do the latter. 
     30 
     31Both smearing and desmearing rely on functions to describe the resolution  
     32effect. SasView provides three smearing algorithms: 
    2933 
    3034*  *Slit Smearing* 
    3135*  *Pinhole Smearing* 
    3236*  *2D Smearing* 
     37 
     38SasView also has an option to use Q resolution data (estimated at the time of  
     39data reduction) supplied in a reduced data file: the *Use dQ data* radio button. 
     40 
     41.. ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ 
     42 
     43dQ Smearing 
     44----------- 
     45  
     46If this option is checked, SasView will assume that the supplied dQ values  
     47represent the standard deviations of Gaussian functions. 
    3348 
    3449.. ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ 
  • src/sas/sasgui/perspectives/fitting/model_thread.py

    rd3911e3 rc1681ea  
    197197            output[index] = self.model.evalDistribution(self.data.x[index]) 
    198198 
    199         sq_model = None 
    200         pq_model = None 
     199        sq_values = None 
     200        pq_values = None 
     201        s_model = None 
     202        p_model = None 
    201203        if isinstance(self.model, MultiplicationModel): 
    202             sq_model = numpy.zeros((len(self.data.x))) 
    203             pq_model = numpy.zeros((len(self.data.x))) 
    204             sq_model[index] = self.model.s_model.evalDistribution(self.data.x[index]) 
    205             pq_model[index] = self.model.p_model.evalDistribution(self.data.x[index]) 
     204            s_model = self.model.s_model 
     205            p_model = self.model.p_model 
     206        elif hasattr(self.model, "get_composition_models"): 
     207            p_model, s_model = self.model.get_composition_models() 
     208 
     209        if p_model is not None and s_model is not None: 
     210            sq_values = numpy.zeros((len(self.data.x))) 
     211            pq_values = numpy.zeros((len(self.data.x))) 
     212            sq_values[index] = s_model.evalDistribution(self.data.x[index]) 
     213            pq_values[index] = p_model.evalDistribution(self.data.x[index]) 
    206214 
    207215        elapsed = time.time() - self.starttime 
     
    220228                      unsmeared_data=unsmeared_data, 
    221229                      unsmeared_error=unsmeared_error, 
    222                       pq_model=pq_model, 
    223                       sq_model=sq_model) 
     230                      pq_model=pq_values, 
     231                      sq_model=sq_values) 
    224232 
    225233    def results(self): 
  • src/sas/sasgui/perspectives/pr/media/pr_help.rst

    r0391dae r1221196  
    1010----------- 
    1111 
    12 This tool calculates a real-space distance distribution function, *P(r)*, using  
    13 the inversion approach (Moore, 1908). 
     12This tool calculates a real-space distance distribution function, *P(r)*, using 
     13the inversion approach (Moore, 1980). 
    1414 
    1515*P(r)* is set to be equal to an expansion of base functions of the type 
     
    2424 
    2525  \chi^2=\frac{\sum_i (I_{meas}(Q_i)-I_{th}(Q_i))^2}{error^2}+Reg\_term 
    26    
     26 
    2727 
    2828where $I_{meas}(Q_i)$ is the measured scattering intensity and $I_{th}(Q_i)$ is 
    29 the prediction from the Fourier transform of the *P(r)* expansion.  
     29the prediction from the Fourier transform of the *P(r)* expansion. 
    3030 
    31 The $Reg\_term$ term is a regularization term set to the second derivative  
     31The $Reg\_term$ term is a regularization term set to the second derivative 
    3232$d^2P(r)/d^2r$ integrated over $r$. It is used to produce a smooth *P(r)* output. 
    3333 
     
    4040 
    4141*  *Number of terms*: the number of base functions in the P(r) expansion. 
    42     
     42 
    4343*  *Regularization constant*: a multiplicative constant to set the size of 
    4444   the regularization term. 
Note: See TracChangeset for help on using the changeset viewer.