Ignore:
Timestamp:
Sep 18, 2017 2:19:13 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, magnetic_scatt, release-4.2.2, ticket-1009, ticket-1094-headless, ticket-1242-2d-resolution, ticket-1243, ticket-1249, ticket885, unittest-saveload
Children:
1e6d9340
Parents:
1659f54 (diff), cfd27dd (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 ticket-639-katex

Location:
src/sas/sasgui/perspectives/calculator
Files:
22 added
22 deleted
9 edited

Legend:

Unmodified
Added
Removed
  • src/sas/sasgui/perspectives/calculator/model_editor.py

    r07ec714 r23359ccb  
    106106        self.model2_string = "cylinder" 
    107107        self.name = 'Sum' + M_NAME 
    108         self.factor = 'scale_factor' 
    109108        self._notes = '' 
    110109        self._operator = '+' 
     
    133132        self.model2_name = str(self.model2.GetValue()) 
    134133        self.good_name = True 
    135         self.fill_oprator_combox() 
     134        self.fill_operator_combox() 
    136135 
    137136    def _layout_name(self): 
     
    491490        a sum or multiply model then create the appropriate string 
    492491        """ 
    493  
    494492        name = '' 
    495  
    496493        if operator == '*': 
    497494            name = 'Multi' 
    498             factor = 'BackGround' 
    499             f_oper = '+' 
     495            factor = 'background' 
    500496        else: 
    501497            name = 'Sum' 
    502498            factor = 'scale_factor' 
    503             f_oper = '*' 
    504  
    505         self.factor = factor 
     499 
    506500        self._operator = operator 
    507         self.explanation = "  Plugin Model = %s %s (model1 %s model2)\n" % \ 
    508                            (self.factor, f_oper, self._operator) 
     501        self.explanation = ("  Plugin_model = scale_factor * (model_1 {} " 
     502            "model_2) + background").format(operator) 
    509503        self.explanationctr.SetLabel(self.explanation) 
    510504        self.name = name + M_NAME 
    511505 
    512506 
    513     def fill_oprator_combox(self): 
     507    def fill_operator_combox(self): 
    514508        """ 
    515509        fill the current combobox with the operator 
     
    527521        return [self.model1_name, self.model2_name] 
    528522 
    529     def write_string(self, fname, name1, name2): 
     523    def write_string(self, fname, model1_name, model2_name): 
    530524        """ 
    531525        Write and Save file 
     
    533527        self.fname = fname 
    534528        description = self.desc_tcl.GetValue().lstrip().rstrip() 
    535         if description == '': 
    536             description = name1 + self._operator + name2 
    537         text = self._operator_choice.GetValue() 
    538         if text.count('+') > 0: 
    539             factor = 'scale_factor' 
    540             f_oper = '*' 
    541             default_val = '1.0' 
    542         else: 
    543             factor = 'BackGround' 
    544             f_oper = '+' 
    545             default_val = '0.0' 
    546         path = self.fname 
    547         try: 
    548             out_f = open(path, 'w') 
    549         except: 
    550             raise 
    551         lines = SUM_TEMPLATE.split('\n') 
    552         for line in lines: 
    553             try: 
    554                 if line.count("scale_factor"): 
    555                     line = line.replace('scale_factor', factor) 
    556                     #print "scale_factor", line 
    557                 if line.count("= %s"): 
    558                     out_f.write(line % (default_val) + "\n") 
    559                 elif line.count("import Model as P1"): 
    560                     if self.is_p1_custom: 
    561                         line = line.replace('#', '') 
    562                         out_f.write(line % name1 + "\n") 
    563                     else: 
    564                         out_f.write(line + "\n") 
    565                 elif line.count("import %s as P1"): 
    566                     if not self.is_p1_custom: 
    567                         line = line.replace('#', '') 
    568                         out_f.write(line % (name1) + "\n") 
    569                     else: 
    570                         out_f.write(line + "\n") 
    571                 elif line.count("import Model as P2"): 
    572                     if self.is_p2_custom: 
    573                         line = line.replace('#', '') 
    574                         out_f.write(line % name2 + "\n") 
    575                     else: 
    576                         out_f.write(line + "\n") 
    577                 elif line.count("import %s as P2"): 
    578                     if not self.is_p2_custom: 
    579                         line = line.replace('#', '') 
    580                         out_f.write(line % (name2) + "\n") 
    581                     else: 
    582                         out_f.write(line + "\n") 
    583                 elif line.count("P1 = find_model"): 
    584                     out_f.write(line % (name1) + "\n") 
    585                 elif line.count("P2 = find_model"): 
    586                     out_f.write(line % (name2) + "\n") 
    587  
    588                 elif line.count("self.description = '%s'"): 
    589                     out_f.write(line % description + "\n") 
    590                 #elif line.count("run") and line.count("%s"): 
    591                 #    out_f.write(line % self._operator + "\n") 
    592                 #elif line.count("evalDistribution") and line.count("%s"): 
    593                 #    out_f.write(line % self._operator + "\n") 
    594                 elif line.count("return") and line.count("%s") == 2: 
    595                     #print "line return", line 
    596                     out_f.write(line % (f_oper, self._operator) + "\n") 
    597                 elif line.count("out2")and line.count("%s"): 
    598                     out_f.write(line % self._operator + "\n") 
    599                 else: 
    600                     out_f.write(line + "\n") 
    601             except: 
    602                 raise 
    603         out_f.close() 
    604         #else: 
    605         #    msg = "Name exists already." 
     529        desc_line = '' 
     530        if description.strip() != '': 
     531            # Sasmodels generates a description for us. If the user provides 
     532            # their own description, add a line to overwrite the sasmodels one 
     533            desc_line = "\nmodel_info.description = '{}'".format(description) 
     534        name = os.path.splitext(os.path.basename(self.fname))[0] 
     535        output = SUM_TEMPLATE.format(name=name, model1=model1_name,  
     536            model2=model2_name, operator=self._operator, desc_line=desc_line) 
     537        with open(self.fname, 'w') as out_f: 
     538            out_f.write(output) 
    606539 
    607540    def compile_file(self, path): 
     
    12781211""" 
    12791212SUM_TEMPLATE = """ 
    1280 # A sample of an experimental model function for Sum/Multiply(Pmodel1,Pmodel2) 
    1281 import os 
    1282 import sys 
    1283 import copy 
    1284 import collections 
    1285  
    1286 import numpy 
    1287  
    1288 from sas.sascalc.fit.pluginmodel import Model1DPlugin 
    1289 from sasmodels.sasview_model import find_model 
    1290  
    1291 class Model(Model1DPlugin): 
    1292     name = os.path.splitext(os.path.basename(__file__))[0] 
    1293     is_multiplicity_model = False 
    1294     def __init__(self, multiplicity=1): 
    1295         Model1DPlugin.__init__(self, name='') 
    1296         P1 = find_model('%s') 
    1297         P2 = find_model('%s') 
    1298         p_model1 = P1() 
    1299         p_model2 = P2() 
    1300         ## Setting  model name model description 
    1301         self.description = '%s' 
    1302         if self.name.rstrip().lstrip() == '': 
    1303             self.name = self._get_name(p_model1.name, p_model2.name) 
    1304         if self.description.rstrip().lstrip() == '': 
    1305             self.description = p_model1.name 
    1306             self.description += p_model2.name 
    1307             self.fill_description(p_model1, p_model2) 
    1308  
    1309         ## Define parameters 
    1310         self.params = collections.OrderedDict() 
    1311  
    1312         ## Parameter details [units, min, max] 
    1313         self.details = {} 
    1314         ## Magnetic Panrameters 
    1315         self.magnetic_params = [] 
    1316         # non-fittable parameters 
    1317         self.non_fittable = p_model1.non_fittable 
    1318         self.non_fittable += p_model2.non_fittable 
    1319  
    1320         ##models 
    1321         self.p_model1= p_model1 
    1322         self.p_model2= p_model2 
    1323  
    1324  
    1325         ## dispersion 
    1326         self._set_dispersion() 
    1327         ## Define parameters 
    1328         self._set_params() 
    1329         ## New parameter:scaling_factor 
    1330         self.params['scale_factor'] = %s 
    1331  
    1332         ## Parameter details [units, min, max] 
    1333         self._set_details() 
    1334         self.details['scale_factor'] = ['', 0.0, numpy.inf] 
    1335  
    1336  
    1337         #list of parameter that can be fitted 
    1338         self._set_fixed_params() 
    1339  
    1340         ## parameters with orientation 
    1341         self.orientation_params = [] 
    1342         for item in self.p_model1.orientation_params: 
    1343             new_item = "p1_" + item 
    1344             if not new_item in self.orientation_params: 
    1345                 self.orientation_params.append(new_item) 
    1346  
    1347         for item in self.p_model2.orientation_params: 
    1348             new_item = "p2_" + item 
    1349             if not new_item in self.orientation_params: 
    1350                 self.orientation_params.append(new_item) 
    1351         ## magnetic params 
    1352         self.magnetic_params = [] 
    1353         for item in self.p_model1.magnetic_params: 
    1354             new_item = "p1_" + item 
    1355             if not new_item in self.magnetic_params: 
    1356                 self.magnetic_params.append(new_item) 
    1357  
    1358         for item in self.p_model2.magnetic_params: 
    1359             new_item = "p2_" + item 
    1360             if not new_item in self.magnetic_params: 
    1361                 self.magnetic_params.append(new_item) 
    1362         # get multiplicity if model provide it, else 1. 
    1363         try: 
    1364             multiplicity1 = p_model1.multiplicity 
    1365             try: 
    1366                 multiplicity2 = p_model2.multiplicity 
    1367             except: 
    1368                 multiplicity2 = 1 
    1369         except: 
    1370             multiplicity1 = 1 
    1371             multiplicity2 = 1 
    1372         ## functional multiplicity of the model 
    1373         self.multiplicity1 = multiplicity1 
    1374         self.multiplicity2 = multiplicity2 
    1375         self.multiplicity_info = [] 
    1376  
    1377     def _clone(self, obj): 
    1378         import copy 
    1379         obj.params     = copy.deepcopy(self.params) 
    1380         obj.description     = copy.deepcopy(self.description) 
    1381         obj.details    = copy.deepcopy(self.details) 
    1382         obj.dispersion = copy.deepcopy(self.dispersion) 
    1383         obj.p_model1  = self.p_model1.clone() 
    1384         obj.p_model2  = self.p_model2.clone() 
    1385         #obj = copy.deepcopy(self) 
    1386         return obj 
    1387  
    1388     def _get_name(self, name1, name2): 
    1389         p1_name = self._get_upper_name(name1) 
    1390         if not p1_name: 
    1391             p1_name = name1 
    1392         name = p1_name 
    1393         name += "_and_" 
    1394         p2_name = self._get_upper_name(name2) 
    1395         if not p2_name: 
    1396             p2_name = name2 
    1397         name += p2_name 
    1398         return name 
    1399  
    1400     def _get_upper_name(self, name=None): 
    1401         if name is None: 
    1402             return "" 
    1403         upper_name = "" 
    1404         str_name = str(name) 
    1405         for index in range(len(str_name)): 
    1406             if str_name[index].isupper(): 
    1407                 upper_name += str_name[index] 
    1408         return upper_name 
    1409  
    1410     def _set_dispersion(self): 
    1411         self.dispersion = collections.OrderedDict() 
    1412         ##set dispersion only from p_model 
    1413         for name , value in self.p_model1.dispersion.iteritems(): 
    1414             #if name.lower() not in self.p_model1.orientation_params: 
    1415             new_name = "p1_" + name 
    1416             self.dispersion[new_name]= value 
    1417         for name , value in self.p_model2.dispersion.iteritems(): 
    1418             #if name.lower() not in self.p_model2.orientation_params: 
    1419             new_name = "p2_" + name 
    1420             self.dispersion[new_name]= value 
    1421  
    1422     def function(self, x=0.0): 
    1423         return 0 
    1424  
    1425     def getProfile(self): 
    1426         try: 
    1427             x,y = self.p_model1.getProfile() 
    1428         except: 
    1429             x = None 
    1430             y = None 
    1431  
    1432         return x, y 
    1433  
    1434     def _set_params(self): 
    1435         for name , value in self.p_model1.params.iteritems(): 
    1436             # No 2D-supported 
    1437             #if name not in self.p_model1.orientation_params: 
    1438             new_name = "p1_" + name 
    1439             self.params[new_name]= value 
    1440  
    1441         for name , value in self.p_model2.params.iteritems(): 
    1442             # No 2D-supported 
    1443             #if name not in self.p_model2.orientation_params: 
    1444             new_name = "p2_" + name 
    1445             self.params[new_name]= value 
    1446  
    1447         # Set "scale" as initializing 
    1448         self._set_scale_factor() 
    1449  
    1450  
    1451     def _set_details(self): 
    1452         for name ,detail in self.p_model1.details.iteritems(): 
    1453             new_name = "p1_" + name 
    1454             #if new_name not in self.orientation_params: 
    1455             self.details[new_name]= detail 
    1456  
    1457         for name ,detail in self.p_model2.details.iteritems(): 
    1458             new_name = "p2_" + name 
    1459             #if new_name not in self.orientation_params: 
    1460             self.details[new_name]= detail 
    1461  
    1462     def _set_scale_factor(self): 
    1463         pass 
    1464  
    1465  
    1466     def setParam(self, name, value): 
    1467         # set param to this (p1, p2) model 
    1468         self._setParamHelper(name, value) 
    1469  
    1470         ## setParam to p model 
    1471         model_pre = '' 
    1472         new_name = '' 
    1473         name_split = name.split('_', 1) 
    1474         if len(name_split) == 2: 
    1475             model_pre = name.split('_', 1)[0] 
    1476             new_name = name.split('_', 1)[1] 
    1477         if model_pre == "p1": 
    1478             if new_name in self.p_model1.getParamList(): 
    1479                 self.p_model1.setParam(new_name, value) 
    1480         elif model_pre == "p2": 
    1481              if new_name in self.p_model2.getParamList(): 
    1482                 self.p_model2.setParam(new_name, value) 
    1483         elif name == 'scale_factor': 
    1484             self.params['scale_factor'] = value 
    1485         else: 
    1486             raise ValueError, "Model does not contain parameter %s" % name 
    1487  
    1488     def getParam(self, name): 
    1489         # Look for dispersion parameters 
    1490         toks = name.split('.') 
    1491         if len(toks)==2: 
    1492             for item in self.dispersion.keys(): 
    1493                 # 2D not supported 
    1494                 if item.lower()==toks[0].lower(): 
    1495                     for par in self.dispersion[item]: 
    1496                         if par.lower() == toks[1].lower(): 
    1497                             return self.dispersion[item][par] 
    1498         else: 
    1499             # Look for standard parameter 
    1500             for item in self.params.keys(): 
    1501                 if item.lower()==name.lower(): 
    1502                     return self.params[item] 
    1503         return 
    1504         #raise ValueError, "Model does not contain parameter %s" % name 
    1505  
    1506     def _setParamHelper(self, name, value): 
    1507         # Look for dispersion parameters 
    1508         toks = name.split('.') 
    1509         if len(toks)== 2: 
    1510             for item in self.dispersion.keys(): 
    1511                 if item.lower()== toks[0].lower(): 
    1512                     for par in self.dispersion[item]: 
    1513                         if par.lower() == toks[1].lower(): 
    1514                             self.dispersion[item][par] = value 
    1515                             return 
    1516         else: 
    1517             # Look for standard parameter 
    1518             for item in self.params.keys(): 
    1519                 if item.lower()== name.lower(): 
    1520                     self.params[item] = value 
    1521                     return 
    1522  
    1523         raise ValueError, "Model does not contain parameter %s" % name 
    1524  
    1525  
    1526     def _set_fixed_params(self): 
    1527         self.fixed = [] 
    1528         for item in self.p_model1.fixed: 
    1529             new_item = "p1" + item 
    1530             self.fixed.append(new_item) 
    1531         for item in self.p_model2.fixed: 
    1532             new_item = "p2" + item 
    1533             self.fixed.append(new_item) 
    1534  
    1535         self.fixed.sort() 
    1536  
    1537  
    1538     def run(self, x = 0.0): 
    1539         self._set_scale_factor() 
    1540         return self.params['scale_factor'] %s \ 
    1541 (self.p_model1.run(x) %s self.p_model2.run(x)) 
    1542  
    1543     def runXY(self, x = 0.0): 
    1544         self._set_scale_factor() 
    1545         return self.params['scale_factor'] %s \ 
    1546 (self.p_model1.runXY(x) %s self.p_model2.runXY(x)) 
    1547  
    1548     ## Now (May27,10) directly uses the model eval function 
    1549     ## instead of the for-loop in Base Component. 
    1550     def evalDistribution(self, x = []): 
    1551         self._set_scale_factor() 
    1552         return self.params['scale_factor'] %s \ 
    1553 (self.p_model1.evalDistribution(x) %s \ 
    1554 self.p_model2.evalDistribution(x)) 
    1555  
    1556     def set_dispersion(self, parameter, dispersion): 
    1557         value= None 
    1558         new_pre = parameter.split("_", 1)[0] 
    1559         new_parameter = parameter.split("_", 1)[1] 
    1560         try: 
    1561             if new_pre == 'p1' and \ 
    1562 new_parameter in self.p_model1.dispersion.keys(): 
    1563                 value= self.p_model1.set_dispersion(new_parameter, dispersion) 
    1564             if new_pre == 'p2' and \ 
    1565 new_parameter in self.p_model2.dispersion.keys(): 
    1566                 value= self.p_model2.set_dispersion(new_parameter, dispersion) 
    1567             self._set_dispersion() 
    1568             return value 
    1569         except: 
    1570             raise 
    1571  
    1572     def fill_description(self, p_model1, p_model2): 
    1573         description = "" 
    1574         description += "This model gives the summation or multiplication of" 
    1575         description += "%s and %s. "% ( p_model1.name, p_model2.name ) 
    1576         self.description += description 
    1577  
    1578 if __name__ == "__main__": 
    1579     m1= Model() 
    1580     #m1.setParam("p1_scale", 25) 
    1581     #m1.setParam("p1_length", 1000) 
    1582     #m1.setParam("p2_scale", 100) 
    1583     #m1.setParam("p2_rg", 100) 
    1584     out1 = m1.runXY(0.01) 
    1585  
    1586     m2= Model() 
    1587     #m2.p_model1.setParam("scale", 25) 
    1588     #m2.p_model1.setParam("length", 1000) 
    1589     #m2.p_model2.setParam("scale", 100) 
    1590     #m2.p_model2.setParam("rg", 100) 
    1591     out2 = m2.p_model1.runXY(0.01) %s m2.p_model2.runXY(0.01)\n 
    1592     print "My name is %s."% m1.name 
    1593     print out1, " = ", out2 
    1594     if out1 == out2: 
    1595         print "===> Simple Test: Passed!" 
    1596     else: 
    1597         print "===> Simple Test: Failed!" 
     1213from sasmodels.core import load_model_info 
     1214from sasmodels.sasview_model import make_model_from_info 
     1215 
     1216model_info = load_model_info('{model1}{operator}{model2}') 
     1217model_info.name = '{name}'{desc_line} 
     1218Model = make_model_from_info(model_info) 
    15981219""" 
    1599  
    16001220if __name__ == "__main__": 
    16011221#    app = wx.PySimpleApp() 
  • src/sas/sasgui/perspectives/calculator/media/density_calculator_help.rst

    rd85c194 r6aad2e8  
    29294) Click the 'Calculate' button to perform the calculation. 
    3030 
    31 .. image:: density_tutor.gif 
     31.. image:: density_tutor.png 
    3232 
    3333.. ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ 
  • src/sas/sasgui/perspectives/calculator/media/gen_sas_help.html

    rd85c194 r6aad2e8  
    1919by the particle  
    2020<p> 
    21 <img src="gen_i.gif"/> 
     21<img src="gen_i.png"/> 
    2222</p> 
    2323<br> 
     
    2626of the j'th pixel respectively. And the total volume 
    2727<p> 
    28 <img src="v_j.gif"/> 
     28<img src="v_j.png"/> 
    2929</p> 
    3030<br> 
     
    4444scattering length. (Figure below). 
    4545<p> 
    46 <img src="mag_vector.bmp"/> 
     46<img src="mag_vector.png"/> 
    4747</p> 
    4848<br> 
    4949The magnetic scattering length density is then 
    5050<p> 
    51 <img src="dm_eq.gif"/> 
     51<img src="dm_eq.png"/> 
    5252</p> 
    5353<br> 
     
    6666<br> 
    6767<p> 
    68 <img src="gen_mag_pic.bmp"/> 
     68<img src="gen_mag_pic.png"/> 
    6969</p> 
    7070<br> 
     
    7575densities , including the nuclear scattering length density (&#946; <sub>N</sub>) are given as, for non-spin-flips, 
    7676<p> 
    77 <img src="sld1.gif"/> 
     77<img src="sld1.png"/> 
    7878</p> 
    7979<br> 
     
    8181for spin-flips, 
    8282<p> 
    83 <img src="sld2.gif"/> 
     83<img src="sld2.png"/> 
    8484</p> 
    8585<br> 
     
    8787where 
    8888<p> 
    89 <img src="mxp.gif"/> 
     89<img src="mxp.png"/> 
    9090</p> 
    9191<p> 
    92 <img src="myp.gif"/> 
     92<img src="myp.png"/> 
    9393</p> 
    9494<p> 
    95 <img src="mzp.gif"/> 
     95<img src="mzp.png"/> 
    9696</p> 
    9797<p> 
    98 <img src="mqx.gif"/> 
     98<img src="mqx.png"/> 
    9999</p> 
    100100<p> 
    101 <img src="mqy.gif"/> 
     101<img src="mqy.png"/> 
    102102</p> 
    103103<br> 
     
    110110<br> 
    111111<p> 
    112 <img src="gen_gui_help.bmp"/> 
     112<img src="gen_gui_help.png"/> 
    113113</p> 
    114114<br> 
     
    136136in a 2D output, whileas the scattering calculation averaged over all the orientations uses the Debye equation providing a 1D output: 
    137137 <p> 
    138 <img src="gen_debye_eq.gif"/> 
     138<img src="gen_debye_eq.png"/> 
    139139</p> 
    140140<br> 
  • src/sas/sasgui/perspectives/calculator/media/image_viewer_help.rst

    rda456fb r6aad2e8  
    3434   will be displayed. 
    3535 
    36 .. image:: load_image.bmp 
     36.. image:: load_image.png 
    3737 
    38383) To save, print, or copy the image, or to apply a grid overlay, right-click  
    3939   anywhere in the plot. 
    4040 
    41 .. image:: pic_plot.bmp 
     41.. image:: pic_plot.png 
    4242 
    43434. If the image is taken from a 2D detector, SasView can attempt to convert  
     
    5151   then click the OK. 
    5252 
    53 .. image:: pic_convert.bmp 
     53.. image:: pic_convert.png 
    5454 
    5555.. ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ 
  • src/sas/sasgui/perspectives/calculator/media/kiessig_calculator_help.rst

    r7805458 r5ed76f8  
    1010----------- 
    1111 
    12 This tool is approximately estimates the thickness of a layer or the diameter  
    13 of particles from the position of the Kiessig fringe/Bragg peak in NR/SAS data  
    14 using the relation 
     12This tool estimates real space dimensions from the position or spacing of 
     13features in recipricol space.  In particular a particle of size $d$ will 
     14give rise to Bragg peaks with spacing $\Delta q$ according to the relation 
    1515 
    16 (thickness *or* size) = 2 * |pi| / (fringe_width *or* peak position) 
    17    
     16.. math:: 
     17 
     18    d = 2\pi / \Delta q 
     19 
     20Similarly, the spacing between the peaks in Kiessig fringes in reflectometry 
     21data arise from layers of thickness $d$. 
     22 
    1823.. ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ 
    1924 
     
    2126-------------- 
    2227 
    23 To get a rough thickness or particle size, simply type the fringe or peak  
     28To get a rough thickness or particle size, simply type the fringe or peak 
    2429position (in units of 1/|Ang|\) and click on the *Compute* button. 
    2530 
    2631.. ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ 
    2732 
    28 .. note::  This help document was last changed by Steve King, 01May2015 
    29  
     33.. note::  This help document was last changed by Paul Kienzle, 05Apr2017 
  • src/sas/sasgui/perspectives/calculator/media/resolution_calculator_help.rst

    r7805458 r5ed76f8  
    1010----------- 
    1111 
    12 This tool is approximately estimates the resolution of Q from SAS instrumental  
    13 parameter values assuming that the detector is flat and normal to the  
     12This tool is approximately estimates the resolution of $Q$ from SAS instrumental 
     13parameter values assuming that the detector is flat and normal to the 
    1414incident beam. 
    1515 
     
    23232) Select the source (Neutron or Photon) and source type (Monochromatic or TOF). 
    2424 
    25    *NOTE! The computational difference between the sources is only the  
     25   *NOTE! The computational difference between the sources is only the 
    2626   gravitational contribution due to the mass of the particles.* 
    2727 
    28 3) Change the default values of the instrumental parameters as required. Be  
     283) Change the default values of the instrumental parameters as required. Be 
    2929   careful to note that distances are specified in cm! 
    3030 
    31 4) Enter values for the source wavelength(s), |lambda|\ , and its spread (= FWHM/|lambda|\ ). 
    32     
    33    For monochromatic sources, the inputs are just one value. For TOF sources,  
    34    the minimum and maximum values should be separated by a '-' to specify a  
     314) Enter values for the source wavelength(s), $\lambda$, and its spread (= $\text{FWHM}/\lambda$). 
     32 
     33   For monochromatic sources, the inputs are just one value. For TOF sources, 
     34   the minimum and maximum values should be separated by a '-' to specify a 
    3535   range. 
    36     
    37    Optionally, the wavelength (BUT NOT of the wavelength spread) can be extended  
    38    by adding '; nn' where the 'nn' specifies the number of the bins for the  
    39    numerical integration. The default value is nn = 10. The same number of bins  
     36 
     37   Optionally, the wavelength (BUT NOT of the wavelength spread) can be extended 
     38   by adding '; nn' where the 'nn' specifies the number of the bins for the 
     39   numerical integration. The default value is nn = 10. The same number of bins 
    4040   will be used for the corresponding wavelength spread. 
    4141 
    42 5) For TOF, the default wavelength spectrum is flat. A custom spectral  
    43    distribution file (2-column text: wavelength (|Ang|\) vs Intensity) can also  
     425) For TOF, the default wavelength spectrum is flat. A custom spectral 
     43   distribution file (2-column text: wavelength (|Ang|\) vs Intensity) can also 
    4444   be loaded by selecting *Add new* in the combo box. 
    4545 
    46 6) When ready, click the *Compute* button. Depending on the computation the  
     466) When ready, click the *Compute* button. Depending on the computation the 
    4747   calculation time will vary. 
    4848 
    49 7) 1D and 2D dQ values will be displayed at the bottom of the panel, and a 2D  
    50    resolution weight distribution (a 2D elliptical Gaussian function) will also  
    51    be displayed in the plot panel even if the Q inputs are outside of the  
     497) 1D and 2D $dQ$ values will be displayed at the bottom of the panel, and a 2D 
     50   resolution weight distribution (a 2D elliptical Gaussian function) will also 
     51   be displayed in the plot panel even if the $Q$ inputs are outside of the 
    5252   detector limit (the red lines indicate the limits of the detector). 
    53     
    54    TOF only: green lines indicate the limits of the maximum Q range accessible  
     53 
     54   TOF only: green lines indicate the limits of the maximum $Q$ range accessible 
    5555   for the longest wavelength due to the size of the detector. 
    56      
    57    Note that the effect from the beam block/stop is ignored, so in the small Q  
    58    region near the beam block/stop  
    5956 
    60    [ie., Q < 2. |pi|\ .(beam block diameter) / (sample-to-detector distance) / |lambda|\_min]  
     57   Note that the effect from the beam block/stop is ignored, so in the small $Q$ 
     58   region near the beam block/stop 
     59 
     60   [i.e., $Q < (2 \pi \cdot \text{beam block diameter}) / (\text{sample-to-detector distance} \cdot \lambda_\text{min})$] 
    6161 
    6262   the variance is slightly under estimated. 
    6363 
    64 8) A summary of the calculation is written to the SasView *Console* at the  
     648) A summary of the calculation is written to the SasView *Console* at the 
    6565   bottom of the main SasView window. 
    6666 
    67 .. image:: resolution_tutor.gif 
     67.. image:: resolution_tutor.png 
    6868 
    6969.. ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ 
     
    7474The scattering wave transfer vector is by definition 
    7575 
    76 .. image:: q.gif 
     76.. image:: q.png 
    7777 
    78 In the small-angle limit, the variance of Q is to a first-order  
     78In the small-angle limit, the variance of $Q$ is to a first-order 
    7979approximation 
    8080 
    81 .. image:: sigma_q.gif 
     81.. image:: sigma_q.png 
    8282 
    8383The geometric and gravitational contributions can then be summarised as 
    8484 
    85 .. image:: sigma_table.gif 
     85.. image:: sigma_table.png 
    8686 
    87 Finally, a Gaussian function is used to describe the 2D weighting distribution  
    88 of the uncertainty in Q. 
     87Finally, a Gaussian function is used to describe the 2D weighting distribution 
     88of the uncertainty in $Q$. 
    8989 
    9090.. ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ 
     
    9393---------- 
    9494 
    95 D.F.R. Mildner and J.M. Carpenter  
     95D.F.R. Mildner and J.M. Carpenter 
    9696*J. Appl. Cryst.* 17 (1984) 249-256 
    9797 
    98 D.F.R. Mildner, J.M. Carpenter and D.L. Worcester  
     98D.F.R. Mildner, J.M. Carpenter and D.L. Worcester 
    9999*J. Appl. Cryst.* 19 (1986) 311-319 
    100100 
  • src/sas/sasgui/perspectives/calculator/media/sas_calculator_help.rst

    rda456fb r5ed76f8  
    1919------ 
    2020 
    21 In general, a particle with a volume *V* can be described by an ensemble  
    22 containing *N* 3-dimensional rectangular pixels where each pixel is much  
    23 smaller than *V*. 
     21In general, a particle with a volume $V$ can be described by an ensemble 
     22containing $N$ 3-dimensional rectangular pixels where each pixel is much 
     23smaller than $V$. 
    2424 
    25 Assuming that all the pixel sizes are the same, the elastic scattering  
     25Assuming that all the pixel sizes are the same, the elastic scattering 
    2626intensity from the particle is 
    2727 
    28 .. image:: gen_i.gif 
     28.. image:: gen_i.png 
    2929 
    3030Equation 1. 
    3131 
    32 where |beta|\ :sub:`j` and *r*\ :sub:`j` are the scattering length density and  
    33 the position of the j'th pixel respectively. 
     32where $\beta_j$ and $r_j$ are the scattering length density and 
     33the position of the $j^\text{th}$ pixel respectively. 
    3434 
    35 The total volume *V* 
     35The total volume $V$ 
    3636 
    37 .. image:: v_j.gif 
     37.. math:: 
    3838 
    39 for |beta|\ :sub:`j` |noteql|\0 where *v*\ :sub:`j` is the volume of the j'th  
    40 pixel (or the j'th natural atomic volume (= atomic mass / (natural molar  
     39    V = \sum_j^N v_j 
     40 
     41for $\beta_j \ne 0$ where $v_j$ is the volume of the $j^\text{th}$ 
     42pixel (or the $j^\text{th}$ natural atomic volume (= atomic mass / (natural molar 
    4143density * Avogadro number) for the atomic structures). 
    4244 
    43 *V* can be corrected by users. This correction is useful especially for an  
    44 atomic structure (such as taken from a PDB file) to get the right normalization.  
     45$V$ can be corrected by users. This correction is useful especially for an 
     46atomic structure (such as taken from a PDB file) to get the right normalization. 
    4547 
    46 *NOTE!* |beta|\ :sub:`j` *displayed in the GUI may be incorrect but this will not  
     48*NOTE! $\beta_j$ displayed in the GUI may be incorrect but this will not 
    4749affect the scattering computation if the correction of the total volume V is made.* 
    4850 
    49 The scattering length density (SLD) of each pixel, where the SLD is uniform, is  
    50 a combination of the nuclear and magnetic SLDs and depends on the spin states  
     51The scattering length density (SLD) of each pixel, where the SLD is uniform, is 
     52a combination of the nuclear and magnetic SLDs and depends on the spin states 
    5153of the neutrons as follows. 
    5254 
     
    5456^^^^^^^^^^^^^^^^^^^ 
    5557 
    56 For magnetic scattering, only the magnetization component, *M*\ :sub:`perp`\ ,  
    57 perpendicular to the scattering vector *Q* contributes to the magnetic  
     58For magnetic scattering, only the magnetization component, $M_\perp$, 
     59perpendicular to the scattering vector $Q$ contributes to the magnetic 
    5860scattering length. 
    5961 
    60 .. image:: mag_vector.bmp 
     62.. image:: mag_vector.png 
    6163 
    6264The magnetic scattering length density is then 
    6365 
    64 .. image:: dm_eq.gif 
     66.. image:: dm_eq.png 
    6567 
    66 where the gyromagnetic ratio |gamma| = -1.913, |mu|\ :sub:`B` is the Bohr  
    67 magneton, *r*\ :sub:`0` is the classical radius of electron, and |sigma| is the  
     68where the gyromagnetic ratio is $\gamma = -1.913$, $\mu_B$ is the Bohr 
     69magneton, $r_0$ is the classical radius of electron, and $\sigma$ is the 
    6870Pauli spin. 
    6971 
    7072For a polarized neutron, the magnetic scattering is depending on the spin states. 
    7173 
    72 Let us consider that the incident neutrons are polarised both parallel (+) and   
    73 anti-parallel (-) to the x' axis (see below). The possible states after  
    74 scattering from the sample are then  
     74Let us consider that the incident neutrons are polarised both parallel (+) and 
     75anti-parallel (-) to the x' axis (see below). The possible states after 
     76scattering from the sample are then 
    7577 
    7678*  Non-spin flips: (+ +) and (- -) 
    7779*  Spin flips:     (+ -) and (- +) 
    7880 
    79 .. image:: gen_mag_pic.bmp 
     81.. image:: gen_mag_pic.png 
    8082 
    81 Now let us assume that the angles of the *Q* vector and the spin-axis (x')  
    82 to the x-axis are |phi| and |theta|\ :sub:`up` respectively (see above). Then,  
    83 depending upon the polarization (spin) state of neutrons, the scattering  
    84 length densities, including the nuclear scattering length density (|beta|\ :sub:`N`\ )  
     83Now let us assume that the angles of the *Q* vector and the spin-axis (x') 
     84to the x-axis are $\phi$ and $\theta_\text{up}$ respectively (see above). Then, 
     85depending upon the polarization (spin) state of neutrons, the scattering 
     86length densities, including the nuclear scattering length density ($\beta_N$) 
    8587are given as 
    8688 
    8789*  for non-spin-flips 
    8890 
    89    .. image:: sld1.gif 
     91   .. image:: sld1.png 
    9092 
    9193*  for spin-flips 
    9294 
    93    .. image:: sld2.gif 
     95   .. image:: sld2.png 
    9496 
    9597where 
    9698 
    97 .. image:: mxp.gif 
     99.. image:: mxp.png 
    98100 
    99 .. image:: myp.gif 
     101.. image:: myp.png 
    100102 
    101 .. image:: mzp.gif 
     103.. image:: mzp.png 
    102104 
    103 .. image:: mqx.gif 
     105.. image:: mqx.png 
    104106 
    105 .. image:: mqy.gif 
     107.. image:: mqy.png 
    106108 
    107 Here the *M0*\ :sub:`x`\ , *M0*\ :sub:`y` and *M0*\ :sub:`z` are the x, y and z  
    108 components of the magnetisation vector in the laboratory xyz frame.  
     109Here the $M0_x$, $M0_y$ and $M0_z$ are the $x$, $y$ and $z$ 
     110components of the magnetisation vector in the laboratory $xyz$ frame. 
    109111 
    110112.. ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ 
     
    113115-------------- 
    114116 
    115 .. image:: gen_gui_help.bmp 
     117.. image:: gen_gui_help.png 
    116118 
    117 After computation the result will appear in the *Theory* box in the SasView   
     119After computation the result will appear in the *Theory* box in the SasView 
    118120*Data Explorer* panel. 
    119121 
    120 *Up_frac_in* and *Up_frac_out* are the ratio  
     122*Up_frac_in* and *Up_frac_out* are the ratio 
    121123 
    122124   (spin up) / (spin up + spin down) 
    123     
     125 
    124126of neutrons before the sample and at the analyzer, respectively. 
    125127 
    126 *NOTE 1. The values of* Up_frac_in *and* Up_frac_out *must be in the range  
     128*NOTE 1. The values of* Up_frac_in *and* Up_frac_out *must be in the range 
    1271290.0 to 1.0. Both values are 0.5 for unpolarized neutrons.* 
    128130 
    129 *NOTE 2. This computation is totally based on the pixel (or atomic) data fixed  
     131*NOTE 2. This computation is totally based on the pixel (or atomic) data fixed 
    130132in xyz coordinates. No angular orientational averaging is considered.* 
    131133 
    132 *NOTE 3. For the nuclear scattering length density, only the real component  
     134*NOTE 3. For the nuclear scattering length density, only the real component 
    133135is taken account.* 
    134136 
     
    139141 
    140142The SANS Calculator tool can read some PDB, OMF or SLD files but ignores 
    141 polarized/magnetic scattering when doing so, thus related parameters such as  
     143polarized/magnetic scattering when doing so, thus related parameters such as 
    142144*Up_frac_in*, etc, will be ignored. 
    143145 
    144 The calculation for fixed orientation uses Equation 1 above resulting in a 2D  
    145 output, whereas the scattering calculation averaged over all the orientations  
     146The calculation for fixed orientation uses Equation 1 above resulting in a 2D 
     147output, whereas the scattering calculation averaged over all the orientations 
    146148uses the Debye equation below providing a 1D output 
    147149 
    148 .. image:: gen_debye_eq.gif 
     150.. image:: gen_debye_eq.png 
    149151 
    150 where *v*\ :sub:`j` |beta|\ :sub:`j` |equiv| *b*\ :sub:`j` is the scattering  
    151 length of the j'th atom. The calculation output is passed to the *Data Explorer*  
     152where $v_j \beta_j \equiv b_j$ is the scattering 
     153length of the $j^\text{th}$ atom. The calculation output is passed to the *Data Explorer* 
    152154for further use. 
    153155 
  • src/sas/sasgui/perspectives/calculator/media/sld_calculator_help.rst

    rf93b473f r5ed76f8  
    1010----------- 
    1111 
    12 The neutron scattering length density (SLD) is defined as 
     12The neutron scattering length density (SLD, $\beta_N$) is defined as 
    1313 
    14   SLD = (b_c1 + b_c2 + ... + b_cn) / Vm 
     14.. math:: 
    1515 
    16 where b_ci is the bound coherent scattering length of ith of n atoms in a molecule 
    17 with the molecular volume Vm 
     16  \beta_N = (b_{c1} + b_{c2} + ... + b_{cn}) / V_m 
     17 
     18where $b_{ci}$ is the bound coherent scattering length of ith of n atoms in a molecule 
     19with the molecular volume $V_m$. 
    1820 
    1921.. ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ 
     
    2224---------------------------- 
    2325 
    24 To calculate scattering length densities enter the empirical formula of a  
     26To calculate scattering length densities enter the empirical formula of a 
    2527compound and its mass density and click "Calculate". 
    2628 
    27 Entering a wavelength value is optional (a default value of 6.0 |Ang| will  
     29Entering a wavelength value is optional (a default value of 6.0 |Ang| will 
    2830be used). 
    2931 
     
    3840*  Parentheses can be nested, such as "(CaCO3(H2O)6)1". 
    3941 
    40 *  Isotopes are represented by their atomic number in *square brackets*, such  
     42*  Isotopes are represented by their atomic number in *square brackets*, such 
    4143   as "CaCO[18]3+6H2O", H[1], or H[2]. 
    4244 
    4345*  Numbers of atoms can be integer or decimal, such as "CaCO3+(3HO0.5)2". 
    4446 
    45 *  The SLD of mixtures can be calculated as well. For example, for a 70-30  
     47*  The SLD of mixtures can be calculated as well. For example, for a 70-30 
    4648   mixture of H2O/D2O write "H14O7+D6O3" or more simply "H7D3O5" (i.e. this says 
    4749   7 hydrogens, 3 deuteriums, and 5 oxygens) and enter a mass density calculated 
    4850   on the percentages of H2O and D2O. 
    4951 
    50 *  Type "C[13]6 H[2]12 O[18]6" for C(13)6H(2)12O(18)6 (6 Carbon-13 atoms, 12  
     52*  Type "C[13]6 H[2]12 O[18]6" for C(13)6H(2)12O(18)6 (6 Carbon-13 atoms, 12 
    5153   deuterium atoms, and 6 Oxygen-18 atoms). 
    52     
     54 
    5355.. ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ 
    5456 
    55 .. note::  This help document was last changed by Steve King, 01May2015 
     57.. note::  This help document was last changed by Paul Kienzle, 05Apr2017 
    5658 
  • src/sas/sasgui/perspectives/calculator/media/slit_calculator_help.rst

    rf93b473f r5ed76f8  
    1111----------- 
    1212 
    13 This tool enables X-ray users to calculate the slit size (FWHM/2) for smearing  
     13This tool enables X-ray users to calculate the slit size (FWHM/2) for smearing 
    1414based on their half beam profile data. 
    1515 
    1616*NOTE! Whilst it may have some more generic applicability, the calculator has 
    17 only been tested with beam profile data from Anton-Paar SAXSess*\ |TM|\   
    18 *software.* 
     17only been tested with beam profile data from Anton-Paar SAXSess:sup:`TM` software.* 
    1918 
    2019.. ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ 
     
    27262) Load a beam profile file in the *Data* field using the *Browse* button. 
    2827 
    29    *NOTE! To see an example of the beam profile file format, visit the file  
     28   *NOTE! To see an example of the beam profile file format, visit the file 
    3029   beam profile.DAT in your {installation_directory}/SasView/test folder.* 
    3130 
    32 3) Once a data is loaded, the slit size is automatically computed and displayed  
     313) Once a data is loaded, the slit size is automatically computed and displayed 
    3332   in the tool window. 
    3433 
    35 *NOTE! The beam profile file does not carry any information about the units of  
     34*NOTE! The beam profile file does not carry any information about the units of 
    3635the Q data. This calculator assumes the data has units of 1/\ |Ang|\ . If the 
    3736data is not in these units it must be manually converted beforehand.* 
Note: See TracChangeset for help on using the changeset viewer.