Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions docs/examples/core/intensityfit/npintensity.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,14 +47,14 @@
import numpy

from diffpy.cmi.fit_tools import optimize_recipe
from diffpy.cmistructure.diffpyparset import DiffpyStructureParSet
from diffpy.srfit.fitbase import (
FitContribution,
FitRecipe,
FitResults,
Profile,
ProfileGenerator,
)
from diffpy.srfit.structure.diffpyparset import DiffpyStructureParSet

######
# Example Code
Expand Down Expand Up @@ -103,7 +103,7 @@ def set_structure(self, strufile):
function whenever it is called.

This will create the refinement Parameters using the
DiffpyStructureParSet adapter from diffpy.srfit.structure.diffpyparset.
DiffpyStructureParSet adapter from diffpy.cmistructure.diffpyparset.
DiffpyStructureParSet is a ParameterSet object that organizes and gives
attribute access to Parameters and ParameterSets adapted from a diffpy
Structure object. The Parameters embedded in the DiffpyStructureParSet
Expand All @@ -113,14 +113,14 @@ def set_structure(self, strufile):
are organized hierarchically:

phase
- lattice (retrieved with 'getLattice')
- lattice (retrieved with 'get_lattice')
- a
- b
- c
- alpha
- beta
- gamma
- scatterers (retrieved with 'getScatterers')
- scatterers (retrieved with 'get_scatterers')
- atom1 (the name depends on the element)
- x
- y
Expand All @@ -136,7 +136,7 @@ def set_structure(self, strufile):
- etc.

The diffpy.structure.Structure instance is held within the
DiffpyStructureParSet as the 'stru' attribute.
DiffpyStructureParSet as the 'structure' attribute.
"""
# Load the structure from file
from diffpy.structure import Structure
Expand Down Expand Up @@ -170,7 +170,7 @@ def __call__(self, q):
"""
self.count += 1
print("iofq called", self.count)
return iofq(self.phase.stru, q)
return iofq(self.phase.structure, q)


# End class IntensityGenerator
Expand Down Expand Up @@ -287,7 +287,7 @@ def gaussian(q, q0, width):
# parameters to the same value (the lattice is cubic). Note that we
# constrain to the "a" Parameter directly. In previous examples, we
# constrained to a Variable by name. This has the same effect.
lattice = phase.getLattice()
lattice = phase.get_lattice()
a = lattice.a
recipe.add_variable(a)
recipe.add_constraint(lattice.b, a)
Expand All @@ -297,7 +297,7 @@ def gaussian(q, q0, width):
# this. Note that we don't give Uiso an initial value. The initial value
# will be inferred from the following constraints.
Uiso = recipe.create_new_variable("Uiso")
for atom in phase.getScatterers():
for atom in phase.get_scatterers():
recipe.add_constraint(atom.Uiso, Uiso)

# Give the recipe away so it can be used!
Expand Down
4 changes: 2 additions & 2 deletions docs/examples/core/intensityfit/npintensityII.py
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ def gaussian(q, q0, width):
# We can also refine structural parameters. We only have to do this once,
# since each generator holds the same DiffpyStructureParSet.
phase = generator1.phase
lattice = phase.getLattice()
lattice = phase.get_lattice()
a = recipe.add_variable(lattice.a)
# We want to allow for isotropic expansion, so we'll make constraints for
# that.
Expand All @@ -182,7 +182,7 @@ def gaussian(q, q0, width):
# this. Note that we don't give Uiso an initial value. The initial value
# will be inferred from the subsequent constraints.
Uiso = recipe.create_new_variable("Uiso")
for atom in phase.getScatterers():
for atom in phase.get_scatterers():
recipe.add_constraint(atom.Uiso, Uiso)

