Package diffpy :: Package pdfgui :: Package control :: Module pdffitsandbox :: Class PdfFitSandbox
[hide private]
[frames] | no frames]

Class PdfFitSandbox

source code

PdfFit sandbox for importing pdffit2 scripts.

Data members:
    _fits       -- list of Fitting instances
    _curphase   -- 0 based index of selected phase
    _curdataset -- 0 based index of selected datased



Instance Methods [hide private]
 
__init__(self) source code
 
allfits(self)
Get resulting list of Fitting and Calculations...
source code
 
sandbox(self)
Create sandbox dictionary suitable for script evaluation...
source code
 
loadscript(self, scriptfile)
Execute scriptfile in this sandbox.
source code
 
read_struct(self, filename)
Read structure from file into memory.
source code
 
read_struct_string(self, s, name='')
Read structure from a string into memory.
source code
 
read_data(self, filename, stype, qmax, qdamp)
Read pdf data from file into memory.
source code
 
read_data_string(self, s, stype, qmax, qdamp, name='')
Read pdf data from a string into memory.
source code
 
read_data_lists(self, stype, qmax, qdamp, r_data, Gr_data, dGr_data=None, name='list')
Read pdf data into memory from lists.
source code
 
pdfrange(self, iset, rmin, rmax)
Set the range of the fit in specified dataset.
source code
 
reset(self)
Clear the last fit.
source code
 
alloc(self, stype, qmax, qdamp, rmin, rmax, rlen)
Allocate space for a PDF calculation.
source code
 
calc(self)
Calculate the PDF of the imported structure.
source code
 
refine(self, toler=1e-08)
Fit the theory to the imported data.
source code
 
refine_step(self, toler=1e-08)
Run a single step of the fit.
source code
 
save_pdf(self, iset, fname)
Save calculated or fitted PDF to file.
source code
 
save_pdf_string(self, iset)
Save calculated or fitted PDF to string.
source code
 
save_dif(self, iset, fname)
Save data and fitted PDF difference to file.
source code
 
save_dif_string(self, iset)
Save data and fitted PDF difference to string.
source code
 
save_res(self, fname)
Save fit-specific data to file.
source code
 
save_res_string(self)
save_res_string() --> Save fit-specific data to a string.
source code
 
save_struct(self, ip, fname)
Save structure resulting from fit to file.
source code
 
save_struct_string(self, ip)
Save structure resulting from fit to string.
source code
 
show_struct(self, ip)
Print structure resulting from fit.
source code
 
constrain(self, var, par, fcon=None)
Constrain a variable to a parameter.
source code
 
setpar(self, idx, val)
Set value of constrained parameter.
source code
 
getpar(self, idx)
Get value of parameter.
source code
 
fixpar(self, idx)
Fix a parameter.
source code
 
freepar(self, idx)
Free a parameter.
source code
 
setvar(self, var, val)
Set the value of a variable.
source code
 
getvar(self, var)
Get stored value of a variable.
source code
 
getrw(self)
Get goodness of fit value, rw.
source code
 
getR(self)
Get r-points used in the fit.
source code
 
getpdf_fit(self)
Get fitted PDF.
source code
 
getpdf_obs(self)
Get observed PDF.
source code
 
get_atoms(self)
Get atoms in the structure.
source code
 
setphase(self, ip)
Switch to phase ip.
source code
 
setdata(self, iset)
Set specified dataset in focus.
source code
 
psel(self, ip)
Associate the current data set with phase ip.
source code
 
pdesel(self, ip)
Unassociate the current data set with phase ip.
source code
 
isel(self, ip, i)
Select atoms for calculating partial PDF...
source code
 
idesel(self, ip, i)
Deselect atoms for calculating partial PDF...
source code
 
jsel(self, ip, i)
Select atoms for calculating partial PDF...
source code
 
jdesel(self, ip, i)
Deselect atoms for calculating partial PDF...
source code
 
bang(self, ia, ja, ka)
bang(ia, ja, ka) --> Get the bond angle defined by atoms ia, ja, ka.
source code
 
blen(self, *args)
blen(ia, ja) --> Get bond between atoms ia and ja.
source code
 
show_scat(self, stype)
Print scattering length for all atoms.
source code
 
