Package diffpy :: Package srrietveld :: Module refinement :: Class Refinement
[frames] | no frames]

Class Refinement

source code

                       object --+            
                                |            
refinementdata.hdf5.object.Object --+        
                                    |        
   refinementdata.refinable.Refinable --+    
                                        |    
     refinementdata.refinement.Refinement --+
                                            |
                                           Refinement

The refinement (fit) class for SrRietveld. A refinement object contains information for a series of single refinement. It contains the subobjects such as the Pattern, Profile, and Contribution.

Instance Methods
 
__init__(self, owner, name=None, handle=None, shape=None)
constructor
source code
 
addParamToStrategy(self, datapath, step=None)
Add a parameter to strategy.
source code
 
dumpDataFile(self, directory, index, bankid=0)
Dump the datafile for refinement in index
source code
 
dumpEngineFile(self, directory, index, basename=None)
dump the engine file to the directory
source code
 
dumpFileFromDataset(self, directory, ds, index, basename=None)
dump the files in pattern objects, such as Datafile, MFIL, and Instrumentfile
source code
 
dumpFiles(self, directory, index)
Dump the files for refinement, including all the files needed to run the refinement (datafile, instrument file, incident spectrum file, engine file)
source code
 
dumpIncidentSpectrumFile(self, directory, index=0, bankid=0)
Dump the incident spectrum file (MFIL, only in EXP files for GSAS)
source code
 
dumpInstrumentFile(self, directory, index=0, bankid=0)
Dump the instrument file into a folder.
source code
 
findFileFromDataset(self, ds, index)
Try to find the file from the information in the dataset
source code
 
getChi2(self)
Get the chi square values of the refinement
source code
 
getDataFileFromPattern(self, index, bankid=0, rootname=None)
Get a data file object from the numpy array saved in Pattern
source code
 
getEngineFileExt(self)
get the extension name of the engine file for this fit
source code
 
getEngineType(self)
Get the engine type for this refinement
source code
 
getInvolvedDatapaths(self, step=None)
Get the refined parameters.
source code
 
getName(self)
Get the name of the refinement
source code
 
getNumOfCycles(self)
Get the number of cycles of the refinement
source code
 
getNumOfPatterns(self)
Get the number of patterns in the refinement
source code
 
getNumOfPhases(self)
Get number of phases in the refinement
source code
 
getOneStepStrategy(self, type='Rietveld')
Combine the strategy steps into one step, so the refinement can run this strategy step and skep running through the steps
source code
 
getParamListForStrategy(self, datapath)
Handling different mechanisms for different engines.
source code
 
getPhaseByName(self, name)
Get the phase object by its name
source code
 
isParamTurnedOn(self, datapath, step=None)
check if the dataset is included in the strategy
source code
 
listEnvParamNames(self)
List the environment parameter names on which the refinements are organized.
source code
 
listEnvParams(self)
List the environment parameter objects on which the refinements are organized.
source code
 
listPatterns(self)
List the Pattern objects in the refinement
source code
 
listPhaseNames(self)
Return a list of phase names in the refinement
source code
 
listPhases(self)
List the Phase objects in the refinement
source code
 
listProfiles(self)
Get a list of Profile objects in the refinement
source code
 
loadDataFile(self, datafile, index=0, bankid=0)
load the data file to the project
source code
 
loadIncidentSpectrumFile(self, mfil, index=0, bankid=0)
Load the incident spectrum file path into the object
source code
 
loadInstrumentFile(self, instrumentfile, index=0, bankid=0)
load the instrument file path to the pattern instrumentfile - the abs path to the instrument file
source code
 
loadStrategyFile(self, fullpath)
load the strategy from a text file
source code
 
removeParamFromStrategy(self, datapath, step=None)
remove parameter from the strategy
source code
 
saveEngineFile(self, enginefile, index=0)
Save the engine file content to the datasets
source code
 
saveFilePathToDataset(self, absPath, ds, index=0, basepath=None)
Save the absolute file path to the dataset
source code
 
setStrategy(self, strategylist)
Set the strategy to refinement object
source code
 
writeStrateyFile(self, fullpath)
write the strategy to a local file
source code

Inherited from refinementdata.refinement.Refinement: addPattern, addStructure, checkStatus, getStatus, isFinished, isRunning, isSubmitted, loadLocalData, removePattern, removeStructure, resetStatus, setStatus

Inherited from refinementdata.refinable.Refinable: addHistory, addHistoryByPath, addSigma, addSigmaByPath, findRefinement, getHistory, getHistoryByPath, getSigma, getSigmaByPath, listHistories, listRefined, loadLocalObjects, removeHistory, update

Inherited from refinementdata.hdf5.object.Object: addObject, copy, copyMeta, delete, exportFile, get, getAttr, getByPath, getFlatIndex, getMetaData, getMultiDimIndex, getObject, getPyObj, hasAttr, hasMeta, importFile, isDescendant, list, listAttrs, listNames, listObjects, load, loadObject, move, range, readStr, removeObject, rename, repeat, replicate, reshape, save, set, setAttr, setByPath, setLabels, setPyObj, unset, unsetAttr, writeStr

