diffpy.srfit 3.1.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (73) hide show
  1. diffpy/__init__.py +15 -0
  2. diffpy/srfit/__init__.py +41 -0
  3. diffpy/srfit/equation/__init__.py +31 -0
  4. diffpy/srfit/equation/builder.py +702 -0
  5. diffpy/srfit/equation/equationmod.py +213 -0
  6. diffpy/srfit/equation/literals/__init__.py +71 -0
  7. diffpy/srfit/equation/literals/abcs.py +81 -0
  8. diffpy/srfit/equation/literals/argument.py +76 -0
  9. diffpy/srfit/equation/literals/literal.py +69 -0
  10. diffpy/srfit/equation/literals/operators.py +380 -0
  11. diffpy/srfit/equation/visitors/__init__.py +94 -0
  12. diffpy/srfit/equation/visitors/argfinder.py +62 -0
  13. diffpy/srfit/equation/visitors/printer.py +120 -0
  14. diffpy/srfit/equation/visitors/swapper.py +142 -0
  15. diffpy/srfit/equation/visitors/validator.py +113 -0
  16. diffpy/srfit/equation/visitors/visitor.py +62 -0
  17. diffpy/srfit/exceptions.py +29 -0
  18. diffpy/srfit/fitbase/__init__.py +53 -0
  19. diffpy/srfit/fitbase/calculator.py +110 -0
  20. diffpy/srfit/fitbase/configurable.py +57 -0
  21. diffpy/srfit/fitbase/constraint.py +117 -0
  22. diffpy/srfit/fitbase/fitcontribution.py +351 -0
  23. diffpy/srfit/fitbase/fithook.py +227 -0
  24. diffpy/srfit/fitbase/fitrecipe.py +826 -0
  25. diffpy/srfit/fitbase/fitresults.py +674 -0
  26. diffpy/srfit/fitbase/parameter.py +314 -0
  27. diffpy/srfit/fitbase/parameterset.py +110 -0
  28. diffpy/srfit/fitbase/profile.py +405 -0
  29. diffpy/srfit/fitbase/profilegenerator.py +168 -0
  30. diffpy/srfit/fitbase/profileparser.py +179 -0
  31. diffpy/srfit/fitbase/recipeorganizer.py +1074 -0
  32. diffpy/srfit/fitbase/restraint.py +117 -0
  33. diffpy/srfit/fitbase/simplerecipe.py +230 -0
  34. diffpy/srfit/fitbase/validatable.py +59 -0
  35. diffpy/srfit/interface/__init__.py +33 -0
  36. diffpy/srfit/interface/interface.py +180 -0
  37. diffpy/srfit/pdf/__init__.py +24 -0
  38. diffpy/srfit/pdf/basepdfgenerator.py +296 -0
  39. diffpy/srfit/pdf/characteristicfunctions.py +432 -0
  40. diffpy/srfit/pdf/debyepdfgenerator.py +115 -0
  41. diffpy/srfit/pdf/pdfcontribution.py +311 -0
  42. diffpy/srfit/pdf/pdfgenerator.py +77 -0
  43. diffpy/srfit/pdf/pdfparser.py +226 -0
  44. diffpy/srfit/sas/__init__.py +30 -0
  45. diffpy/srfit/sas/prcalculator.py +139 -0
  46. diffpy/srfit/sas/sasgenerator.py +70 -0
  47. diffpy/srfit/sas/sasimport.py +66 -0
  48. diffpy/srfit/sas/sasparameter.py +70 -0
  49. diffpy/srfit/sas/sasparser.py +133 -0
  50. diffpy/srfit/sas/sasprofile.py +94 -0
  51. diffpy/srfit/structure/__init__.py +60 -0
  52. diffpy/srfit/structure/basestructureparset.py +62 -0
  53. diffpy/srfit/structure/bvsrestraint.py +101 -0
  54. diffpy/srfit/structure/cctbxparset.py +292 -0
  55. diffpy/srfit/structure/diffpyparset.py +303 -0
  56. diffpy/srfit/structure/objcrystparset.py +1552 -0
  57. diffpy/srfit/structure/sgconstraints.py +761 -0
  58. diffpy/srfit/structure/srrealparset.py +92 -0
  59. diffpy/srfit/util/__init__.py +50 -0
  60. diffpy/srfit/util/argbinders.py +29 -0
  61. diffpy/srfit/util/inpututils.py +50 -0
  62. diffpy/srfit/util/nameutils.py +45 -0
  63. diffpy/srfit/util/observable.py +93 -0
  64. diffpy/srfit/util/tagmanager.py +150 -0
  65. diffpy/srfit/util/weakrefcallable.py +170 -0
  66. diffpy/srfit/version.py +26 -0
  67. diffpy_srfit-3.1.0.dist-info/METADATA +216 -0
  68. diffpy_srfit-3.1.0.dist-info/RECORD +73 -0
  69. diffpy_srfit-3.1.0.dist-info/WHEEL +5 -0
  70. diffpy_srfit-3.1.0.dist-info/licenses/AUTHORS.rst +10 -0
  71. diffpy_srfit-3.1.0.dist-info/licenses/LICENSE.rst +138 -0
  72. diffpy_srfit-3.1.0.dist-info/licenses/LICENSE_DANSE.rst +34 -0
  73. diffpy_srfit-3.1.0.dist-info/top_level.txt +1 -0
