Changeset 6e6dd4c in sasview for src


Ignore:
Timestamp:
Apr 16, 2017 12:27:35 PM (7 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.2.2, ticket-1009, ticket-1094-headless, ticket-1242-2d-resolution, ticket-1243, ticket-1249, ticket885, unittest-saveload
Children:
914c49d5
Parents:
3e5648b (diff), e5cbbce (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.
Message:

Merge branch 'master' into batch_slicer

Location:
src/sas
Files:
1 added
1 deleted
5 edited
1 moved

Legend:

Unmodified
Added
Removed
  • src/sas/sasgui/guiframe/gui_manager.py

    r49165488 r2f22db9  
    7777    # clean all these module variables and put them into a config class 
    7878    # that can be passed by sasview.py. 
    79     logger.info(sys.executable) 
    80     logger.info(str(sys.argv)) 
     79    logger.debug(sys.executable) 
     80    logger.debug(str(sys.argv)) 
    8181    from sas import sasview as sasview 
    8282    app_path = os.path.dirname(sasview.__file__) 
    83     logger.info("Using application path: %s", app_path) 
     83    logger.debug("Using application path: %s", app_path) 
    8484    return app_path 
    8585 
     
    109109        if fObj is not None: 
    110110            fObj.close() 
    111     logger.info("GuiManager loaded %s/%s" % (path, file)) 
     111    logger.debug("GuiManager loaded %s/%s" % (path, file)) 
    112112    return config_module 
    113113 
     
    126126        # Didn't find local config, load the default 
    127127        import sas.sasgui.guiframe.config as config 
    128         logger.info("using default local_config") 
     128        logger.debug("using default local_config") 
    129129    else: 
    130         logger.info("found local_config in %s" % os.getcwd()) 
     130        logger.debug("found local_config in %s" % os.getcwd()) 
    131131else: 
    132     logger.info("found local_config in %s" % PATH_APP) 
     132    logger.debug("found local_config in %s" % PATH_APP) 
    133133 
    134134from sas.sasgui.guiframe.customdir import SetupCustom 
     
    139139    if custom_config is None: 
    140140        msgConfig = "Custom_config file was not imported" 
    141         logger.info(msgConfig) 
     141        logger.debug(msgConfig) 
    142142    else: 
    143         logger.info("using custom_config in %s" % os.getcwd()) 
     143        logger.debug("using custom_config in %s" % os.getcwd()) 
    144144else: 
    145     logger.info("using custom_config from %s" % c_conf_dir) 
     145    logger.debug("using custom_config from %s" % c_conf_dir) 
    146146 
    147147# read some constants from config 
     
    21292129                if "SAS_OPENCL" in line: 
    21302130                    if sas_opencl: 
    2131                         new_config_lines.append("SAS_OPENCL = \""+sas_opencl+"\"") 
     2131                        new_config_lines.append("SAS_OPENCL = \"" + sas_opencl 
     2132                                                + "\"\n") 
    21322133                    else: 
    2133                         new_config_lines.append("SAS_OPENCL = None") 
     2134                        new_config_lines.append("SAS_OPENCL = \"None\"\n") 
    21342135                else: 
    21352136                    new_config_lines.append(line) 
     
    21562157        if response is not None: 
    21572158            try: 
    2158                 #  
    21592159                content = response.read().strip() 
    2160                 logger.info("Connected to www.sasview.org. Latest version: %s" 
    2161                              % (content)) 
     2160                logger.info("Connected to www.sasview.org. Latest version: %s", content) 
    21622161                version_info = json.loads(content) 
    21632162            except: 
  • src/sas/sasgui/perspectives/calculator/sld_panel.py

    r7432acb r2d220dd  
    6060        # Object that receive status event 
    6161        self.base = base 
    62         self.wavelength = WAVELENGTH 
     62        self.neutron_wavelength = WAVELENGTH 
     63        self.xray_source_input = WAVELENGTH 
    6364        self.parent = parent 
    6465        #layout attribute 
     
    6768        self.compound = "" 
    6869        self.density = "" 
    69         self.wavelength_ctl = None 
     70        self.neutron_wavelength_ctl = None 
     71        self.xray_source_input_ctl = None 
     72        self.xray_cbox = None 
    7073        self.neutron_sld_real_ctl = None 
    7174        self.neutron_sld_im_ctl = None 
    72         self.mo_ka_sld_real_ctl = None 
    73         self.mo_ka_sld_im_ctl = None 
    74         self.cu_ka_sld_real_ctl = None 
    75         self.cu_ka_sld_im_ctl = None 
     75        self.xray_sld_real_ctl = None 
     76        self.xray_sld_im_ctl = None 
    7677        self.neutron_abs_ctl = None 
    7778        self.neutron_inc_ctl = None 
    7879        self.neutron_length_ctl = None 
    7980        self.button_calculate = None 
     81        self.xray_source = None 
    8082        #Draw the panel 
    8183        self._do_layout() 
    8284        self.SetAutoLayout(True) 
    8385        self.Layout() 
     86        self.fill_xray_cbox() 
    8487 
    8588    def _do_layout(self): 
     
    108111        self.density_ctl = wx.TextCtrl(self, -1, size=(_BOX_WIDTH, -1)) 
    109112        unit_density_txt = wx.StaticText(self, -1, unit_density) 
    110         wavelength_txt = wx.StaticText(self, -1, 'Wavelength ') 
    111         self.wavelength_ctl = wx.TextCtrl(self, -1, size=(_BOX_WIDTH, -1)) 
    112         self.wavelength_ctl.SetValue(str(self.wavelength)) 
    113         unit_a_txt = wx.StaticText(self, -1, unit_a) 
     113        neutron_wavelength_txt = wx.StaticText(self, -1, 'Neutron wavelength') 
     114        self.neutron_wavelength_ctl = wx.TextCtrl(self, -1, size=(_BOX_WIDTH, -1)) 
     115        self.neutron_wavelength_ctl.SetValue(str(self.neutron_wavelength)) 
     116        self.xray_source_input_txt = wx.StaticText(self, -1, 'X-ray wavelength') 
     117        self.xray_source_input_ctl = wx.TextCtrl(self, -1, size=(_BOX_WIDTH, -1)) 
     118        self.xray_source_input_ctl.SetValue(str(self.xray_source_input)) 
     119        neutron_unit_a_txt = wx.StaticText(self, -1, unit_a) 
     120 
     121        self.xray_cbox = wx.ComboBox(self, -1, size=(70, 20), style=wx.CB_READONLY) 
     122        xray_cbox_tip = "Select an element, wavelength or energy" 
     123        self.xray_cbox.SetToolTipString(xray_cbox_tip) 
     124        wx.EVT_COMBOBOX(self.xray_cbox, -1, self.on_select_xray) 
     125 
    114126        iy = 0 
    115127        ix = 0 
     
    131143        iy += 1 
    132144        ix = 0 
    133         sizer_input.Add(wavelength_txt, (iy, ix), (1, 1), 
    134                              wx.LEFT | wx.EXPAND | wx.ADJUST_MINSIZE, 15) 
    135         ix += 1 
    136         sizer_input.Add(self.wavelength_ctl, (iy, ix), (1, 1), 
    137                             wx.EXPAND | wx.ADJUST_MINSIZE, 0) 
    138         ix += 1 
    139         sizer_input.Add(unit_a_txt, (iy, ix), (1, 1), 
     145        sizer_input.Add(neutron_wavelength_txt, (iy, ix), (1, 1), 
     146                             wx.LEFT | wx.EXPAND | wx.ADJUST_MINSIZE, 15) 
     147        ix += 1 
     148        sizer_input.Add(self.neutron_wavelength_ctl, (iy, ix), (1, 1), 
     149                            wx.EXPAND | wx.ADJUST_MINSIZE, 0) 
     150        ix += 1 
     151        sizer_input.Add(neutron_unit_a_txt, (iy, ix), (1, 1), 
     152                            wx.EXPAND | wx.ADJUST_MINSIZE, 0) 
     153        iy += 1 
     154        ix = 0 
     155        sizer_input.Add(self.xray_source_input_txt, (iy, ix), (1, 1), 
     156                             wx.LEFT | wx.EXPAND | wx.ADJUST_MINSIZE, 15) 
     157        ix += 1 
     158        sizer_input.Add(self.xray_source_input_ctl, (iy, ix), (1, 1), 
     159                            wx.EXPAND | wx.ADJUST_MINSIZE, 0) 
     160        ix += 1 
     161        sizer_input.Add(self.xray_cbox, (iy, ix), (1, 1), 
    140162                            wx.EXPAND | wx.ADJUST_MINSIZE, 0) 
    141163        boxsizer1.Add(sizer_input) 
     
    151173                                                 size=(_BOX_WIDTH, -1)) 
    152174        self.neutron_sld_real_ctl.SetEditable(False) 
    153         self.neutron_sld_real_ctl.SetToolTipString("Neutron SLD real.") 
     175        self.neutron_sld_real_ctl.SetToolTipString("Neutron SLD real") 
    154176        self.neutron_sld_im_ctl = wx.TextCtrl(self, -1, 
    155177                                              size=(_BOX_WIDTH, -1)) 
    156178        self.neutron_sld_im_ctl.SetEditable(False) 
    157         self.neutron_sld_im_ctl.SetToolTipString("Neutron SLD imaginary.") 
     179        self.neutron_sld_im_ctl.SetToolTipString("Neutron SLD imaginary") 
    158180        neutron_sld_units_txt = wx.StaticText(self, -1, unit_sld) 
    159181 
    160         cu_ka_sld_txt = wx.StaticText(self, -1, 'Cu Ka SLD') 
    161         self.cu_ka_sld_real_ctl = wx.TextCtrl(self, -1, 
     182        xray_sld_txt = wx.StaticText(self, -1, 'X-ray SLD') 
     183        self.xray_sld_real_ctl = wx.TextCtrl(self, -1, 
    162184                                               size=(_BOX_WIDTH, -1)) 
    163         self.cu_ka_sld_real_ctl.SetEditable(False) 
    164         self.cu_ka_sld_real_ctl.SetToolTipString("Cu Ka SLD real.") 
    165         self.cu_ka_sld_im_ctl = wx.TextCtrl(self, -1, 
     185        self.xray_sld_real_ctl.SetEditable(False) 
     186        self.xray_sld_real_ctl.SetToolTipString("X-ray SLD real") 
     187        self.xray_sld_im_ctl = wx.TextCtrl(self, -1, 
    166188                                            size=(_BOX_WIDTH, -1)) 
    167         self.cu_ka_sld_im_ctl.SetEditable(False) 
    168         self.cu_ka_sld_im_ctl.SetToolTipString("Cu Ka SLD imaginary.") 
    169         cu_ka_sld_units_txt = wx.StaticText(self, -1, unit_sld) 
    170  
    171         mo_ka_sld_txt = wx.StaticText(self, -1, 'Mo Ka SLD') 
    172         self.mo_ka_sld_real_ctl = wx.TextCtrl(self, -1, 
    173                                                size=(_BOX_WIDTH, -1)) 
    174         self.mo_ka_sld_real_ctl.SetEditable(False) 
    175         self.mo_ka_sld_real_ctl.SetToolTipString("Mo Ka SLD real.") 
    176         self.mo_ka_sld_im_ctl = wx.TextCtrl(self, -1, 
    177                                              size=(_BOX_WIDTH, -1)) 
    178         self.mo_ka_sld_im_ctl.SetEditable(False) 
    179         self.mo_ka_sld_im_ctl.SetToolTipString("Mo Ka SLD imaginary.") 
    180         mo_ka_sld_units_txt = wx.StaticText(self, -1, unit_sld) 
     189        self.xray_sld_im_ctl.SetEditable(False) 
     190        self.xray_sld_im_ctl.SetToolTipString("X-ray SLD imaginary") 
     191        xray_sld_units_txt = wx.StaticText(self, -1, unit_sld) 
    181192 
    182193        neutron_inc_txt = wx.StaticText(self, -1, 'Neutron Inc. Xs') 
     
    219230        iy += 1 
    220231        ix = 0 
    221         sizer_output.Add(cu_ka_sld_txt, (iy, ix), (1, 1), 
    222                              wx.LEFT | wx.EXPAND | wx.ADJUST_MINSIZE, 15) 
    223         ix += 1 
    224         sizer_output.Add(self.cu_ka_sld_real_ctl, (iy, ix), (1, 1), 
     232        sizer_output.Add(xray_sld_txt, (iy, ix), (1, 1), 
     233                             wx.LEFT | wx.EXPAND | wx.ADJUST_MINSIZE, 15) 
     234        ix += 1 
     235        sizer_output.Add(self.xray_sld_real_ctl, (iy, ix), (1, 1), 
    225236                            wx.EXPAND | wx.ADJUST_MINSIZE, 0) 
    226237        ix += 1 
     
    228239                         (iy, ix), (1, 1), wx.EXPAND | wx.ADJUST_MINSIZE, 0) 
    229240        ix += 1 
    230         sizer_output.Add(self.cu_ka_sld_im_ctl, 
     241        sizer_output.Add(self.xray_sld_im_ctl, 
    231242                         (iy, ix), (1, 1), wx.EXPAND | wx.ADJUST_MINSIZE, 0) 
    232243        ix += 1 
    233         sizer_output.Add(cu_ka_sld_units_txt, 
    234                          (iy, ix), (1, 1), wx.EXPAND | wx.ADJUST_MINSIZE, 0) 
    235         iy += 1 
    236         ix = 0 
    237         sizer_output.Add(mo_ka_sld_txt, (iy, ix), (1, 1), 
    238                              wx.LEFT | wx.EXPAND | wx.ADJUST_MINSIZE, 15) 
    239         ix += 1 
    240         sizer_output.Add(self.mo_ka_sld_real_ctl, (iy, ix), (1, 1), 
    241                             wx.EXPAND | wx.ADJUST_MINSIZE, 0) 
    242         ix += 1 
    243         sizer_output.Add(wx.StaticText(self, -1, i_complex), 
    244                          (iy, ix), (1, 1), wx.EXPAND | wx.ADJUST_MINSIZE, 0) 
    245         ix += 1 
    246         sizer_output.Add(self.mo_ka_sld_im_ctl, 
    247                          (iy, ix), (1, 1), wx.EXPAND | wx.ADJUST_MINSIZE, 0) 
    248         ix += 1 
    249         sizer_output.Add(mo_ka_sld_units_txt, 
     244        sizer_output.Add(xray_sld_units_txt, 
    250245                         (iy, ix), (1, 1), wx.EXPAND | wx.ADJUST_MINSIZE, 0) 
    251246        iy += 1 
     
    310305        self.SetSizer(vbox) 
    311306 
     307    def fill_xray_cbox(self): 
     308        """ 
     309        fill the x-ray combobox with the sources 
     310        """ 
     311        source_list = ['[A]', '[keV]', 'Element'] 
     312        for source in source_list: 
     313            pos = self.xray_cbox.Append(str(source)) 
     314            self.xray_cbox.SetClientData(pos, str(source.strip())) 
     315        self.xray_cbox.SetSelection(0) 
     316        self.xray_source = source_list[0] 
     317 
     318    def on_select_xray(self, event=None): 
     319        """ 
     320        On Selecting a source 
     321        """ 
     322        item = event.GetEventObject() 
     323        self.xray_source = item.GetValue().strip() 
     324 
     325        if self.xray_source == "[A]": 
     326            self.xray_source_input_txt.SetLabel("X-ray wavelength") 
     327        elif self.xray_source == "[keV]": 
     328            self.xray_source_input_txt.SetLabel("X-ray energy") 
     329        elif self.xray_source == "Element": 
     330            self.xray_source_input_txt.SetLabel("X-ray source") 
     331 
    312332    def on_help(self, event): 
    313333        """ 
     
    363383            msg += "Error for Density value :expect float" 
    364384 
    365         self.wavelength = self.wavelength_ctl.GetValue() 
    366         if str(self.wavelength).lstrip().rstrip() == "": 
    367             self.wavelength = WAVELENGTH 
    368             self.wavelength_ctl.SetValue(str(WAVELENGTH)) 
    369             self.wavelength_ctl.SetBackgroundColour(wx.WHITE) 
    370             self.wavelength_ctl.Refresh() 
     385        self.neutron_wavelength = self.neutron_wavelength_ctl.GetValue() 
     386        self.xray_source_input = self.xray_source_input_ctl.GetValue() 
     387 
     388        if str(self.neutron_wavelength).lstrip().rstrip() == "": 
     389            self.neutron_wavelength = WAVELENGTH 
     390            self.neutron_wavelength_ctl.SetValue(str(WAVELENGTH)) 
     391            self.neutron_wavelength_ctl.SetBackgroundColour(wx.WHITE) 
     392            self.neutron_wavelength_ctl.Refresh() 
    371393            msg += "Default value for wavelength is 6.0" 
    372394        else: 
    373             if check_float(self.wavelength_ctl): 
    374                 self.wavelength = float(self.wavelength) 
     395            if check_float(self.neutron_wavelength_ctl): 
     396                self.neutron_wavelength = float(self.neutron_wavelength) 
    375397            else: 
    376398                flag = False 
    377399                msg += "Error for wavelength value :expect float" 
     400 
     401        if str(self.xray_source_input).lstrip().rstrip() == "": 
     402            self.xray_source_input = WAVELENGTH 
     403            self.xray_source_input_ctl.SetValue(str(WAVELENGTH)) 
     404            self.xray_source_input_ctl.SetBackgroundColour(wx.WHITE) 
     405            self.xray_source_input_ctl.Refresh() 
     406            msg += "Default value for wavelength is 6.0" 
     407        else: 
     408            if (self.xray_source == '[A]') or (self.xray_source == '[keV]'): 
     409                if check_float(self.xray_source_input_ctl): 
     410                    self.xray_source_input = float(self.xray_source_input) 
     411                else: 
     412                    flag = False 
     413                    msg += "Error for wavelength value :expect float" 
     414            elif (self.xray_source == 'Element'): 
     415                try: 
     416                    import periodictable 
     417                    exec("periodictable." + self.xray_source_input) 
     418                except AttributeError: 
     419                    flag = False 
     420                    msg += "X-ray element supplied isn't in the database" 
     421 
     422 
    378423 
    379424        self.compound = self.compound_ctl.GetValue().lstrip().rstrip() 
     
    410455        return xray_sld_from_atoms(atom, density=density, energy=energy) 
    411456 
    412  
    413457    def calculateSld(self, event): 
    414458        """ 
     
    430474                        length = neutron_scattering(compound=self.compound, 
    431475                                   density=self.density, 
    432                                    wavelength=self.wavelength) 
    433             cu_real, cu_im = self.calculate_sld_helper(element="Cu", 
    434                                                  density=self.density, 
    435                                         molecule_formula=self.sld_formula) 
    436             mo_real, mo_im = self.calculate_sld_helper(element="Mo", 
    437                                                        density=self.density, 
    438                                      molecule_formula=self.sld_formula) 
     476                                   wavelength=self.neutron_wavelength) 
     477            if self.xray_source == "[A]": 
     478                energy = xray_energy(self.xray_source_input) 
     479                xray_real, xray_im = xray_sld_from_atoms(self.sld_formula.atoms, 
     480                                                         density=self.density, 
     481                                                         energy=energy) 
     482            elif self.xray_source == "[keV]": 
     483                xray_real, xray_im = xray_sld_from_atoms(self.sld_formula.atoms, 
     484                                                         density=self.density, 
     485                                                         energy=self.xray_source_input) 
     486            elif self.xray_source == "Element": 
     487                xray_real, xray_im = self.calculate_sld_helper(element=self.xray_source_input, 
     488                                                               density=self.density, 
     489                                                               molecule_formula=self.sld_formula) 
    439490            # set neutron sld values 
    440491            val = format_number(sld_real * _SCALE) 
     
    443494            self.neutron_sld_im_ctl.SetValue(val) 
    444495            # Compute the Cu SLD 
    445             self.cu_ka_sld_real_ctl.SetValue(format_number(cu_real * _SCALE)) 
    446             val = format_number(math.fabs(cu_im) * _SCALE) 
    447             self.cu_ka_sld_im_ctl.SetValue(val) 
    448             # Compute the Mo SLD 
    449             self.mo_ka_sld_real_ctl.SetValue(format_number(mo_real * _SCALE)) 
    450             val = format_number(math.fabs(mo_im) * _SCALE) 
    451             self.mo_ka_sld_im_ctl.SetValue(val) 
     496            self.xray_sld_real_ctl.SetValue(format_number(xray_real * _SCALE)) 
     497            val = format_number(math.fabs(xray_im) * _SCALE) 
     498            self.xray_sld_im_ctl.SetValue(val) 
    452499            # set incoherence and absorption 
    453500            self.neutron_inc_ctl.SetValue(format_number(incoh)) 
     
    456503            self.neutron_length_ctl.SetValue(format_number(length)) 
    457504            # display wavelength 
    458             self.wavelength_ctl.SetValue(str(self.wavelength)) 
     505            #self.wavelength_ctl.SetValue(str(self.wavelength)) 
     506            #self.wavelength_ctl.SetValue(str(self.wavelength)) 
    459507        except: 
    460508            if self.base is not None: 
     
    470518        self.neutron_sld_real_ctl.SetValue("") 
    471519        self.neutron_sld_im_ctl.SetValue("") 
    472         self.mo_ka_sld_real_ctl.SetValue("") 
    473         self.mo_ka_sld_im_ctl.SetValue("") 
    474         self.cu_ka_sld_real_ctl.SetValue("") 
    475         self.cu_ka_sld_im_ctl.SetValue("") 
     520        self.xray_sld_real_ctl.SetValue("") 
     521        self.xray_sld_im_ctl.SetValue("") 
    476522        self.neutron_abs_ctl.SetValue("") 
    477523        self.neutron_inc_ctl.SetValue("") 
  • src/sas/sascalc/dataloader/manipulations.py

    r7432acb r3e5648b  
    430430            z_max = max(data2D.q_data) 
    431431            z_min = min(data2D.q_data) 
    432             x_max = data2D.dqx_data[data2D.q_data[z_max]] 
    433             x_min = data2D.dqx_data[data2D.q_data[z_min]] 
    434             y_max = data2D.dqy_data[data2D.q_data[z_max]] 
    435             y_min = data2D.dqy_data[data2D.q_data[z_min]] 
     432            x_max = data2D.dqx_data[numpy.where(data2D.q_data == z_max)] 
     433            x_min = data2D.dqx_data[numpy.where(data2D.q_data == z_min)] 
     434            y_max = data2D.dqy_data[numpy.where(data2D.q_data == z_max)] 
     435            y_min = data2D.dqy_data[numpy.where(data2D.q_data == z_min)] 
    436436            # Find qdx at q = 0 
    437437            dq_overlap_x = (x_min * z_max - x_max * z_min) / (z_max - z_min) 
     
    785785            z_max = max(data2D.q_data) 
    786786            z_min = min(data2D.q_data) 
    787             x_max = data2D.dqx_data[data2D.q_data[z_max]] 
    788             x_min = data2D.dqx_data[data2D.q_data[z_min]] 
    789             y_max = data2D.dqy_data[data2D.q_data[z_max]] 
    790             y_min = data2D.dqy_data[data2D.q_data[z_min]] 
     787            x_max = data2D.dqx_data[numpy.where(data2D.q_data == z_max)] 
     788            x_min = data2D.dqx_data[numpy.where(data2D.q_data == z_min)] 
     789            y_max = data2D.dqy_data[numpy.where(data2D.q_data == z_max)] 
     790            y_min = data2D.dqy_data[numpy.where(data2D.q_data == z_min)] 
    791791            # Find qdx at q = 0 
    792792            dq_overlap_x = (x_min * z_max - x_max * z_min) / (z_max - z_min) 
  • src/sas/sasgui/guiframe/local_perspectives/plotting/Plotter2D.py

    r7432acb r3e5648b  
    361361                if self.slicer.__class__.__name__ != "BoxSum": 
    362362                    wx_id = ids.next() 
    363                     slicerpop.Append(wx_id, '&Edit Slicer Parameters') 
     363                    name = '&Edit Slicer Parameters and Batch Slicing' 
     364                    slicerpop.Append(wx_id, name) 
    364365                    wx.EVT_MENU(self, wx_id, self._onEditSlicer) 
    365366            slicerpop.AppendSeparator() 
     
    532533 
    533534        """ 
    534         ## Clear current slicer 
     535        # Clear current slicer 
    535536        if self.slicer is not None: 
    536537            self.slicer.clear() 
    537         ## Create a new slicer 
     538        # Create a new slicer 
    538539        self.slicer_z += 1 
    539540        self.slicer = slicer(self, self.subplot, zorder=self.slicer_z) 
    540541        self.subplot.set_ylim(self.data2D.ymin, self.data2D.ymax) 
    541542        self.subplot.set_xlim(self.data2D.xmin, self.data2D.xmax) 
    542         ## Draw slicer 
     543        # Draw slicer 
    543544        self.update() 
    544545        self.slicer.update() 
     
    572573        npt = math.floor(npt) 
    573574        from sas.sascalc.dataloader.manipulations import CircularAverage 
    574         ## compute the maximum radius of data2D 
     575        # compute the maximum radius of data2D 
    575576        self.qmax = max(math.fabs(self.data2D.xmax), 
    576577                        math.fabs(self.data2D.xmin)) 
     
    578579                        math.fabs(self.data2D.ymin)) 
    579580        self.radius = math.sqrt(math.pow(self.qmax, 2) + math.pow(self.ymax, 2)) 
    580         ##Compute beam width 
     581        # Compute beam width 
    581582        bin_width = (self.qmax + self.qmax) / npt 
    582         ## Create data1D circular average of data2D 
     583        # Create data1D circular average of data2D 
    583584        Circle = CircularAverage(r_min=0, r_max=self.radius, 
    584585                                 bin_width=bin_width) 
     
    599600        new_plot.name = "Circ avg " + self.data2D.name 
    600601        new_plot.source = self.data2D.source 
    601         #new_plot.info = self.data2D.info 
     602        # new_plot.info = self.data2D.info 
    602603        new_plot.interactive = True 
    603604        new_plot.detector = self.data2D.detector 
    604605 
    605         ## If the data file does not tell us what the axes are, just assume... 
     606        # If the data file does not tell us what the axes are, just assume... 
    606607        new_plot.xaxis("\\rm{Q}", "A^{-1}") 
    607608        if hasattr(self.data2D, "scale") and \ 
     
    615616        new_plot.id = "Circ avg " + self.data2D.name 
    616617        new_plot.is_data = True 
    617         self.parent.update_theory(data_id=self.data2D.id, \ 
    618                                        theory=new_plot) 
     618        self.parent.update_theory(data_id=self.data2D.id, theory=new_plot) 
    619619        wx.PostEvent(self.parent, 
    620620                     NewPlotEvent(plot=new_plot, title=new_plot.name)) 
     
    630630        """ 
    631631        if self.slicer is not None: 
    632             from SlicerParameters import SlicerParameterPanel 
     632            from parameters_panel_slicer import SlicerParameterPanel 
    633633            dialog = SlicerParameterPanel(self, -1, "Slicer Parameters") 
    634634            dialog.set_slicer(self.slicer.__class__.__name__, 
     
    668668        params = self.slicer.get_params() 
    669669        ## Create a new panel to display results of summation of Data2D 
    670         from slicerpanel import SlicerPanel 
     670        from parameters_panel_boxsum import SlicerPanel 
    671671        win = MDIFrame(self.parent, None, 'None', (100, 200)) 
    672672        new_panel = SlicerPanel(parent=win, id=-1, 
     
    758758        if default_name.count('.') > 0: 
    759759            default_name = default_name.split('.')[0] 
    760         #default_name += "_out" 
    761760        if self.parent is not None: 
    762761            self.parent.show_data2d(data, default_name) 
    763762 
    764763    def modifyGraphAppearance(self, e): 
    765         self.graphApp = graphAppearance(self, 'Modify graph appearance', legend=False) 
     764        self.graphApp = graphAppearance(self, 'Modify graph appearance', 
     765                                        legend=False) 
    766766        self.graphApp.setDefaults(self.grid_on, self.legend_on, 
    767767                                  self.xaxis_label, self.yaxis_label, 
  • src/sas/sasgui/guiframe/local_perspectives/plotting/parameters_panel_boxsum.py

    r7432acb r37d461c  
    11import wx 
    22import wx.lib.newevent 
    3 #from copy import deepcopy 
     3from parameters_panel_slicer import SlicerParameterPanel 
    44from sas.sasgui.guiframe.utils import format_number 
    5 from sas.sasgui.guiframe.events import SlicerParameterEvent 
    6 from sas.sasgui.guiframe.events import EVT_SLICER_PARS 
    7 from sas.sasgui.guiframe.events import EVT_SLICER 
     5from sas.sasgui.guiframe.panel_base import PanelBase 
     6from sas.sasgui.guiframe.events import (SlicerParameterEvent, EVT_SLICER_PARS, 
     7                                        EVT_SLICER) 
    88 
    9 from sas.sasgui.guiframe.panel_base import PanelBase 
    109 
    1110class SlicerPanel(wx.Panel, PanelBase): 
     
    1312    Panel class to show the slicer parameters 
    1413    """ 
    15     #TODO: show units 
    16     #TODO: order parameters properly 
    17     ## Internal name for the AUI manager 
     14    # Internal name for the AUI manager 
    1815    window_name = "Slicer panel" 
    19     ## Title to appear on top of the window 
     16    # Title to appear on top of the window 
    2017    window_caption = "Slicer Panel" 
    2118    CENTER_PANE = False 
     
    2522        wx.Panel.__init__(self, parent, id, *args, **kwargs) 
    2623        PanelBase.__init__(self) 
    27         ## Initialization of the class 
     24        # Initialization of the class 
    2825        self.base = base 
    2926        if params is None: 
     
    4441        else: 
    4542            self.set_slicer(type, params) 
    46         ## Bindings 
    47         self.parent.Bind(EVT_SLICER, self.onEVT_SLICER) 
    48         self.parent.Bind(EVT_SLICER_PARS, self.onParamChange) 
    49  
    50     def onEVT_SLICER(self, event): 
    51         """ 
    52         Process EVT_SLICER events 
    53         When the slicer changes, update the panel 
    54  
    55         :param event: EVT_SLICER event 
    56  
    57         """ 
    58         event.Skip() 
    59         if event.obj_class is None: 
    60             self.set_slicer(None, None) 
    61         else: 
    62             self.set_slicer(event.type, event.params) 
     43        # Bindings 
     44        self.parent.Bind(EVT_SLICER, SlicerParameterPanel.on_evt_slicer) 
     45        self.parent.Bind(EVT_SLICER_PARS, SlicerParameterPanel.on_param_change) 
    6346 
    6447    def set_slicer(self, type, params): 
     
    8467            keys.sort() 
    8568            for item in keys: 
    86                 if not item.lower() in ["num_points", "avg", "avg_error", "sum", "sum_error"]: 
     69                if not item.lower() in ["num_points", "avg", "avg_error", "sum", 
     70                                        "sum_error"]: 
    8771                    n += 1 
    8872                    text = wx.StaticText(self, -1, item, style=wx.ALIGN_LEFT) 
    8973                    self.bck.Add(text, (n - 1, 0), 
    90                                  flag=wx.LEFT | wx.ALIGN_CENTER_VERTICAL, border=15) 
     74                                 flag=wx.LEFT | wx.ALIGN_CENTER_VERTICAL, 
     75                                 border=15) 
    9176                    ctl = wx.TextCtrl(self, -1, size=(80, 20), 
    9277                                      style=wx.TE_PROCESS_ENTER) 
     
    9580                    ctl.SetToolTipString(hint_msg) 
    9681                    ctl.SetValue(str(format_number(params[item]))) 
    97                     self.Bind(wx.EVT_TEXT_ENTER, self.onTextEnter) 
    98                     ctl.Bind(wx.EVT_SET_FOCUS, self.onSetFocus) 
    99                     ctl.Bind(wx.EVT_KILL_FOCUS, self.onTextEnter) 
     82                    self.Bind(wx.EVT_TEXT_ENTER, self.on_text_enter) 
     83                    ctl.Bind(wx.EVT_SET_FOCUS, self.on_set_focus) 
     84                    ctl.Bind(wx.EVT_KILL_FOCUS, self.on_text_enter) 
    10085                    self.parameters.append([item, ctl]) 
    101                     self.bck.Add(ctl, (n - 1, 1), flag=wx.TOP | wx.BOTTOM, border=0) 
     86                    self.bck.Add(ctl, (n - 1, 1), flag=wx.TOP | wx.BOTTOM, 
     87                                 border=0) 
    10288            for item in keys: 
    103                 if  item.lower() in ["num_points", "avg", "avg_error", "sum", "sum_error"]: 
     89                if item.lower() in ["num_points", "avg", "avg_error", "sum", 
     90                                    "sum_error"]: 
    10491                    n += 1 
    105                     text = wx.StaticText(self, -1, item + ": ", style=wx.ALIGN_LEFT) 
    106                     self.bck.Add(text, (n - 1, 0), flag=wx.LEFT | wx.ALIGN_CENTER_VERTICAL, 
     92                    text = wx.StaticText(self, -1, item + ": ", 
     93                                         style=wx.ALIGN_LEFT) 
     94                    self.bck.Add(text, (n - 1, 0), 
     95                                 flag=wx.LEFT | wx.ALIGN_CENTER_VERTICAL, 
    10796                                 border=15) 
    10897                    ctl = wx.StaticText(self, -1, 
     
    11099                                        style=wx.ALIGN_LEFT) 
    111100                    ctl.SetToolTipString("Result %s" % item) 
    112                     self.bck.Add(ctl, (n - 1, 1), flag=wx.TOP | wx.BOTTOM, border=0) 
     101                    self.bck.Add(ctl, (n - 1, 1), flag=wx.TOP | wx.BOTTOM, 
     102                                 border=0) 
    113103        self.bck.Layout() 
    114104        self.Layout() 
    115         psizer = self.parent.GetSizer() 
    116         if psizer is not None: 
    117             psizer.Layout() 
     105        p_sizer = self.parent.GetSizer() 
     106        if p_sizer is not None: 
     107            p_sizer.Layout() 
    118108 
    119     def onSetFocus(self, evt): 
     109    def on_set_focus(self, evt): 
    120110        """ 
    121111        Highlight the txtcrtl 
     
    126116        # Select the whole control, after this event resolves 
    127117        wx.CallAfter(widget.SetSelection, -1, -1) 
    128         return 
    129118 
    130     def onParamChange(self, evt): 
    131         """ 
    132         Receive and event and reset the text field contained in self.parameters 
    133  
    134         """ 
    135         evt.Skip() 
    136         for item in self.parameters: 
    137             if item[0] in evt.params: 
    138                 item[1].SetValue(format_number(evt.params[item[0]])) 
    139                 item[1].Refresh() 
    140  
    141     def onTextEnter(self, evt): 
     119    def on_text_enter(self, evt): 
    142120        """ 
    143121        Parameters have changed 
     
    149127            try: 
    150128                params[item[0]] = float(item[1].GetValue()) 
    151                 item[1].SetBackgroundColour(wx.SystemSettings_GetColour(wx.SYS_COLOUR_WINDOW)) 
     129                item[1].SetBackgroundColour(wx.SystemSettings_GetColour( 
     130                    wx.SYS_COLOUR_WINDOW)) 
    152131                item[1].Refresh() 
    153132            except: 
     
    155134                item[1].SetBackgroundColour("pink") 
    156135                item[1].Refresh() 
    157  
    158         if has_error == False: 
     136        if not has_error: 
    159137            # Post parameter event 
    160             ## base is guiframe is this case 
     138            # base is guiframe is this case 
    161139            event = SlicerParameterEvent(type=self.type, params=params) 
    162140            wx.PostEvent(self.base, event) 
     
    166144        On Close Event 
    167145        """ 
    168         ID = self.uid 
    169         self.parent.delete_panel(ID) 
     146        uid = self.uid 
     147        self.parent.delete_panel(uid) 
    170148        self.frame.Destroy() 
  • src/sas/sasgui/perspectives/fitting/basepage.py

    r9c0f3c17 rac0578c  
    252252        if not hasattr(self, "model_view"): 
    253253            return 
    254         toggle_mode_on = self.model_view.IsEnabled() 
     254        toggle_mode_on = self.model_view.IsEnabled() or self.data is None 
    255255        if toggle_mode_on: 
    256256            if self.enable2D and not check_data_validity(self.data): 
Note: See TracChangeset for help on using the changeset viewer.