show_scat_string(self, stype)
Get string with scattering length for all atoms.
source code
 
get_scat(self, *args)
Return scattering factor of given element.
source code
 
set_scat(self, *args)
set_scat() --> Change neutron or x-ray scattering factor for given element.
source code
 
reset_scat(self, *args)
reset_scat() --> reset scattering factor.
source code
 
num_atoms(self)
Get number of atoms in current phase.
source code
Static Methods [hide private]
 
lat(n)
lat(n) --> Get reference to lattice variable n.
source code
 
x(i)
x(i) --> Get reference to x-value of atom i.
source code
 
y(i)
y(i) --> Get reference to y-value of atom i.
source code
 
z(i)
z(i) --> Get reference to z-value of atom i.
source code
 
u11(i)
u11(i) --> Get reference to U(1,1) for atom i.
source code
 
u22(i)
u22(i) --> Get reference to U(2,2) for atom i.
source code
 
u33(i)
u33(i) --> Get reference to U(3,3) for atom i.
source code
 
u12(i)
u12(i) --> Get reference to U(1,2) for atom i.
source code
 
u13(i)
u13(i) --> Get reference to U(1,3) for atom i.
source code
 
u23(i)
u23(i) --> Get reference to U(2,3) for atom i.
source code
 
occ(i)
occ(i) --> Get reference to occupancy of atom i.
source code
 
pscale()
pscale() --> Get reference to pscale.
source code
 
pfrac()
pfrac() --> Deprecated reference to pscale.
source code
 
spdiameter()
spdiameter() --> Get reference to spdiameter.
source code
 
stepcut()
stepcut() --> Get reference to stepcut.
source code
 
sratio()
sratio() --> Get reference to sigma ratio.
source code
 
srat()
srat() --> Deprecated reference to sigma ratio.
source code
 
delta1()
delta1() --> Get reference to linear sharpening factor 1/R peak sharpening factor.
source code
 
delta2()
delta2() --> Get reference to delta2 The phenomenological correlation constant in the Debye-Waller factor.
source code
 
delta()
delta() --> deprecated, same as delta2().
source code
 
gamma()
gamma() --> deprecated, same as delta1().
source code
 
dscale()
dscale() --> Get reference to dscale.
source code
 
qsig()
qsig() --> Deprecated reference to qdamp.
source code
 
qdamp()
qdamp() --> Get reference to qdamp.
source code
 
qalp()
qalp() --> Deprecated reference to qbroad.
source code
 
qbroad()
qbroad() --> Get reference to qbroad.
source code
 
rcut()
rcut() --> Get reference to rcut.
source code
Class Variables [hide private]
  _atomselect = {'ALL': -1}
  _FCON = {'FCOMP': 2, 'FSQR': 3, 'IDENT': 1}
  _Sctp = {'N': 1, 'X': 0}
  _dataset_vars = ('qdamp', 'qbroad', 'dscale')
Method Details [hide private]

allfits(self)

source code 
Get resulting list of Fitting and Calculations
        

sandbox(self)

source code 
Create sandbox dictionary suitable for script evaluation

returns sandbox dictionary

loadscript(self, scriptfile)

source code 
Execute scriptfile in this sandbox.  Before it is executed, change
to script directory and shadow pdffit and pdffit2 modules

scriptfile  --  path to the script to be loaded

read_struct(self, filename)

source code 
Read structure from file into memory.

filename  -- name of file from which to read structure

Raises:
    pdffit2.calculationError when a lattice cannot be created from the
    given structure
    pdffit2.structureError when a structure file is malformed
    IOError when the file cannot be read from the disk

read_struct_string(self, s, name='')

source code 
Read structure from a string into memory.

s    -- string containing the contents of the structure file
name -- tag with which to label structure

Raises:
    pdffit2.calculationError when a lattice cannot be created from the
    given structure
    pdffit2.structureError when a structure file is malformed

read_data(self, filename, stype, qmax, qdamp)

source code 
Read pdf data from file into memory.

filename -- name of file from which to read data
stype    -- 'X' (xray) or 'N' (neutron)
qmax     -- maximum q value
qdamp    -- instrumental q-resolution factor