@@ -0,0 +1,179 @@
1
+ #!/usr/bin/env python
2
+ ##############################################################################
3
+ #
4
+ # diffpy.srfit by DANSE Diffraction group
5
+ # Simon J. L. Billinge
6
+ # (c) 2008 The Trustees of Columbia University
7
+ # in the City of New York. All rights reserved.
8
+ #
9
+ # File coded by: Chris Farrow
10
+ #
11
+ # See AUTHORS.txt for a list of people who contributed.
12
+ # See LICENSE_DANSE.txt for license information.
13
+ #
14
+ ##############################################################################
15
+ """This module contains classes for parsing profiles from files.
16
+
17
+ ProfileParser is a base class for parsing data. It can interact with a
18
+ Profile object to automatically set the Profile's data and metadata.
19
+ Each specific file format must be encapsulated in a ProfileParser
20
+ subclass.
21
+
22
+ See the class documentation for more information.
23
+ """
24
+
25
+
26
+ from diffpy.srfit.exceptions import ParseError
27
+
28
+
29
+ class ProfileParser(object):
30
+ """Class for parsing data from a or string.
31
+
32
+ Attributes
33
+
34
+ _format -- Name of the data format that this parses (string, default
35
+ ""). The format string is a unique identifier for the data
36
+ format handled by the parser.
37
+ _banks -- The data from each bank. Each bank contains a (x, y, dx,
38
+ dy)
39
+ tuple:
40
+ x -- A numpy array containing the independent
41
+ variable read from the file.
42
+ y -- A numpy array containing the profile
43
+ from the file.
44
+ dx -- A numpy array containing the uncertainty in x
45
+ read from the file. This is None if the
46
+ uncertainty cannot be read.
47
+ dy -- A numpy array containing the uncertainty read
48
+ from the file. This is None if the uncertainty
49
+ cannot be read.
50
+ _x -- Independent variable from the chosen bank
51
+ _y -- Profile from the chosen bank
52
+ _dx -- Uncertainty in independent variable from the chosen bank
53
+ _dy -- Uncertainty in profile from the chosen bank
54
+ _meta -- A dictionary containing metadata read from the file.
55
+
56
+ General Metadata
57
+
58
+ filename -- The name of the file from which data was parsed. This key
59
+ will not exist if data was not read from file.
60
+ nbanks -- The number of banks parsed.
61
+ bank -- The chosen bank number.
62
+ """
63
+
64
+ _format = ""
65
+
66
+ def __init__(self):
67
+ """Initialize the attributes."""
68
+ self._banks = []
69
+ self._meta = {}
70
+ self._x = None
71
+ self._y = None
72
+ self._dx = None
73
+ self._dy = None
74
+ return
75
+
76
+ def getFormat(self):
77
+ """Get the format string."""
78
+ return self._format
79
+
80
+ def parseString(self, patstring):
81
+ """Parse a string and set the _x, _y, _dx, _dy and _meta variables.
82
+
83
+ When _dx or _dy cannot be obtained in the data format it is set to
84
+ None.
85
+
86
+ This wipes out the currently loaded data and selected bank number.
87
+
88
+ Arguments
89
+ patstring -- A string containing the pattern
90
+
91
+ Raises ParseError if the string cannot be parsed
92
+ """
93
+ raise NotImplementedError()
94
+
95
+ def parseFile(self, filename):
96
+ """Parse a file and set the _x, _y, _dx, _dy and _meta variables.
97
+
98
+ This wipes out the currently loaded data and selected bank number.
99
+
100
+ Arguments
101
+ filename -- The name of the file to parse
102
+
103
+ Raises IOError if the file cannot be read
104
+ Raises ParseError if the file cannot be parsed
105
+ """
106
+ infile = open(filename, "r")
107
+ self._banks = []
108
+ self._meta = {}
109
+ filestring = infile.read()
110
+ self.parseString(filestring)
111
+ infile.close()
112
+ self._meta["filename"] = filename
113
+
114
+ if len(self._banks) < 1:
115
+ raise ParseError("There are no data in the banks")
116
+
117
+ self.selectBank(0)
118
+ return
119
+
120
+ def getNumBanks(self):
121
+ """Get the number of banks read by the parser."""
122
+ return len(self._banks)
123
+
124
+ def selectBank(self, index):
125
+ """Select which bank to use.
126
+
127
+ This method should only be called after the data has been parsed. The
128
+ chosen bank number is not persistent, and so must be re-selected if the
129
+ parser is used to parse more data. This uses python list notation, so
130
+ index -n returns the nth bank from the end.
131
+
132
+ Arguments:
133
+ index -- index of bank (integer, starting at 0).
134
+
135
+ Raises IndexError if requesting a bank that does not exist
136
+ """
137
+ if index is None:
138
+ index = self._meta.get("bank", 0)
139
+
140
+ numbanks = self.getNumBanks()
141
+ if index > numbanks:
142
+ raise IndexError("Bank index out of range")
143
+
144
+ if index < 0:
145
+ index += numbanks
146
+
147
+ if index < 0:
148
+ raise IndexError("Bank index out of range")
149
+
150
+ self._meta["bank"] = index
151
+ self._meta["nbanks"] = numbanks
152
+ self._x, self._y, self._dx, self._dy = self._banks[index]
153
+ return
154
+
155
+ def getData(self, index=None):
156
+ """Get the data.
157
+
158
+ This method should only be called after the data has been parsed. The
159
+ chosen bank number is not persistent, and so must be re-selected if the
160
+ parser is used to parse more data. This uses python list notation, so
161
+ index -n returns the nth bank from the end.
162
+
163
+ Arguments:
164
+ index -- index of bank (integer, starting at 0, default None). If
165
+ index is None then the currently selected bank is used.
166
+
167
+ This returns (x, y, dx, dy) tuple for the bank. dx is 0 if it cannot
168
+ be determined from the data format.
169
+ """
170
+ self.selectBank(index)
171
+
172
+ return self._x, self._y, self._dx, self._dy
173
+
174
+ def getMetaData(self):
175
+ """Get the parsed metadata."""
176
+ return self._meta
177
+
178
+
179
+ # End of ProfileParser