Changeset 3657667 in sasview


Ignore:
Timestamp:
Jan 12, 2013 2:45:21 PM (11 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:
5917637
Parents:
3540156
Message:

Added arbitrary orientation for pdb atomic data

Files:
4 edited

Legend:

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

    r3540156 r3657667  
    131131        self.file_name = '' 
    132132        self.time_text = None 
     133        self.orient_combo = None 
    133134        self.omfreader = sans_gen.OMFReader() 
    134135        self.sldreader = sans_gen.SLDReader() 
     
    290291        self.parent.set_omfpanel_default_shap(self.default_shape) 
    291292        self.parent.set_omfpanel_npts() 
     293         
     294    def _fill_orient_combo(self): 
     295        """ 
     296        Fill up the orientation combo box: used only for atomic structure 
     297        """ 
     298        orient_combo = wx.ComboBox(self, -1, size=(150, -1),  
     299                                      style=wx.CB_READONLY)  
     300        orient_combo.Append('Fixed orientation') 
     301        orient_combo.Append('No orientation ') 
     302         
     303        orient_combo.Bind(wx.EVT_COMBOBOX, self._on_orient_select) 
     304        orient_combo.SetSelection(0) 
     305        return orient_combo 
     306     
     307    def _on_orient_select(self, event): 
     308        """ 
     309        On selecting a orientation 
     310        """ 
     311        event.Skip() 
     312        cb = event.GetEventObject() 
     313        is_avg = cb.GetCurrentSelection() == 1 
     314        self.model.set_is_avg(is_avg)          
    292315            
    293316    def _layout_qrange(self): 
     
    339362        self.est_time = '*Estimated Computation time : %s sec' 
    340363        self.time_text = wx.StaticText(self, -1, self.est_time% str(2) ) 
     364        self.orient_combo = self._fill_orient_combo() 
     365        self.orient_combo.Show(False) 
    341366        self.bt_compute = wx.Button(self, wx.NewId(),'Compute') 
    342367        self.bt_compute.Bind(wx.EVT_BUTTON, self.on_compute) 
    343368        self.bt_compute.SetToolTipString("Compute 2D Scattering Pattern.") 
    344369        self.button_sizer.AddMany([(self.time_text , 0, wx.LEFT, 20), 
    345                                    (self.bt_compute, 0, wx.LEFT, 190)]) 
     370                                   (self.orient_combo , 0, wx.LEFT, 20), 
     371                                   (self.bt_compute, 0, wx.LEFT, 20)]) 
    346372         
    347373    def estimate_ctime(self): 
    348374        """ 
     375        Calculation time estimation 
    349376        """ 
    350377        n_qbins = float(self.npt_ctl.GetValue()) 
     
    366393    def _do_layout(self): 
    367394        """ 
    368             Draw window content 
     395        Draw window content 
    369396        """ 
    370397        self._define_structure() 
     
    513540            self.data_name_tcl.SetValue(str(filename)) 
    514541            self.file_name = filename.split('.')[0] 
     542            self.orient_combo.SetSelection(0) 
    515543            if self.ext in self.omfreader.ext: 
    516544                gen = sans_gen.OMF2SLD() 
     
    526554            else: 
    527555                raise 
     556            self.orient_combo.Show(is_pdbdata) 
     557            self.button_sizer.Layout() 
    528558            self._set_sld_data_helper(True) 
    529559        except: 
     
    547577        Set sld data helper 
    548578        """ 
     579        is_avg = self.orient_combo.GetCurrentSelection() == 1 
     580        self.model.set_is_avg(is_avg) 
    549581        self.model.set_sld_data(self.sld_data) 
    550582        self.draw_button.Enable(self.sld_data!=None) 
     
    606638        marker = ',' 
    607639        m_size = 2 
    608         if output.pix_type != 'pixel': 
     640        if output.pix_type == 'atom': 
    609641            marker = 'o' 
    610             m_size = 2 
     642            m_size = 3.5 
    611643        pos_x = output.pos_x 
    612644        pos_y = output.pos_y 
     
    614646        sld_mx = output.sld_mx 
    615647        sld_my = output.sld_my 
    616         sld_mz = output.sld_mz   
     648        sld_mz = output.sld_mz  
     649        pix_symbol = output.pix_symbol  
    617650 
    618651        sld_tot = (numpy.fabs(sld_mx) + numpy.fabs(sld_my) +  
     
    632665            sld_my = sld_my[is_nonzero] 
    633666            sld_mz = sld_mz[is_nonzero] 
    634          
     667            pix_symbol = output.pix_symbol[is_nonzero] 
    635668        # Plot selective points in color 
    636         other_color = numpy.ones(len(output.pix_symbol), dtype='bool') 
     669        other_color = numpy.ones(len(pix_symbol), dtype='bool') 
    637670        for key in color_dic.keys(): 
    638             chosen_color = output.pix_symbol == key 
     671            chosen_color = pix_symbol == key 
    639672            if numpy.any(chosen_color): 
    640673                other_color = other_color  & (chosen_color != True) 
     
    15741607    """ 
    15751608    def __init__(self, parent=None, title="Generic Scattering Calculator", 
    1576                 size=(PANEL_WIDTH * 1.3, PANEL_HEIGHT * 1.55), *args, **kwds): 
     1609                size=(PANEL_WIDTH * 1.3, PANEL_HEIGHT * 1.57), *args, **kwds): 
    15771610        """ 
    15781611        Init 
  • calculatorview/src/sans/perspectives/calculator/media/gen_sans_help.html

    rdbc01f2 r3657667  
    2525</p> 
    2626<br> 
    27 for &#946;<sub>j</sub> &#8800; 0 where v<sub>j</sub> is the volume of the j'th pixel. 
     27for &#946;<sub>j</sub> &#8800; 0 where v<sub>j</sub> is the volume of the j'th pixel  
     28(or the j'th natural atomic volume (= atomic mass/natural molar density/Abogadro number)  
     29 for the atomic structures given by a pdb file). 
    2830<br> 
    2931The 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

    r3540156 r3657667  
    88import numpy 
    99import os 
     10import copy 
    1011 
    1112MFactor_AM = 2.853E-12 
     
    5253        self.data_mz = None 
    5354        self.data_vol = None #[A^3] 
     55        self.is_avg = False 
    5456        ## Name of the model 
    5557        self.name = "GenSAS" 
     
    5860        self.params['scale']       = 1.0 
    5961        self.params['background']  = 0.0 
     62        self.params['solvent_SLD']     = 0.0 
    6063        self.params['Up_frac_in']     = 0.5 
    6164        self.params['Up_frac_out']    = 0.5 
     
    6669        self.details['scale']      = ['', None, None] 
    6770        self.details['background'] = ['[1/cm]', None, None] 
     71        self.details['solvent_SLD']    = ['1/A^(2)', None, None] 
    6872        self.details['Up_frac_in']    = ['[u/(u+d)]', None, None] 
    6973        self.details['Up_frac_out']   = ['[u/(u+d)]', None, None] 
     
    8084            raise 
    8185        self.data_vol = volume 
    82          
     86     
     87    def set_is_avg(self, is_avg=False):   
     88        """ 
     89        Sets is_avg: [bool] 
     90        """ 
     91        self.is_avg = is_avg 
     92           
    8393    def _gen(self, x, y, i): 
    8494        """ 
     
    90100        """ 
    91101        len_x = len(self.data_x) 
     102        if self.is_avg: 
     103            len_x *= -1 
    92104        len_q = len(x) 
     105        sldn = copy.deepcopy(self.data_sldn) 
     106        sldn -= self.params['solvent_SLD'] 
    93107        model = mod.new_GenI(len_x, self.data_x, self.data_y, self.data_z,  
    94                              self.data_sldn, self.data_mx, self.data_my,  
     108                             sldn, self.data_mx, self.data_my,  
    95109                             self.data_mz, self.data_vol, 
    96110                             self.params['Up_frac_in'],  
  • sansmodels/src/c_gen/sld2i.cpp

    rb1174ec r3657667  
    5353 */ 
    5454void GenI :: genicom(int npoints, double *qx, double *qy, double *I_out){ 
     55        //npoints is given negative for angular averaging  
    5556        // Assumes that q doesn't have qz component and sld_n is all real 
    5657        double q = 0.0; 
     58        int is_avg = 0; 
    5759        //double Pi = 4.0*atan(1.0); 
    5860        polar_sld b_sld; 
     
    6971 
    7072        double count = 0.0; 
     73        //check if this computation is for averaging 
     74        if (n_pix < 0 ){ 
     75                is_avg = 1; 
     76                n_pix = fabs(n_pix); 
     77        } 
    7178        //Assume that pixel volumes are given in vol_pix in A^3 unit 
    7279        //int x_size = 0; //in Ang 
     
    93100                                                                 mx_val[j], my_val[j], mz_val[j], 
    94101                                                                 inspin, outspin, stheta); 
    95                                 qr = (qx[i]*x_val[j] + qy[i]*y_val[j]); 
    96                                 iqr = cassign(0.0, qr); 
    97                                 ephase = cplx_exp(iqr); 
     102                                if (is_avg < 1){ 
     103                                        //anisotropic 
     104                                        qr = (qx[i]*x_val[j] + qy[i]*y_val[j]); 
     105                                        iqr = cassign(0.0, qr); 
     106                                        ephase = cplx_exp(iqr); 
     107                                        } 
     108                                else{ 
     109                                        //isotropic 
     110                                        qr = sqrt(x_val[j]*x_val[j]+y_val[j]*y_val[j]+z_val[j]*z_val[j]); 
     111                                        qr *= q; 
     112                                        if (qr == 0.0){ 
     113                                                ephase = cassign(0.0, 1.0); 
     114                                                } 
     115                                        else{ 
     116                                                qr = sin(qr) / qr; 
     117                                                ephase = cassign(qr, 0.0); 
     118                                                } 
     119                                        } 
    98120                                //up_up 
    99121                                if (inspin > 0.0 && outspin > 0.0){ 
Note: See TracChangeset for help on using the changeset viewer.