Changeset afd45674 in sasview


Ignore:
Timestamp:
Jan 18, 2013 6:05:38 PM (12 years ago)
Author:
Jae Cho <jhjcho@…>
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:
afcb052
Parents:
1c6c1b7
Message:

Added total volume param in the sasgen model

Files:
4 edited

Legend:

Unmodified
Added
Removed
  • calculatorview/src/sans/perspectives/calculator/gen_scatter_panel.py

    rfad6056 rafd45674  
    580580        self.model.set_is_avg(is_avg) 
    581581        self.model.set_sld_data(self.sld_data) 
     582         
    582583        self.draw_button.Enable(self.sld_data!=None) 
    583584        wx.CallAfter(self.parent.set_sld_data, self.sld_data) 
     585        self._update_model_params() 
    584586        if is_draw: 
    585587            wx.CallAfter(self.sld_draw, False) 
    586              
     588     
     589    def _update_model_params(self): 
     590        """ 
     591        Update the model parameter values 
     592        """ 
     593        for list in self.parameters: 
     594            param_name = list[0].GetLabelText() 
     595            val = str(self.model.params[param_name]) 
     596            list[1].SetValue(val) 
     597     
     598    def set_volume_ctl_val(self, val): 
     599        """ 
     600        Set volume txtctrl value 
     601        """ 
     602        for list in self.parameters: 
     603            param_name = list[0].GetLabelText() 
     604            if param_name.lower() == 'total_volume': 
     605                list[1].SetValue(val) 
     606                list[1].Refresh() 
     607                break 
     608                             
    587609    def _onparamEnter(self, event): 
    588610        """ 
     
    787809            return 
    788810        try: 
    789             #vol = self.parent.get_pix_volumes() 
    790             #self.model.set_pixel_volumes(vol) 
    791811            self.model.set_sld_data(self.sld_data) 
    792812            self.set_input_params() 
     
    15221542                    nop = npts 
    15231543                self.display_npts(nop) 
     1544                 
    15241545        ctl.Refresh() 
    15251546        return flag 
    15261547     
     1548    def _set_volume_ctr_val(self, npts): 
     1549        """ 
     1550        Set total volume 
     1551        """ 
     1552        total_volume = npts * self.sld_data.vol_pix[0] 
     1553        self.parent.set_volume_ctr_val(total_volume) 
     1554                     
    15271555    def _onstepsize(self, event): 
    15281556        """ 
     
    15471575                        s_size *= s_val 
    15481576                self.sld_data.set_pixel_volumes(s_size) 
     1577                if ctl.IsEnabled(): 
     1578                    total_volume = sum(self.sld_data.vol_pix) 
     1579                    self.parent.set_volume_ctr_val(total_volume) 
    15491580            except: 
    15501581                pass 
     
    15721603            self.npix_ctl.Refresh() 
    15731604            self.parent.set_etime() 
     1605            wx.CallAfter(self._set_volume_ctr_val, nop) 
    15741606        except: 
    15751607            # On Init 
     
    16071639    """ 
    16081640    def __init__(self, parent=None, title="Generic Scattering Calculator", 
    1609                 size=(PANEL_WIDTH * 1.3, PANEL_HEIGHT * 1.57), *args, **kwds): 
     1641                size=(PANEL_WIDTH * 1.3, PANEL_HEIGHT * 1.65), *args, **kwds): 
    16101642        """ 
    16111643        Init 
     
    18351867        return vol 
    18361868     
     1869    def set_volume_ctr_val(self, val): 
     1870        """ 
     1871        Set volume txtctl value 
     1872        """ 
     1873        try: 
     1874            self.panel.set_volume_ctl_val(str(val)) 
     1875        except: 
     1876            print "self.panel is not initialized yet" 
     1877             
    18371878    def set_omfpanel_default_shap(self, shape): 
    18381879        """ 
  • calculatorview/src/sans/perspectives/calculator/media/gen_sans_help.html

    r3657667 rafd45674  
    2727for &#946;<sub>j</sub> &#8800; 0 where v<sub>j</sub> is the volume of the j'th pixel  
    2828(or the j'th natural atomic volume (= atomic mass/natural molar density/Abogadro number)  
    29  for the atomic structures given by a pdb file). 
     29 for the atomic structures). The total volume V can be corrected by users.  
     30This correction is useful especially for an atomic structure (taken from a pdb file) to get the right  
     31normalization. Note that the  &#946;<sub>j</sub> displayed in GUI may be incorrect but will not  
     32affect the scattering computation if the correction of the total volume is made. 
    3033<br> 
    3134The scattering length density (SLD) of each pixel where the SLD is uniform, is a combination of the nuclear and magnetic SLDs  
  • sanscalculator/src/sans/calculator/sans_gen.py

    rcd89c6f rafd45674  
    6161        self.params['background']  = 0.0 
    6262        self.params['solvent_SLD']     = 0.0 
     63        self.params['total_volume'] = 1.0 
    6364        self.params['Up_frac_in']     = 1.0 
    6465        self.params['Up_frac_out']    = 1.0 
     
    7071        self.details['background'] = ['[1/cm]', None, None] 
    7172        self.details['solvent_SLD']    = ['1/A^(2)', None, None] 
     73        self.details['total_volume']    = ['A^(3)', None, None] 
    7274        self.details['Up_frac_in']    = ['[u/(u+d)]', None, None] 
    7375        self.details['Up_frac_out']   = ['[u/(u+d)]', None, None] 
     
    113115 
    114116        mod.genicom(model, len_q, x, y, i) 
    115         return  self.params['scale'] * i + self.params['background'] 
     117        vol_correction = self.data_total_volume / self.params['total_volume'] 
     118        return  self.params['scale'] * vol_correction * i + \ 
     119                        self.params['background'] 
    116120         
    117121    def set_sld_data(self, sld_data=None):    
     
    129133        self.data_mz = sld_data.sld_mz 
    130134        self.data_vol = sld_data.vol_pix 
     135        self.data_total_volume = sum(sld_data.vol_pix) 
     136        self.params['total_volume'] = sum(sld_data.vol_pix) 
    131137         
    132138    def getProfile(self): 
Note: See TracChangeset for help on using the changeset viewer.