Inherited from object: __delattr__, __format__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __sizeof__, __str__, __subclasshook__

Class Variables

Inherited from refinementdata.refinement.Refinement: ERROR, FINISHED, NORMAL, RUNNING, SUBMITTED

Properties
  numStrategySteps
Get the number of strategy steps
  strategy
Get the strategy list from the fit object

Inherited from refinementdata.hdf5.object.Object: labels, name, ndim, path

Inherited from object: __class__

Method Details

__init__(self, owner, name=None, handle=None, shape=None)
(Constructor)

source code 

constructor

Overrides: object.__init__

addParamToStrategy(self, datapath, step=None)

source code 

Add a parameter to strategy. The included parameters will be turned on in the refinement.

Parameters:
  • datapath (string) - the dataset signature path to be added to the strategy
  • step (integer) - the step of the strategy to which the parameter will be added
    • None, the parameter will be added to all steps
    • step >= total number of existing steps, a new step will be added to the strategy list. The new step includes the new parameter, and all previously included parameters
    • 0 <= step < total number of existing steps, the new parameter will be added to the step
Returns:
no return value

dumpDataFile(self, directory, index, bankid=0)

source code 

Dump the datafile for refinement in index

Parameters:
  • directory (directory path string) - the directory where the data files will be saved
  • index (integer or tuple) - the index of the single refinement
  • bankid (integer) - the bank id of the pattern to look for
Returns:
the list of data file path saved, listed same as the bank number if the file is not found or not set, the item is None

dumpEngineFile(self, directory, index, basename=None)

source code 

dump the engine file to the directory

Parameters:
  • directory (directory path string) - the directory where the file will be saved
  • index (integer or tuple) - the data index of the engine file
  • basename (string) - the file name of the engine file
Returns:
the path of the engine file

dumpFileFromDataset(self, directory, ds, index, basename=None)

source code 

dump the files in pattern objects, such as Datafile, MFIL, and Instrumentfile

Parameters:
  • ds (a Dataset object) - the dataset stores the file path information
  • basename (string) - if defined, will be used as the file name @return - the paths of the dumped new file
  • directory (directory path string @param directory - the directory where the file will be saved)
  • index (integer or tuple @param index - the index in the dataset)

dumpFiles(self, directory, index)

source code 

Dump the files for refinement, including all the files needed to run the refinement (datafile, instrument file, incident spectrum file, engine file)

Parameters:
  • directory (directory path string) - the directory where the files will be saved
  • index (integer or tuple) - the index of the refinement to dump
Returns:
no return value

dumpIncidentSpectrumFile(self, directory, index=0, bankid=0)

source code 

Dump the incident spectrum file (MFIL, only in EXP files for GSAS)

Parameters:
  • directory (directory path string) - the directory where the file will be saved
  • index (integer or tuple) - the index of the dataset
  • bankid (integer) - the bank id of the pattern to look for
Returns:
the new path of the saved file

dumpInstrumentFile(self, directory, index=0, bankid=0)

source code 

Dump the instrument file into a folder. Usually the instrument files are the same for all data set.

Parameters:
  • directory (directory path string) - the directory where the file will be moved to
  • index (integer or tuple) - the index of the dataset, default to be the first in the list
  • bankid (integer) - the bank id of the pattern to look for
Returns:
the new path of the instrument file

findFileFromDataset(self, ds, index)

source code 

Try to find the file from the information in the dataset

Parameters:
  • ds (a Dataset object) - the dataset which stores the file path information
  • index (integer or tuple) - the index in the dataset
Returns:
the file absolute path if the file is found, None otherwise

getChi2(self)

source code 

Get the chi square values of the refinement

Returns:
the chi square values of the refinement

getDataFileFromPattern(self, index, bankid=0, rootname=None)

source code 

Get a data file object from the numpy array saved in Pattern

Parameters:
  • index (integer or tuple) - the index of the single refinement
  • bankid (integer) - the bank id of the pattern to look for
  • rootname (string) - the rootname of the data file, which is the file name without the extension
Returns:
a Datafile object

getEngineFileExt(self)

source code 

get the extension name of the engine file for this fit

Returns:
string of file extension, for example "EXP" or "pcr"

getEngineType(self)

source code 

Get the engine type for this refinement

Returns:
the string of the engine type, for example "gsas" or "fullprof"

getInvolvedDatapaths(self, step=None)

source code 

Get the refined parameters. The datasets ever included in the strategy list will be listed. The order of the datasets when they turned on is ignored

Parameters:
  • step (integer) - the strategy step, if step is a valid integer, then get the datasets in that step; if none, get all the datasets in all steps
Returns:
the a list of Dataset objects

getName(self)

source code 

Get the name of the refinement

Returns:
the refinement name

getNumOfCycles(self)

source code 

Get the number of cycles of the refinement

Returns:
the chi square values of the refinement

getNumOfPatterns(self)

source code 