# Give the recipe away so it can be used!
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,9 @@
"from diffpy.srfit.fitbase import FitContribution, FitRecipe\n",
"from diffpy.srfit.fitbase import FitResults\n",
"from diffpy.srfit.fitbase import Profile\n",
"from diffpy.srfit.pdf import PDFParser, PDFGenerator\n",
"from diffpy.cmipdf import PDFParser, PDFGenerator\n",
"from diffpy.structure.parsers import get_parser\n",
"from diffpy.srfit.structure import constrain_as_space_group"
"from diffpy.cmistructure import constrain_as_space_group"
]
},
{
Expand Down Expand Up @@ -311,7 +311,7 @@
" # This Generator will later compute the model PDF for the structure\n",
" # object we provide it here.\n",
" generator_crystal1 = PDFGenerator(\"G1\")\n",
" generator_crystal1.setStructure(stru1, periodic=True)\n",
" generator_crystal1.set_structure(stru1, periodic=True)\n",
"\n",
" # 12: Create a Fit Contribution object, and arbitrarily name it 'crystal'.\n",
" # We then give the PDF Generator object we created just above\n",
Expand Down Expand Up @@ -363,8 +363,8 @@
" # below '.value = ' syntax.\n",
" recipe.crystal.G1.qdamp.value = QDAMP_I\n",
" recipe.crystal.G1.qbroad.value = QBROAD_I\n",
" recipe.crystal.G1.setQmax(QMAX)\n",
" recipe.crystal.G1.setQmin(QMIN)\n",
" recipe.crystal.G1.set_qmax(QMAX)\n",
" recipe.crystal.G1.set_qmin(QMIN)\n",
"\n",
" # 17: Add a variable to the Fit Recipe object, initialize the variables\n",
" # with some value, and tag it with an arbitrary string. Here we add the scale\n",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,10 @@
"outputs": [],
"source": [
"from diffpy.srfit.fitbase import FitContribution, FitRecipe, FitResults, Profile\n",
"from diffpy.srfit.pdf import PDFParser, PDFGenerator\n",
"from diffpy.cmipdf import PDFParser, PDFGenerator\n",
"from diffpy.structure.parsers import get_parser\n",
"from diffpy.srfit.pdf.characteristicfunctions import spherical_particle\n",
"from diffpy.srfit.structure import constrain_as_space_group"
"from diffpy.cmipdf.characteristicfunctions import spherical_particle\n",
"from diffpy.cmistructure import constrain_as_space_group"
]
},
{
Expand Down Expand Up @@ -273,7 +273,7 @@
"\n",
" # 12: Create a PDF Generator object for a periodic structure model.\n",
" generator_crystal1 = PDFGenerator(\"G1\")\n",
" generator_crystal1.setStructure(stru1, periodic=True)\n",
" generator_crystal1.set_structure(stru1, periodic=True)\n",
"\n",
" # 13: Create a Fit Contribution object.\n",
" contribution = FitContribution(\"crystal\")\n",
Expand Down Expand Up @@ -312,8 +312,8 @@
" # assign Q_max and Q_min.\n",
" generator_crystal1.qdamp.value = QDAMP_I\n",
" generator_crystal1.qbroad.value = QBROAD_I\n",
" generator_crystal1.setQmax(QMAX)\n",
" generator_crystal1.setQmin(QMIN)\n",
" generator_crystal1.set_qmax(QMAX)\n",
" generator_crystal1.set_qmin(QMIN)\n",
"\n",
" # 18: Add, initialize, and tag variables in the Fit Recipe object.\n",
" # In this case we also add 'psize', which is the NP size.\n",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,14 @@
from scipy.optimize import least_squares

# ... and the relevant CMI packages
from diffpy.cmipdf import PDFGenerator, PDFParser
from diffpy.cmistructure import constrain_as_space_group
from diffpy.srfit.fitbase import (
FitContribution,
FitRecipe,
FitResults,
Profile,
)
from diffpy.srfit.pdf import PDFGenerator, PDFParser
from diffpy.srfit.structure import constrain_as_space_group
from diffpy.structure.parsers import get_parser

plt.style.use(all_styles["bg-style"])
Expand Down Expand Up @@ -116,7 +116,7 @@ def make_recipe(cif_path, dat_path):
# This Generator will later compute the model PDF for the structure
# object we provide it here.
generator_crystal1 = PDFGenerator("G1")
generator_crystal1.setStructure(stru1, periodic=True)
generator_crystal1.set_structure(stru1, periodic=True)

# 12: Create a Fit Contribution object, and arbitrarily name it 'crystal'.
# We then give the PDF Generator object we created just above
Expand Down Expand Up @@ -173,8 +173,8 @@ def make_recipe(cif_path, dat_path):
# below '.value = ' syntax.
recipe.crystal.G1.qdamp.value = QDAMP_I
recipe.crystal.G1.qbroad.value = QBROAD_I
recipe.crystal.G1.setQmax(QMAX)
recipe.crystal.G1.setQmin(QMIN)
recipe.crystal.G1.set_qmax(QMAX)
recipe.crystal.G1.set_qmin(QMIN)

# 17: Add a variable to the Fit Recipe object, initialize the variables
# with some value, and tag it with an arbitrary string. Here we add the
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,14 +55,14 @@
"\n",
"from diffpy.utils.parsers.loaddata import loadData\n",
"from diffpy.srfit.fitbase import FitRecipe, FitContribution, Profile, FitResults\n",
"from diffpy.srfit.pdf import PDFGenerator, PDFParser\n",
"from diffpy.cmipdf import PDFGenerator, PDFParser\n",
"from diffpy.srfit.fitbase.parameterset import ParameterSet\n",
"from pyobjcryst import loadCrystal\n",
"from pyobjcryst.crystal import Crystal\n",
"\n",
"#We import the form factors. We will use this to fit the Pt nanoparticles as spherical particles.\n",
"import diffpy.srfit.pdf.characteristicfunctions\n",
"F = diffpy.srfit.pdf.characteristicfunctions"
"import diffpy.cmipdf.characteristicfunctions\n",
"F = diffpy.cmipdf.characteristicfunctions"
]
},
{
Expand Down Expand Up @@ -123,7 +123,7 @@
" fc = FitContribution(fc_name)\n",
" for name, crystal in crystals.items():\n",
" pg = PDFGenerator(name)\n",
" pg.setStructure(crystal, periodic=True)\n",
" pg.set_structure(crystal, periodic=True)\n",
" fc.add_profile_generator(pg)\n",
" for name, (f, argnames) in functions.items():\n",
" fc.register_function(f, name=name, argnames=argnames)\n",
Expand Down Expand Up @@ -236,7 +236,7 @@
" fixed=True,\n",
" tags=_get_tags(name, \"lat\")\n",
" ).bound_range(0.)\n",
" atoms: typing.List[ParameterSet] = pg.phase.getScatterers()\n",
" atoms: typing.List[ParameterSet] = pg.phase.get_scatterers()\n",
" for atom in atoms:\n",
" par = atom.Biso\n",
" recipe.add_variable(\n",
Expand Down Expand Up @@ -537,7 +537,7 @@
" if pg_names is not None:\n",
" for pg_name in pg_names:\n",
" pg: PDFGenerator = getattr(fc, pg_name)\n",
" stru: Crystal = pg.stru\n",
" stru: Crystal = pg.structure\n",
" cif_path = f_path.with_name(\n",
" \"{}_{}\".format(f_path.stem, pg_name)\n",
" ).with_suffix(\".cif\")\n",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,15 @@
from scipy.optimize import least_squares

# ... and the relevant CMI packages
from diffpy.cmipdf import PDFGenerator, PDFParser
from diffpy.cmipdf.characteristicfunctions import spherical_particle
from diffpy.cmistructure import constrain_as_space_group
from diffpy.srfit.fitbase import (
FitContribution,
FitRecipe,
FitResults,
Profile,
)
from diffpy.srfit.pdf import PDFGenerator, PDFParser
from diffpy.srfit.pdf.characteristicfunctions import spherical_particle
from diffpy.srfit.structure import constrain_as_space_group
from diffpy.structure.parsers import get_parser

plt.style.use(all_styles["bg-style"])
Expand Down Expand Up @@ -126,7 +126,7 @@ def make_recipe(cif_path, dat_path):

# 12: Create a PDF Generator object for a periodic structure model.
generator_crystal1 = PDFGenerator("G1")
generator_crystal1.setStructure(stru1, periodic=True)
generator_crystal1.set_structure(stru1, periodic=True)

# 13: Create a Fit Contribution object.
contribution = FitContribution("crystal")
Expand Down Expand Up @@ -172,8 +172,8 @@ def make_recipe(cif_path, dat_path):
# assign Q_max and Q_min.
generator_crystal1.qdamp.value = QDAMP_I
generator_crystal1.qbroad.value = QBROAD_I
generator_crystal1.setQmax(QMAX)
generator_crystal1.setQmin(QMIN)
generator_crystal1.set_qmax(QMAX)
generator_crystal1.set_qmin(QMIN)

# 18: Add, initialize, and tag variables in the Fit Recipe object.
# In this case we also add 'psize', which is the NP size.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@
from pyobjcryst.crystal import Crystal
from scipy.optimize import least_squares

from diffpy.cmipdf import PDFGenerator, PDFParser
from diffpy.srfit.fitbase import (
FitContribution,
FitRecipe,
FitResults,
Profile,
)
from diffpy.srfit.fitbase.parameterset import ParameterSet
from diffpy.srfit.pdf import PDFGenerator, PDFParser


# Recipe functions
Expand Down Expand Up @@ -51,7 +51,7 @@ def _create_recipe(
fc = FitContribution(fc_name)
for name, crystal in crystals.items():
pg = PDFGenerator(name)
pg.setStructure(crystal, periodic=True)
pg.set_structure(crystal, periodic=True)
fc.add_profile_generator(pg)
for name, (f, argnames) in functions.items():
fc.register_function(f, name=name, argnames=argnames)
Expand Down Expand Up @@ -162,7 +162,7 @@ def _add_params_in_pg(recipe: FitRecipe, pg: PDFGenerator) -> None:
fixed=True,
tags=_get_tags(name, "lat"),
).bound_range(0.0)
atoms: typing.List[ParameterSet] = pg.phase.getScatterers()
atoms: typing.List[ParameterSet] = pg.phase.get_scatterers()
for atom in atoms:
par = atom.Biso
recipe.add_variable(
Expand Down Expand Up @@ -435,7 +435,7 @@ def save_results(
if pg_names is not None:
for pg_name in pg_names:
pg: PDFGenerator = getattr(fc, pg_name)
stru: Crystal = pg.stru
stru: Crystal = pg.structure
cif_path = f_path.with_name(
"{}_{}".format(f_path.stem, pg_name)
).with_suffix(".cif")
Expand Down
12 changes: 6 additions & 6 deletions docs/examples/pdf/ch05Fit2Phase/solutions/diffpy-cmi/fit2P.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,14 @@
from scipy.optimize import least_squares

# ... and the relevant CMI packages
from diffpy.cmipdf import PDFGenerator, PDFParser
from diffpy.cmistructure import constrain_as_space_group
from diffpy.srfit.fitbase import (
FitContribution,
FitRecipe,
FitResults,
Profile,
)
from diffpy.srfit.pdf import PDFGenerator, PDFParser
from diffpy.srfit.structure import constrain_as_space_group
from diffpy.structure.parsers import get_parser

plt.style.use(all_styles["bg-style"])
Expand Down Expand Up @@ -109,12 +109,12 @@ def make_recipe(cif_path1, cif_path2, dat_path):
# 11a: Create a PDF Generator object for a periodic structure model
# of phase 1.
generator_crystal1 = PDFGenerator("G_Si")
generator_crystal1.setStructure(stru1, periodic=True)
generator_crystal1.set_structure(stru1, periodic=True)

# 11b: Create a PDF Generator object for a periodic structure model
# of phase 2.
generator_crystal2 = PDFGenerator("G_Ni")
generator_crystal2.setStructure(stru2, periodic=True)
generator_crystal2.set_structure(stru2, periodic=True)

# 12: Create a Fit Contribution object. This is new, as we
# need to tell the Fit Contribution about BOTH the phase
Expand Down Expand Up @@ -192,8 +192,8 @@ def make_recipe(cif_path1, cif_path2, dat_path):
# assign Q_max and Q_min for each phase.
generator.qdamp.value = QDAMP_I
generator.qbroad.value = QBROAD_I
generator.setQmax(QMAX)
generator.setQmin(QMIN)
generator.set_qmax(QMAX)
generator.set_qmin(QMIN)

# 18c: Get the symmetry equivalent parameters for each phase.
spacegroupparams = constrain_as_space_group(
Expand Down
Loading
Loading