Changeset b2964ef in sasview


Ignore:
Timestamp:
Apr 2, 2019 7:42:56 AM (3 months ago)
Author:
GitHub <noreply@…>
Branches:
master
Parents:
fa307dd (diff), 4688acf (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:
Wojciech Potrzebowski <Wojciech.Potrzebowski@…> (04/02/19 07:42:56)
git-committer:
GitHub <noreply@…> (04/02/19 07:42:56)
Message:

Merge pull request #219 from SasView?/ticket-1267

I've tested it on OSX and Windows and it seems to behave as expected. This should fix ticket #1239, #219 and sasmodels#202

Location:
src/sas
Files:
6 added
1 deleted
3 edited

Legend:

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

    r895703d r4688acf  
    1616import wx 
    1717 
     18# TODO: move device query functions to sasmodels 
    1819try: 
    1920    import pyopencl as cl 
     
    2425import sasmodels.model_test 
    2526import sasmodels.sasview_model 
     27from sasmodels.generate import F32, F64 
    2628 
    2729from sas.sasgui.guiframe.documentation_window import DocumentationWindow 
    2830 
    2931logger = logging.getLogger(__name__) 
    30  
    31  
    3232 
    3333class CustomMessageBox(wx.Dialog): 
     
    7676 
    7777        self.SetAutoLayout(True) 
    78         self.ShowModal() 
    79         self.Destroy() 
    8078 
    8179 
     
    144142        test_btn = wx.Button(self, test_id, 'Test') 
    145143        test_btn.SetToolTipString("Test if models compile on the given infrastructure") 
     144        self.test_btn = test_btn 
    146145 
    147146        self.Bind(wx.EVT_BUTTON, self.on_OK, accept_btn) 
     
    179178        :return: 
    180179        """ 
     180        # TODO: Include cuda platforms if available. 
    181181        clinfo = [] 
    182182        platforms = [] 
     
    257257        #The same block of code as for OK but it is needed if we want to have 
    258258        #active response to Test button 
     259 
    259260        no_opencl_msg = False 
    260261        if self.sas_opencl: 
     
    265266            if "SAS_OPENCL" in os.environ: 
    266267                del os.environ["SAS_OPENCL"] 
    267         sasmodels.sasview_model.reset_environment() 
     268        # CRUFT: next version of reset_environment() will return env 
     269        env = sasmodels.sasview_model.reset_environment() 
    268270 
    269271        try: 
    270272            env = sasmodels.kernelcl.environment() 
    271             clinfo = [(ctx.devices[0].platform.vendor, 
    272                        ctx.devices[0].platform.version, 
    273                        ctx.devices[0].vendor, 
    274                        ctx.devices[0].name, 
    275                        ctx.devices[0].version) 
    276                       for ctx in env.context] 
    277         except Exception: 
    278             clinfo = None 
     273            clinfo = {} 
     274            if env.context[F64] is None: 
     275                clinfo['double'] = "None" 
     276            else: 
     277                ctx64 = env.context[F64].devices[0] 
     278                clinfo['double'] = ", ".join(( 
     279                    ctx64.platform.vendor, 
     280                    ctx64.platform.version, 
     281                    ctx64.vendor, 
     282                    ctx64.name, 
     283                    ctx64.version)) 
     284            if env.context[F32] is None: 
     285                clinfo['single'] = "None" 
     286            else: 
     287                ctx32 = env.context[F32].devices[0] 
     288                clinfo['single'] = ", ".join(( 
     289                    ctx32.platform.vendor, 
     290                    ctx32.platform.version, 
     291                    ctx32.vendor, 
     292                    ctx32.name, 
     293                    ctx32.version)) 
     294            # If the same device is used for single and double precision, then 
     295            # say so. Whether double is the same as single or single is the 
     296            # same as double depends on the order they are listed below. 
     297            if env.context[F32] == env.context[F64]: 
     298                clinfo['double'] = "same as single precision" 
     299        except Exception as exc: 
     300            logger.debug("exc %s", str(exc)) 
     301            clinfo = {'double': "None", 'single': "None"} 
     302 
     303        msg = "\nPlatform Details:\n\n" 
     304        msg += "Sasmodels version: " 
     305        msg += sasmodels.__version__ + "\n" 
     306        msg += "\nPlatform used: " 
     307        msg += json.dumps(platform.uname()) + "\n" 
     308        if no_opencl_msg: 
     309            msg += "\nOpenCL driver: None\n" 
     310        else: 
     311            msg += "\nOpenCL driver:\n" 
     312            msg += "   single precision: " + clinfo['single'] + "\n" 
     313            msg += "   double precision: " + clinfo['double'] + "\n" 
     314 
     315        msg_title = 'OpenCL tests results' 
     316        running = msg + "\nRunning tests.  This may take several minutes.\n\n" 
     317        msg_dialog = CustomMessageBox(self.panel1, running, msg_title) 
     318        msg_dialog.Show() 
    279319 
    280320        failures = [] 
    281321        tests_completed = 0 
    282         for test in sasmodels.model_test.model_tests(): 
     322        self.test_btn.Disable() 
     323        tests = sasmodels.model_test.make_suite('opencl', ['all']) 
     324        for test in tests: 
    283325            try: 
    284                 test() 
    285             except Exception: 
    286                 failures.append(test.description) 
    287  
     326                wx.Yield() 
     327                test.run_all() 
     328                msg_dialog.text.AppendText('.') 
     329            except Exception as exc: 
     330                logger.debug("%s failed with %s", test.test_name, str(exc)) 
     331                msg_dialog.text.AppendText('\nFail: ' + test.test_name) 
     332                failures.append(test.test_name) 
    288333            tests_completed += 1 
    289  
    290         info = { 
    291             'version':  sasmodels.__version__, 
    292             'platform': platform.uname(), 
    293             'opencl': clinfo, 
    294             'failing tests': failures, 
    295         } 
    296  
    297         msg_info = 'OpenCL tests results' 
    298  
    299         msg = str(tests_completed)+' tests completed.\n' 
    300         if len(failures) > 0: 
    301             msg += str(len(failures))+' tests failed.\n' 
    302             msg += 'Failing tests: ' 
    303             msg += json.dumps(info['failing tests']) 
    304             msg += "\n" 
    305         else: 
    306             msg += "All tests passed!\n" 
    307  
    308         msg += "\nPlatform Details:\n\n" 
    309         msg += "Sasmodels version: " 
    310         msg += info['version']+"\n" 
    311         msg += "\nPlatform used: " 
    312         msg += json.dumps(info['platform'])+"\n" 
    313         if no_opencl_msg: 
    314             msg += "\nOpenCL driver: None" 
    315         else: 
    316             msg += "\nOpenCL driver: " 
    317             msg += json.dumps(info['opencl'])+"\n" 
    318  
    319         CustomMessageBox(self.panel1, msg, msg_info) 
     334            # TODO: Put a stop button in CustomDialog and test it here. 
     335            #if tests_completed > 5: break 
     336 
     337        status = 'Failed %d of %d' % (len(failures), tests_completed) 
     338        msg_dialog.text.AppendText('\n\n' + status + '\n') 
     339        self.test_btn.Enable() 
     340        msg_dialog.ShowModal() 
     341        msg_dialog.Destroy() 
    320342 
    321343    def on_help(self, event): 
  • src/sas/sasgui/perspectives/fitting/media/fitting_help.rst

    rb7ce5ad rfa307dd  
    4242*  *Ellipsoid* - ellipsoidal shapes (oblate,prolate, core shell, etc) 
    4343*  *Parellelepiped* - as the name implies 
    44 *  *Sphere* - sheroidal shapes (sphere, core multishell, vesicle, etc) 
     44*  *Sphere* - spheroidal shapes (sphere, core multishell, vesicle, etc) 
    4545*  *Lamellae* - lamellar shapes (lamellar, core shell lamellar, stacked 
    4646   lamellar, etc) 
     
    6161on the *Description* button to the right. 
    6262 
     63Product Models 
     64^^^^^^^^^^^^^^ 
     65 
     66S(Q) models can be combined with many models in the other categories to 
     67generate what SasView calls "product models". The combination can be done by 
     68one of two methods, but how they behave is slightly different. 
     69 
     70The first, most straightforward, method is simply to use the S(Q) drop-down in 
     71the FitPage: 
     72 
     73.. figure:: p_and_s_buttons.png 
     74 
     75This example would then generate a product model with the following parameters: 
     76 
     77.. figure:: p_and_s_buttons_parameters.png 
     78 
     79The other method is to use the :ref:`Sum|Multi(p1,p2)` tool under Fitting > 
     80Plugin Model Operations: 
     81 
     82.. figure:: p_and_s_sum_model.png 
     83 
     84This creates a product model with the following parameters: 
     85 
     86.. figure:: p_and_s_sum_model_parameters.png 
     87 
     88As can be seen, the second method has produced a product model with an extra 
     89parameter: *radius_effective*. This is the radial distance determining the 
     90range of the $S(Q)$ interaction and may, or may not, be the same as the 
     91*radius*, in this example, depending on the concentration of the system. In 
     92other systems, *radius_effective* may depend on the particle form (shape). 
     93 
     94See :ref:`Product_Models` for more information. 
     95 
    6396Show 1D/2D 
    6497^^^^^^^^^^ 
     
    119152 
    120153For a complete list of all the library models available in SasView, see 
    121 the `Model Documentation <../../../index.html>`_ . 
     154the `Model Documentation <../../../sasgui/perspectives/fitting/models/index.html>`_ . 
    122155 
    123156It is also possible to add your own models. 
     
    216249Such a plugin should then be available in the S(Q) drop-down box on a FitPage (once 
    217250a P(Q) model has been selected). 
     251 
     252.. _Sum|Multi(p1,p2): 
    218253 
    219254Sum|Multi(p1,p2) 
  • src/sas/sasview/test/README.txt

    r914ba0a r1cf0fc0  
    1 Test data sets are included as a convenience to our users. The data sets are organized based on their data structure; 1D data (ie, I(Q)), 2D data (ie, I(Qx,Qy)), coordinate data (eg, PDB files), image data (eg, TIFF files), SasView saved states, SESANS data, and data in formats that are not yet implemented but which are in the works for future releases. 
     1Test data sets are included as a convenience to our users. The data sets are 
     2organized based on their data structure; 1D data (ie, I(Q)), 2D data 
     3(ie, I(Qx,Qy)), coordinate data (eg, PDB files), image data 
     4(eg, TIFF files), SasView saved states, SESANS data, and data in formats that 
     5are not yet implemented but which are in the works for future releases. 
    26 
    3 1D data sets EITHER a) have at least two columns of data with I(abs. units) on the y-axis and Q on the x-axis, OR b) have I and Q in separate files. Data in the latter format (/convertible_files) need to be converted to a single file format with the File Converter tool before SasView will analyse them. 
     71D data sets EITHER a) have at least two columns of data with I(abs. units) on 
     8the y-axis and Q on the x-axis, OR b) have I and Q in separate files. Data in 
     9the latter format (/convertible_files) need to be converted to a single file 
     10format with the File Converter tool before SasView will analyse them. 
    411 
    5 2D data sets are data sets that give the deduced intensity for each detector pixel. Depending on the file extension, uncertainty and metadata may also be available. 
     122D data sets are data sets that give the deduced intensity for each detector 
     13pixel. Depending on the file extension, uncertainty and metadata may also be 
     14available. 
    615 
    7 Coordinate data sets are designed to be read by the Generic Scattering Calculator tool. 
     16Coordinate data sets are designed to be read by the Generic Scattering 
     17Calculator tool. 
    818 
    919Image data sets are designed to be read by the Image Viewer tool. 
    1020 
    11 Save states are projects and analyses saved by the SASVIEW program. A single analysis file contains the data and parameters for a single fit (.fit), p(r) inversion (.pr), or invariant calculation (.inv). A project file (.svs) contains the results for every active analysis. 
     21Save states are projects and analyses saved by the SASVIEW program. A single 
     22analysis file contains the data and parameters for a single fit (.fit), p(r) 
     23inversion (.pr), or invariant calculation (.inv). A project file (.svs) 
     24contains the results for every active analysis. 
    1225 
    13 SESANS data sets primarily contain the neutron polarisation as a function of the spin-echo length. 
     26SESANS data sets primarily contain the neutron polarisation as a function of 
     27the spin-echo length. 
Note: See TracChangeset for help on using the changeset viewer.