Raises:
    IOError when the file cannot be read from disk

read_data_string(self, s, stype, qmax, qdamp, name='')

source code 
Read pdf data from a string into memory.

s       -- string containing the contents of the data file
stype   -- 'X' (xray) or 'N' (neutron)
qmax    -- maximum q value
qdamp   -- instrumental q-resolution factor
name    -- tag with which to label data

read_data_lists(self, stype, qmax, qdamp, r_data, Gr_data, dGr_data=None, name='list')

source code 
Read pdf data into memory from lists.

All lists must be of the same length.
stype       -- 'X' (xray) or 'N' (neutron)
qmax        -- maximum q value
qdamp       -- instrumental q-resolution factor
r_data      -- list of r-values
Gr_data     -- list of G(r) values
dGr_data    -- list of G(r) uncertainty values
name        -- tag with which to label data

Raises:
    NotImplementedError

pdfrange(self, iset, rmin, rmax)

source code 
Set the range of the fit in specified dataset.

iset    -- data set to consider, indexed from 1 or 'ALL'
rmin    -- minimum r-value of fit
rmax    -- maximum r-value of fit

alloc(self, stype, qmax, qdamp, rmin, rmax, rlen)

source code 
Allocate space for a PDF calculation.

The structure from which to calculate the PDF must first be imported with
the read_struct() or read_struct_string() method.
stype   -- 'X' (xray) or 'N' (neutron)
qmax    -- maximum q value
qdamp   -- instrumental q-resolution factor
rmin    -- minimum r-value of calculation
rmax    -- maximum r-value of calculation
rlen    -- number of data points in calculation

calc(self)

source code 
Calculate the PDF of the imported structure.

Space for the calculation must first be allocated with the alloc()
method.

Raises:
    ControlRuntimeError when space for calculation has not been
    allocated

refine(self, toler=1e-08)

source code 
Fit the theory to the imported data.

toler   --  tolerance of the fit, ignored for now

refine_step(self, toler=1e-08)

source code 
Run a single step of the fit.

toler   --  tolerance of the fit

Raises:
    NotImplementedError - I am not importing such beast

save_pdf(self, iset, fname)

source code 
Save calculated or fitted PDF to file.  Ignored.
        

save_pdf_string(self, iset)

source code 
Save calculated or fitted PDF to string.

iset    -- data set to save, indexed from 1

Raises:
    NotImplementedError - we cannot return anything without engine.

save_dif(self, iset, fname)

source code 
Save data and fitted PDF difference to file.  Ignored.

iset    -- data set to save
fname   -- file to write to

save_dif_string(self, iset)

source code 
Save data and fitted PDF difference to string.

iset    -- data set to save

Raises:
    NotImplementedError - we cannot return anything without engine.

save_res(self, fname)

source code 
Save fit-specific data to file.  Ignored.
        

save_res_string(self)

source code 
save_res_string() --> Save fit-specific data to a string.

Raises:
    NotImplementedError - we cannot return anything without engine.

save_struct(self, ip, fname)

source code 
Save structure resulting from fit to file.  Ignored.

ip    -- phase to save

save_struct_string(self, ip)

source code 
Save structure resulting from fit to string.

ip    -- phase to save

Raises:
    NotImplementedError - we cannot return anything without engine.

show_struct(self, ip)

source code 
Print structure resulting from fit.  Ignored.

ip    -- phase to display

constrain(self, var, par, fcon=None)

source code 
Constrain a variable to a parameter.

A variable can be constrained to a number or equation string.
var     -- variable to constrain, such as x(1)
par     -- parameter which to constrain the variable. This can be
           an integer or an equation string containing a reference
           to another parameter. Equation strings use standard c++
           syntax. The value of a constrained parameter is accessed
           as @p in an equation string, where p is the parameter.
           e.g.
           >>>  constrain(x(1), 1)
           >>>  constrain(x(2), "0.5+@1")
fcon    -- 'IDENT', 'FCOMP', or 'FSQR', old-style constraint formulas:
               'IDENT'  @par
               'FCOMP'  1.0-@par
               'FSQR'   @par*@par

setpar(self, idx, val)

source code 
Set value of constrained parameter.

