2121
2222__all__ = ["PDFContribution" ]
2323
24+ from diffpy .cmipdf .debyepdfgenerator import DebyePDFGenerator
25+ from diffpy .cmipdf .pdfgenerator import PDFGenerator
2426from diffpy .srfit .fitbase import FitContribution , Profile , ProfileParser
2527
2628
@@ -106,7 +108,7 @@ def __init__(self, name):
106108
107109 # Data methods
108110
109- def loadData (self , datafile ):
111+ def load_data (self , datafile ):
110112 """Load the data from a datafile.
111113
112114 Parameters
@@ -121,7 +123,7 @@ def loadData(self, datafile):
121123 self .profile .load_parsed_data (parser )
122124 return
123125
124- def setCalculationRange (self , xmin = None , xmax = None , dx = None ):
126+ def set_calculation_range (self , xmin = None , xmax = None , dx = None ):
125127 """Set epsilon-inclusive calculation range.
126128
127129 Adhere to the observed ``xobs`` points when ``dx`` is the same
@@ -166,42 +168,40 @@ def savetxt(self, fname, **kwargs):
166168
167169 # Phase methods
168170
169- def addStructure (self , name , structure , periodic = True ):
171+ def add_structure (self , structure , name = "phase" , periodic = True ):
170172 """Add a phase that goes into the PDF calculation.
171173
172174 Parameters
173175 ----------
174- name
176+ structure : Structure object
177+ `diffpy.structure.Structure`, `pyobjcryst.crystal.Crystal` or
178+ `pyobjcryst.molecule.Molecule` instance.
179+ name : str, optional
175180 A name to give the generator that will manage the PDF
176181 calculation from the passed structure. The adapted
177182 structure will be accessible via the name "phase" as an
178183 attribute of the generator, e.g.
179184 contribution.name.phase, where 'contribution' is this
180185 contribution and 'name' is passed name.
181- (default), then the name will be set as "phase".
182- structure
183- diffpy.structure.Structure, pyobjcryst.crystal.Crystal or
184- pyobjcryst.molecule.Molecule instance. Default None.
185- periodic
186- The structure should be treated as periodic. If this is
186+ Default is `"phase"`.
187+ periodic : bool, optional
188+ The structure should be treated as periodic. If this is
187189 True (default), then a PDFGenerator will be used to
188190 calculate the PDF from the phase. Otherwise, a
189191 DebyePDFGenerator will be used. Note that some structures
190192 do not support periodicity, in which case this may be
191193 ignored.
192194
193195
194- Returns the new phase (ParameterSet appropriate for what was passed in
195- structure.)
196+ Returns
197+ -------
198+ The new phase (ParameterSet appropriate for what was passed in
199+ structure.)
196200 """
197201 # Based on periodic, create the proper generator.
198202 if periodic :
199- from diffpy .cmipdf .pdfgenerator import PDFGenerator
200-
201203 gen = PDFGenerator (name )
202204 else :
203- from diffpy .cmipdf .debyepdfgenerator import DebyePDFGenerator
204-
205205 gen = DebyePDFGenerator (name )
206206
207207 # Set up the generator
@@ -210,49 +210,45 @@ def addStructure(self, name, structure, periodic=True):
210210
211211 return gen .phase
212212
213- def addPhase (self , name , parset , periodic = True ):
214- """Add a phase that goes into the PDF calculation.
213+ def add_structure_from_parset (self , parset , name , periodic = True ):
214+ """Add a phase that goes into the PDF calculation from a
215+ ParameterSet.
215216
216217 Parameters
217218 ----------
218- name
219- A name to give the generator that will manage the PDF
219+ parset : SrealParSet object
220+ A SrRealParSet that holds the structural information.
221+ This can be used to share the phase between multiple
222+ BasePDFGenerators, and have the changes in one reflect in
223+ another.
224+ name : str
225+ The name to give the generator that will manage the PDF
220226 calculation from the passed parameter phase. The parset
221227 will be accessible via the name "phase" as an attribute
222228 of the generator, e.g., contribution.name.phase, where
223229 'contribution' is this contribution and 'name' is passed
224230 name.
225- parset
226- A SrRealParSet that holds the structural information.
227- This can be used to share the phase between multiple
228- BasePDFGenerators, and have the changes in one reflect in
229- another.
230- periodic
231+ periodic : bool, optional
231232 The structure should be treated as periodic. If this is
232233 True (default), then a PDFGenerator will be used to
233234 calculate the PDF from the phase. Otherwise, a
234235 DebyePDFGenerator will be used. Note that some structures
235236 do not support periodicity, in which case this may be
236237 ignored.
237238
238-
239- Returns the new phase (ParameterSet appropriate for what was passed in
240- structure.)
239+ Returns
240+ -------
241+ The new phase (ParameterSet appropriate for what was passed in
242+ parset.)
241243 """
242244 # Based on periodic, create the proper generator.
243245 if periodic :
244- from diffpy .cmipdf .pdfgenerator import PDFGenerator
245-
246246 gen = PDFGenerator (name )
247247 else :
248- from diffpy .cmipdf .debyepdfgenerator import DebyePDFGenerator
249-
250248 gen = DebyePDFGenerator (name )
251-
252249 # Set up the generator
253250 gen .set_structure_from_parset (parset , periodic )
254251 self ._setup_generator (gen )
255-
256252 return gen .phase
257253
258254 def _setup_generator (self , gen ):
0 commit comments