Get the number of patterns in the refinement

Returns:
number of patterns

getNumOfPhases(self)

source code 

Get number of phases in the refinement

Returns:
number of phases

getOneStepStrategy(self, type='Rietveld')

source code 

Combine the strategy steps into one step, so the refinement can run this strategy step and skep running through the steps

Parameters:
  • type (string) - the type of the refinement, default to be Rietveld. Possible value can be "Rietveld" or "LeBail"
Returns:
the one step strategy list

getParamListForStrategy(self, datapath)

source code 

Handling different mechanisms for different engines. For example, for gsas, some parameters such as all background parameters have to be added or removed all together. Also the lattice parameters have to be combined in GSAS as well.

Parameters:
  • datapath (string) - the data path, which denotes the ownership tree of a dataset. It reads as Pattern[0].Back[0], Phase[0].Atom[1].x, or Phase[0].a
Returns:
a list of paths of the parameter data object that should be combined with the passed in datapath

getPhaseByName(self, name)

source code 

Get the phase object by its name

Parameters:
  • name (string) - the phase name to obtain
Returns:
the phase object with the name if exists. None if no such phase object. The program will emit a warning if duplicate phase names exist, and the first phase obj with the same name will be returned

isParamTurnedOn(self, datapath, step=None)

source code 

check if the dataset is included in the strategy

Parameters:
  • datapath (string) - the signature path string of the data. For ordinary data, just dataset.path for data with extra index, its dataset.path + '[%i]' % extraindex
  • step (integer) - the strategy step to be investigate. If None, return True if the dataset is included in any step
Returns:
True if the dataset is included, False otherwise

listEnvParamNames(self)

source code 

List the environment parameter names on which the refinements are organized. For example, the temperature or pressure series

Returns:
the environment parameter names

listEnvParams(self)

source code 

List the environment parameter objects on which the refinements are organized. For example, the temperature or pressure series

Returns:
a list of environment parameter objects

listPatterns(self)

source code 

List the Pattern objects in the refinement

Returns:
a list of patterns

listPhaseNames(self)

source code 

Return a list of phase names in the refinement

Returns:
a list of phase names

listPhases(self)

source code 

List the Phase objects in the refinement

Returns:
a list of phases

listProfiles(self)

source code 

Get a list of Profile objects in the refinement

Returns:
a list of Profile objects

loadDataFile(self, datafile, index=0, bankid=0)

source code 

load the data file to the project

Parameters:
  • datafile (file path string) - the data file absolute path
  • index (integer or tuple) - the index of the single refinement
  • bankid (integer) - the bank id of the pattern, default to be 0
Returns:
no return value

loadIncidentSpectrumFile(self, mfil, index=0, bankid=0)

source code 

Load the incident spectrum file path into the object

Parameters:
  • mfil (file path string) - the abs path of the incident spectrum file MFIL
  • index (the index of the single refinement) - integer or tuple
  • bankid (integers) - the bank id of the pattern
Returns:
no return value

loadInstrumentFile(self, instrumentfile, index=0, bankid=0)

source code 

load the instrument file path to the pattern instrumentfile - the abs path to the instrument file

Parameters:
  • index (integer or tuple) - the index of the single refinement
  • bankid (integer or tuple) - the bankid of the pattern
Returns:
no return value

loadStrategyFile(self, fullpath)

source code 

load the strategy from a text file

Parameters:
  • fullpath (file path string) - the stratey file path
Returns:
no return value

removeParamFromStrategy(self, datapath, step=None)

source code 

remove parameter from the strategy

Parameters:
  • datapath (string) - the data signature path to be removed from the strategy
  • step (integer) - the strategy step.
    • None, will remove the strategy from all steps
    • 0 <= step < total number of existing steps, the new parameter will be removed from the step
Returns:
no return value

saveEngineFile(self, enginefile, index=0)

source code 

Save the engine file content to the datasets

Parameters:
  • enginefile (filepath string) - the engine file path
  • index (integer or tuple) - the index of the single refinement
Returns:
no return value

saveFilePathToDataset(self, absPath, ds, index=0, basepath=None)

source code 

Save the absolute file path to the dataset

Parameters:
  • ds (Dataset object) - the dataset to store the file path information
  • index (integer or tuple) - the index of the dataset
  • absPath (file path string) - the absolute path of the data file
  • basepath (directory path string) - the basepath used to determine the relative path, the project.basepath will be used if basepath None
Returns:
no return value

setStrategy(self, strategylist)

source code 

Set the strategy to refinement object

Parameters:
  • strategylist (list) - a list with strategy steps
Returns:
no return value

writeStrateyFile(self, fullpath)

source code 

write the strategy to a local file

Parameters:
  • fullpath (file path string) - the file path to write to
Returns:
no return value

Property Details

numStrategySteps

Get the number of strategy steps

Get Method:
unreachable.numStrategySteps(self) - Get the number of strategy steps

strategy

Get the strategy list from the fit object

Get Method:
unreachable.strategy(self) - Get the strategy list from the fit object