idx     --  parameter index
val     --  Either a numerical value or a reference to variable

Raises:
    KeyError when parameter is yet to be constrained

getpar(self, idx)

source code 
Get value of parameter.

idx     --  parameter index

Raises:
    KeyError if parameter does not exists

fixpar(self, idx)

source code 
Fix a parameter.

idx     --  parameter index

Fixed parameters are not fitted in a refinement. Passed parameter can be
'ALL', in which case all parameters are fixed.

Raises:
    ControlKeyError if parameter does not exists

freepar(self, idx)

source code 
Free a parameter.

idx     --  parameter index

Freed parameters are fitted in a refinement. Passed parameter can be
ALL, in which case all parameters are freed.

Raises:
    ControlKeyError if parameter does not exists

setvar(self, var, val)

source code 
Set the value of a variable.

Raises:
    ControlKeyError if variable does not yet exist

getvar(self, var)

source code 
Get stored value of a variable.

Raises:
    ControlKeyError if variable index does not exist

returns value of variable var.

getrw(self)

source code 
Get goodness of fit value, rw.
Raises:
    NotImplementedError - we cannot return anything without engine.

getR(self)

source code 
Get r-points used in the fit.

This function should only be called after data has been loaded or
calculated. Before a refinement, the list of r-points will reflect the
data. Afterwords, they will reflect the fit range.

Raises:
    NotImplementedError - we cannot return anything without engine.

getpdf_fit(self)

source code 
Get fitted PDF.

This function should only be called after a refinement or refinement
step has been done.

Raises:
    NotImplementedError - we cannot return anything without engine.

getpdf_obs(self)

source code 
Get observed PDF.

This function should only be called after data has been loaded or
calculated. Before a refinement, the list of r-points will reflect the
data. Afterwords, they will reflect the fit range.

Raises:
    NotImplementedError - we cannot return anything without engine.

get_atoms(self)

source code 
Get atoms in the structure.

This function should only be called after a structure has been loaded.

Raises:
    NotImplementedError - we cannot return anything without engine.

setphase(self, ip)

source code 
Switch to phase ip.

ip  --  phase index starting from 1

All parameters assigned after this method is called refer only to the
current phase.

Raises:
    IndexError if phase ip does not exist

setdata(self, iset)

source code 
Set specified dataset in focus.

iset  --  dataset index starting from 1

Raises:
    IndexError if dataset iset does not exist

psel(self, ip)

source code 
Associate the current data set with phase ip.

ip -- phase index starting from 1

Raises:
    NotImplementedError

pdesel(self, ip)

source code 
Unassociate the current data set with phase ip.

ip -- phase index starting from 1

Raises:
    NotImplementedError

isel(self, ip, i)

source code 
Select atoms for calculating partial PDF

ip  --  phase index starting from 1, if set to 'ALL' isel applies
        to all phases
i  --   atom index starting from 1, if set to 'ALL', select all atoms

Raises: 
    NotImplementedError

idesel(self, ip, i)

source code 
Deselect atoms for calculating partial PDF

ip  --  phase index starting from 1, if set to 'ALL' isel applies
        to all phases
i  --   atom index starting from 1, if set to 'ALL', select all atoms

Raises: 
    NotImplementedError

jsel(self, ip, i)

source code 
Select atoms for calculating partial PDF

ip  --  phase index starting from 1, if set to 'ALL' jsel applies
        to all phases
i  --   atom index starting from 1, if set to 'ALL', select all atoms

Raises: 
    NotImplementedError

jdesel(self, ip, i)

source code 
Deselect atoms for calculating partial PDF

ip  --  phase index starting from 1, if set to 'ALL' jsel applies
        to all phases
i  --   atom index starting from 1, if set to 'ALL', select all atoms

Raises: 
    NotImplementedError

bang(self, ia, ja, ka)

source code 
bang(ia, ja, ka) --> Get the bond angle defined by atoms ia, ja, ka.

Raises:
    NotImplementedError

blen(self, *args)

source code 
blen(ia, ja) --> Get bond between atoms ia and ja.  Ignored.

