Changeset 3009 for trunk/GSASIIscriptable.py
- Timestamp:
- Aug 16, 2017 10:00:23 AM (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/GSASIIscriptable.py
r3007 r3009 16 16 Supports a command line interface as well. 17 17 18 19 18 Look at :class:`G2Project` to start. 19 20 ===================== 21 Refinement parameters 22 ===================== 23 24 There are three classes of refinement parameters: 25 26 * Histogram. Turned on and off through :func:`~G2PwdrData.set_refinements` 27 and :func:`~G2PwdrData.clear_refinements` 28 * Phase. Turned on and off through :func:`~G2Phase.set_refinements` 29 and :func:`~G2Phase.clear_refinements` 30 * Histogram-and-phase (HAP). Turned on and off through 31 :func:`~G2Phase.set_HAP_refinements` and :func:`~G2Phase.clear_HAP_refinements` 20 32 """ 21 33 from __future__ import division, print_function # needed? … … 134 146 135 147 :param dict Project: representation of gpx file following the GSAS-II 136 tree structure as described for LoadDictFromProjFile148 tree structure as described for LoadDictFromProjFile 137 149 :param list nameList: names of main tree entries & subentries used to reconstruct project file 138 150 :param str ProjFile: full file name for output project.gpx file (including extension) … … 159 171 160 172 :returns list rdlist: list of reader objects containing powder data, one for each 161 "Bank" of data encountered in file. Items in reader object of interest are:162 163 * rd.comments: list of str: comments found on powder file164 * rd.dnames: list of str: data nammes suitable for use in GSASII data tree NB: duplicated in all rd entries in rdlist165 * rd.powderdata: list of numpy arrays: pos,int,wt,zeros,zeros,zeros as needed for a PWDR entry in GSASII data tree.173 "Bank" of data encountered in file. Items in reader object of interest are: 174 175 * rd.comments: list of str: comments found on powder file 176 * rd.dnames: list of str: data nammes suitable for use in GSASII data tree NB: duplicated in all rd entries in rdlist 177 * rd.powderdata: list of numpy arrays: pos,int,wt,zeros,zeros,zeros as needed for a PWDR entry in GSASII data tree. 166 178 ''' 167 179 rdfile,rdpath,descr = imp.find_module(reader) … … 194 206 '''Create an initial Histogram dictionary 195 207 196 Author: Jackson O'Donnell jacksonhodonnell@gmail.com208 Author: Jackson O'Donnell (jacksonhodonnell .at. gmail.com) 197 209 ''' 198 210 if dType in ['SXC','SNC']: … … 222 234 223 235 from GSASIIphsGUI.py, near end of UpdatePhaseData 224 Author: Jackson O'Donnell jacksonhodonnell@gmail.com 236 237 Author: Jackson O'Donnell (jacksonhodonnell .at. gmail.com) 225 238 ''' 226 239 if 'RBModels' not in data: … … 241 254 242 255 From GSASIIphsGui.py, function of the same name. Minor changes for imports etc. 243 Author: Jackson O'Donnell jacksonhodonnell@gmail.com 256 257 Author: Jackson O'Donnell (jacksonhodonnell .at. gmail.com) 244 258 """ 245 259 mapDefault = {'MapType':'','RefList':'','Resolution':0.5,'Show bonds':True, … … 371 385 372 386 Returns: project dictionary, name list 373 Author: Jackson O'Donnell jacksonhodonnell@gmail.com 387 388 Author: Jackson O'Donnell (jacksonhodonnell .at. gmail.com) 374 389 """ 375 390 if not filename: … … 512 527 """Loads powder data from a reader object, and assembles it into a GSASII data tree. 513 528 514 Returns: (name, tree) - 2-tuple of the histogram name (str), and data 515 Author: Jackson O'Donnell jacksonhodonnell@gmail.com 529 :returns: (name, tree) - 2-tuple of the histogram name (str), and data 530 531 Author: Jackson O'Donnell (jacksonhodonnell .at. gmail.com) 516 532 """ 517 533 HistName = 'PWDR ' + G2obj.StripUnicode(reader.idstring, '_') … … 580 596 def _deep_copy_into(from_, into): 581 597 """Helper function for reloading .gpx file. See G2Project.reload() 582 Author: Jackson O'Donnell jacksonhodonnell@gmail.com 598 599 :author: Jackson O'Donnell (jacksonhodonnell .at. gmail.com) 583 600 """ 584 601 if isinstance(from_, dict) and isinstance(into, dict): … … 619 636 of overrides are implemented so that the wrapper behaves like a dictionary. 620 637 621 Author: Jackson O'Donnell jacksonhodonnell@gmail.com638 Author: Jackson O'Donnell (jacksonhodonnell .at. gmail.com) 622 639 """ 623 640 def __init__(self, datadict): … … 652 669 653 670 :param str gpxfile: Existing .gpx file to be loaded. If nonexistent, 654 creates an empty project.671 creates an empty project. 655 672 :param str author: Author's name. Optional. 656 673 :param str filename: The filename the project should be saved to in 657 the future. If both filename and gpxfile are present, the project is658 loaded from the gpxfile, then set to save to filename in the future"""674 the future. If both filename and gpxfile are present, the project is 675 loaded from the gpxfile, then set to save to filename in the future""" 659 676 if gpxfile is None: 660 677 filename = os.path.abspath(os.path.expanduser(filename)) … … 712 729 713 730 :returns: A :class:`G2PwdrData` object representing 714 the histogram731 the histogram 715 732 """ 716 733 LoadG2fil() … … 737 754 :param str phasename: The name of the new phase, or None for the default 738 755 :param list histograms: The names of the histograms to associate with 739 this phase756 this phase 740 757 741 758 :returns: A :class:`G2Phase` object representing the 742 new phase.759 new phase. 743 760 """ 744 761 LoadG2fil() … … 829 846 self.reload() 830 847 831 def histogram_names(self):832 """Gives a list of the names of each histogram in the project.833 834 :returns: list of strings835 836 .. seealso::837 :func:`~GSASIIscriptable.G2Project.histogram`838 :func:`~GSASIIscriptable.G2Project.histograms`839 :func:`~GSASIIscriptable.G2Project.phase`840 :func:`~GSASIIscriptable.G2Project.phases`841 :func:`~GSASIIscriptable.G2Project.phase_names`842 """843 output = []844 for obj in self.names:845 if len(obj) > 1 and obj[0] != u'Phases':846 output.append(obj[0])847 return output848 849 848 def histogram(self, histname): 850 849 """Returns the histogram named histname, or None if it does not exist. … … 852 851 :param histname: The name of the histogram (str), or ranId or index. 853 852 :returns: A :class:`G2PwdrData` object, or None if 854 the histogram does not exist853 the histogram does not exist 855 854 856 855 .. seealso:: … … 861 860 if histname in self.data: 862 861 return G2PwdrData(self.data[histname], self) 863 histRanId = None864 862 for key, val in G2obj.HistIdLookup.items(): 865 863 name, ranId = val … … 883 881 return output 884 882 885 def phase_names(self):886 """Gives an list of the names of each phase in the project.887 888 :returns: A list of strings889 890 .. seealso::891 :func:`~GSASIIscriptable.G2Project.histogram`892 :func:`~GSASIIscriptable.G2Project.histograms`893 :func:`~GSASIIscriptable.G2Project.phase`894 :func:`~GSASIIscriptable.G2Project.phases`895 """896 for obj in self.names:897 if obj[0] == 'Phases':898 return obj[1:]899 return []900 901 883 def phase(self, phasename): 902 884 """ 903 885 Gives an object representing the specified phase in this project. 904 886 905 :param str phasename: The name of the desired phase 887 :param str phasename: The name of the desired phase. Either the name 888 (str), the phase's ranId, or the phase's index 906 889 :returns: A :class:`G2Phase` object 907 890 :raises: KeyError … … 915 898 if phasename in phases: 916 899 return G2Phase(phases[phasename], phasename, self) 917 phaseRanId = None918 900 for key, val in G2obj.PhaseIdLookup.items(): 919 901 name, ranId = val … … 926 908 Returns a list of all the phases in the project. 927 909 928 :returns: A :class:`G2Phase`910 :returns: A list of :class:`G2Phase` objects 929 911 930 912 .. seealso:: … … 944 926 :param list refinements: A list of dictionaries defining refinements 945 927 :param str histogram: Name of histogram for refinements to be applied 946 to, or 'all'928 to, or 'all' 947 929 :param str phase: Name of phase for refinements to be applied to, or 948 'all'930 'all' 949 931 """ 950 932 if outputnames: … … 985 967 :param dict refinement: The refinements to be conducted 986 968 :param histogram: Either a name of a histogram (str), a list of 987 histogram names, or 'all' (default)969 histogram names, or 'all' (default) 988 970 :param phase: Either a name of a phase (str), a list of phase names, or 989 'all' (default)971 'all' (default) 990 972 991 973 .. seealso:: … … 1082 1064 type is passed directly to add_constraint_raw as consType 1083 1065 1084 :param list vars: A list of variables to hold. Either G2obj.G2VarObjobjects,1085 string variable specifiers, or arguments for :meth:`make_var_obj`1066 :param list vars: A list of variables to hold. Either :class:`GSASIIobj.G2VarObj` objects, 1067 string variable specifiers, or arguments for :meth:`make_var_obj` 1086 1068 :param str type: A string constraint type specifier. See 1087 1069 :class:`~GSASIIscriptable.G2Project.add_constraint_raw`""" … … 1140 1122 class G2AtomRecord(G2ObjectWrapper): 1141 1123 """Wrapper for an atom record. Has convenient accessors via @property. 1124 1125 1126 Available accessors: label, type, refinement_flags, coordinates, 1127 occupancy, ranId, id, adp_flag, uiso 1142 1128 1143 1129 Example: … … 1154 1140 >>> atom.ranId 1155 1141 4615973324315876477 1142 >>> atom.occupancy 1143 1.0 1156 1144 """ 1157 1145 def __init__(self, data, indices, proj): … … 1183 1171 def coordinates(self): 1184 1172 return tuple(self.data[self.cx:self.cx+3]) 1173 1174 @property 1175 def occupancy(self): 1176 return self.data[self.cx+3] 1177 1178 @occupancy.setter 1179 def occupancy(self, val): 1180 self.data[self.cx+3] = float(val) 1185 1181 1186 1182 @property … … 1424 1420 class G2Phase(G2ObjectWrapper): 1425 1421 """A wrapper object around a given phase. 1426 Author: Jackson O'Donnell jacksonhodonnell@gmail.com 1422 1423 Author: Jackson O'Donnell (jacksonhodonnell .at. gmail.com) 1427 1424 """ 1428 1425 def __init__(self, data, name, proj): … … 1448 1445 :param str atomlabel: The name of the atom (e.g. "O2") 1449 1446 :returns: A :class:`G2AtomRecord` object 1450 representing the atom.1447 representing the atom. 1451 1448 """ 1452 1449 # Consult GSASIIobj.py for the meaning of this … … 1461 1458 """Returns a list of atoms present in the phase. 1462 1459 1463 :returns: A list of :class:`G2AtomRecord` objects. See 1464 also :func:`~GSASIIscriptable.G2Phase.atom` 1460 :returns: A list of :class:`G2AtomRecord` objects. 1461 1462 .. seealso:: 1463 :func:`~GSASIIscriptable.G2Phase.atom` 1464 :class:`G2AtomRecord` 1465 1465 """ 1466 1466 ptrs = self.data['General']['AtomPtrs'] … … 1552 1552 :param dict refs: A dictionary of the parameters to be set. 1553 1553 :param histograms: Either 'all' (default) or a list of the histograms 1554 whose HAP parameters will be set with this phase. Histogram and phase1555 must already be associated1554 whose HAP parameters will be set with this phase. Histogram and phase 1555 must already be associated 1556 1556 1557 1557 :returns: None … … 1628 1628 :param dict refs: A dictionary of the parameters to be cleared. 1629 1629 :param histograms: Either 'all' (default) or a list of the histograms 1630 whose HAP parameters will be cleared with this phase. Histogram and1631 phase must already be associated1630 whose HAP parameters will be cleared with this phase. Histogram and 1631 phase must already be associated 1632 1632 1633 1633 :returns: None
Note: See TracChangeset
for help on using the changeset viewer.