Changeset 3085
- Timestamp:
- Sep 19, 2017 12:12:48 PM (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/GSASIIscriptable.py
r3069 r3085 30 30 * Histogram-and-phase (HAP). Turned on and off through 31 31 :func:`~G2Phase.set_HAP_refinements` and :func:`~G2Phase.clear_HAP_refinements` 32 33 34 ============================ 35 Refinement specifiers format 36 ============================ 37 38 .. _Histogram_parameters_table: 39 40 -------------------- 41 Histogram parameters 42 -------------------- 43 44 This table describes the dictionaries supplied to :func:`~G2PwdrData.set_refinement` 45 and :func:`~G2PwdrData.clear_refinement`. 46 47 .. tabularcolumns:: |l|p| 48 49 ===================== ==================== ==================== 50 key subkey explanation 51 ===================== ==================== ==================== 52 Limits The 2-theta range of values to consider. Can 53 be either a dictionary of 'low' and 'high', 54 or a list of 2 items [low, high] 55 \ low Sets the low limit 56 \ high Sets the high limit 57 Sample Parameters Should be provided as a **list** of subkeys 58 to set or clear, e.g. ['DisplaceX', 'Scale'] 59 \ Absorption 60 \ Contrast 61 \ DisplaceX Sample displacement along the X direction 62 \ DisplaceY Sample displacement along the Y direction 63 \ Scale Histogram Scale factor 64 Background Sample background. If value is a boolean, 65 the background's 'refine' parameter is set 66 to the given boolean. Usually should be a 67 dictionary with any of the following keys: 68 \ type The background model, e.g. 'chebyschev' 69 \ refine The value of the refine flag, boolean 70 \ no. coeffs Number of coefficients to use, integer 71 \ coeffs List of floats, literal values for background 72 \ FixedPoints List of (2-theta, intensity) values for fixed points 73 \ fit fixed points If True, triggers a fit to the fixed points to be calculated. It is calculated when this key is detected, regardless of calls to refine. 74 Instrument Parameters As in Sample Paramters, Should be provided as a **list** of subkeys to 75 set or clear, e.g. ['X', 'Y', 'Zero', 'SH/L'] 76 \ U, V, W All separate keys. Gaussian peak profile terms 77 \ X, Y Separate keys. Lorentzian peak profile terms 78 \ Zero Zero shift 79 \ SH/L 80 \ Polariz. Polarization parameter 81 \ Lam Lambda, the incident wavelength 82 ===================== ==================== ==================== 83 84 85 .. _Phase_parameters_table: 86 87 ---------------- 88 Phase parameters 89 ---------------- 90 91 This table describes the dictionaries supplied to :func:`~G2Phase.set_refinement` 92 and :func:`~G2Phase.clear_refinement`. 93 94 95 .. _HAP_parameters_table: 96 97 ------------------------------ 98 Histogram-and-phase parameters 99 ------------------------------ 100 101 This table describes the dictionaries supplied to :func:`~G2Phase.set_HAP_refinement` 102 and :func:`~G2Phase.clear_HAP_refinement`. 103 104 105 ============================ 106 Scriptable API 107 ============================ 32 108 """ 33 109 from __future__ import division, print_function # needed? … … 720 796 SaveDictToProjFile(self.data, self.names, self.filename) 721 797 722 def add_powder_histogram(self, datafile, iparams ):798 def add_powder_histogram(self, datafile, iparams, phases=[]): 723 799 """Loads a powder data histogram into the project. 724 800 … … 728 804 :param str datafile: The powder data file to read, a filename. 729 805 :param str iparams: The instrument parameters file, a filename. 806 :param list phases: Phases to link to the new histogram 730 807 731 808 :returns: A :class:`G2PwdrData` object representing … … 741 818 if histname in self.data: 742 819 print("Warning - redefining histogram", histname) 820 elif self.names[-1][0] == 'Phases': 821 self.names.insert(-1, new_names) 743 822 else: 744 if self.names[-1][0] == 'Phases': 745 self.names.insert(-1, new_names) 746 else: 747 self.names.append(new_names) 823 self.names.append(new_names) 748 824 self.data[histname] = pwdrdata 749 825 self.update_ids() 826 827 for phase in phases: 828 phase = self.phase(phase) 829 self.link_histogram_phase(histname, phase) 830 750 831 return self.histogram(histname) 751 832 … … 803 884 for hist in histograms: 804 885 self.link_histogram_phase(hist, phasename) 805 # if histname.startswith('HKLF '):806 # raise NotImplementedError("Does not support HKLF yet")807 # elif histname.startswith('PWDR '):808 # hist = self.histogram(histname)809 # hist['Reflection Lists'][generalData['Name']] = {}810 # UseList[histname] = SetDefaultDData('PWDR', histname, NShkl=NShkl, NDij=NDij)811 # for key, val in [('Use', True), ('LeBail', False),812 # ('newLeBail', True),813 # ('Babinet', {'BabA': [0.0, False],814 # 'BabU': [0.0, False]})]:815 # if key not in UseList[histname]:816 # UseList[histname][key] = val817 # else:818 # raise NotImplementedError("Unexpected histogram" + histname)819 886 820 887 for obj in self.names: … … 1154 1221 string variable specifiers, or arguments for :meth:`make_var_obj` 1155 1222 :param str type: A string constraint type specifier. See 1156 :class:`~GSASIIscriptable.G2Project.add_constraint_raw`""" 1223 :class:`~GSASIIscriptable.G2Project.add_constraint_raw` 1224 1225 """ 1157 1226 for var in vars: 1158 1227 if isinstance(var, str): … … 1418 1487 """Sets the refinement parameter 'key' to the specification 'value' 1419 1488 1420 :param dict refs: A dictionary of the parameters to be set. 1421 1422 :returns: None""" 1489 :param dict refs: A dictionary of the parameters to be set. See 1490 :ref:`Histogram_parameters_table` for a description of 1491 what these dictionaries should be. 1492 1493 :returns: None 1494 1495 """ 1423 1496 do_fit_fixed_points = False 1424 1497 for key, value in refs.items(): … … 1436 1509 sample = self.data['Sample Parameters'] 1437 1510 for sparam in value: 1511 if sparam not in sample: 1512 raise ValueError("Unknown refinement parameter, " 1513 + str(sparam)) 1438 1514 sample[sparam][1] = True 1439 1515 elif key == 'Background': … … 1597 1673 .. seealso:: 1598 1674 :func:`~G2Phase.get_cell_and_esd` 1675 1599 1676 """ 1600 1677 cell = self.data['General']['Cell'] … … 1609 1686 1610 1687 :returns: a tuple of two dictionaries 1688 1611 1689 .. seealso:: 1612 1690 :func:`~G2Phase.get_cell` 1691 1613 1692 """ 1614 1693 # translated from GSASIIstrIO.ExportBaseclass.GetCell … … 1731 1810 """Sets the refinement parameter 'key' to the specification 'value' 1732 1811 1733 :param dict refs: A dictionary of the parameters to be set. 1812 :param dict refs: A dictionary of the parameters to be set. See 1813 :ref:`Phase_parameters_table` for a description of 1814 this dictionary. 1734 1815 1735 1816 :returns: None""" … … 1746 1827 else: 1747 1828 atom = self.atom(atomlabel) 1829 if atom is None: 1830 raise ValueError("No such atom: " + atomlabel) 1748 1831 atom.refinement_flags = atomrefinement 1749 1832 elif key == "LeBail": … … 1783 1866 the given histograms 1784 1867 1785 :param dict refs: A dictionary of the parameters to be set. 1868 :param dict refs: A dictionary of the parameters to be set. See 1869 :ref:`HAP_parameters_table` for a description of this 1870 dictionary. 1786 1871 :param histograms: Either 'all' (default) or a list of the histograms 1787 1872 whose HAP parameters will be set with this phase. Histogram and phase … … 1817 1902 mustrain = h['Mustrain'] 1818 1903 newType = None 1819 if isinstance(val, str):1904 if isinstance(val, (unicode, str)): 1820 1905 if val in ['isotropic', 'uniaxial', 'generalized']: 1821 1906 newType = val … … 1832 1917 mustrain[5] = [False for p in mustrain[4]] 1833 1918 elif newType == 'uniaxial': 1834 pass 1919 if 'refine' in val: 1920 types = val['refine'] 1921 if isinstance(types, (unicode, str)): 1922 types = [types] 1923 else: 1924 types = [] 1925 1926 for unitype in types: 1927 if unitype == 'equatorial': 1928 mustrain[2][0] = True 1929 elif unitype == 'axial': 1930 mustrain[2][1] = True 1931 else: 1932 msg = 'Invalid uniaxial mustrain type' 1933 raise ValueError(msg + ': ' + unitype) 1835 1934 else: # newtype == 'generalized' 1836 1935 mustrain[2] = [False for p in mustrain[1]] 1936 1837 1937 if direction: 1838 1938 direction = [int(n) for n in direction]
Note: See TracChangeset
for help on using the changeset viewer.