blen(a1, a2, lb, ub) --> Print length of all a1-a2 bonds in range
[lb,ub], where a1 and a2 are integers representing atom types. 1
represent the first type of atom in the phase, 2 represents the second
type of atom in the structure, an so on. Either a1 or a2 can be the
keyword ALL, in which all atom types are used for that end of the
calculated bonds.

show_scat(self, stype)

source code 
Print scattering length for all atoms.  Ignored.

stype -- 'X' (xray) or 'N' (neutron).

show_scat_string(self, stype)

source code 
Get string with scattering length for all atoms.

stype -- 'X' (xray) or 'N' (neutron).

Raises:
    NotImplementedError

get_scat(self, *args)

source code 
Return scattering factor of given element.
Not supported.

Raises: 
    NotImplementedError

set_scat(self, *args)

source code 
set_scat() --> Change neutron or x-ray scattering factor for given
element.  Not supported.

Raises: 
    NotImplementedError

reset_scat(self, *args)

source code 
reset_scat() --> reset scattering factor.  Not supported.

Raises: 
    NotImplementedError

num_atoms(self)

source code 
Get number of atoms in current phase.

Raises:
    ControlKeyError if phase does not exists

lat(n)
Static Method

source code 
lat(n) --> Get reference to lattice variable n.

n can be an integer or a string representing the lattice variable.
1 <==> 'a'
2 <==> 'b'
3 <==> 'c'
4 <==> 'alpha'
5 <==> 'beta'
6 <==> 'gamma'

u11(i)
Static Method

source code 
u11(i) --> Get reference to U(1,1) for atom i.

U is the anisotropic thermal factor tensor.

u22(i)
Static Method

source code 
u22(i) --> Get reference to U(2,2) for atom i.

U is the anisotropic thermal factor tensor.

u33(i)
Static Method

source code 
u33(i) --> Get reference to U(3,3) for atom i.

U is the anisotropic thermal factor tensor.

u12(i)
Static Method

source code 
u12(i) --> Get reference to U(1,2) for atom i.

U is the anisotropic thermal factor tensor.

u13(i)
Static Method

source code 
u13(i) --> Get reference to U(1,3) for atom i.

U is the anisotropic thermal factor tensor.

u23(i)
Static Method

source code 
u23(i) --> Get reference to U(2,3) for atom i.

U is the anisotropic thermal factor tensor.

pscale()
Static Method

source code 
pscale() --> Get reference to pscale.

pscale is the fraction of the total structure that the current phase
represents.

pfrac()
Static Method

source code 
pfrac() --> Deprecated reference to pscale.

pscale is the fraction of the total structure that the current phase
represents.

spdiameter()
Static Method

source code 
spdiameter() --> Get reference to spdiameter.

Diameter value for the spherical particle PDF correction. 
Spherical envelope is not applied when spdiameter equals 0.

stepcut()
Static Method

source code 
stepcut() --> Get reference to stepcut.

stepcut is cutoff radius for empirical step-function PDF envelope.
Step cutoff is not applied when stepcut equals 0.
Non-refineable variable.  

sratio()
Static Method

source code 
sratio() --> Get reference to sigma ratio.

The sigma ratio determines the reduction in the Debye-Waller factor for
distances below rcut.

srat()
Static Method

source code 
srat() --> Deprecated reference to sigma ratio.

The sigma ratio determines the reduction in the Debye-Waller factor for
distances below rcut.

delta2()
Static Method

source code 
delta2() --> Get reference to delta2

The phenomenological correlation constant in the Debye-Waller factor.
The (1/R^2) peak sharpening factor.

dscale()
Static Method

source code 
dscale() --> Get reference to dscale.

The data scale factor.

qsig()
Static Method

source code 
qsig() --> Deprecated reference to qdamp.

instrument q-resolution factor.

qdamp()
Static Method

source code 
qdamp() --> Get reference to qdamp.

instrument q-resolution factor.

qalp()
Static Method

source code 
qalp() --> Deprecated reference to qbroad.

Quadratic peak sharpening factor.

qbroad()
Static Method

source code 
qbroad() --> Get reference to qbroad.

Quadratic peak sharpening factor.

rcut()
Static Method

source code 
rcut() --> Get reference to rcut.

rcut is the value of r below which peak sharpening, defined by the sigma
ratio (sratio), applies.