Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Namespace Members | Class Members | File Members | Related Pages

ObjCryst::PowderPattern Class Reference

Powder pattern class, with an observed pattern and several calculated components to modelize the pattern. More...

Inheritance diagram for ObjCryst::PowderPattern:

Inheritance graph
[legend]
Collaboration diagram for ObjCryst::PowderPattern:

Collaboration graph
[legend]
List of all members.

Public Member Functions

 PowderPattern ()
 PowderPattern (const PowderPattern &)
 ~PowderPattern ()
virtual const string & GetClassName () const
 Name for this class ("RefinableObj", "Crystal",...).

void AddPowderPatternComponent (PowderPatternComponent &)
 Add a component (phase, backround) to this pattern.

unsigned int GetNbPowderPatternComponent () const
 Number of components.

const PowderPatternComponentGetPowderPatternComponent (const string &name) const
 Access to a component of the powder pattern.

const PowderPatternComponentGetPowderPatternComponent (const int) const
 Access to a component of the powder pattern.

PowderPatternComponentGetPowderPatternComponent (const string &name)
 Access to a component of the powder pattern.

PowderPatternComponentGetPowderPatternComponent (const int)
 Access to a component of the powder pattern.

void SetPowderPatternPar (const REAL min, const REAL step, unsigned long nbPoint)
 the powder pattern angular range & resolution parameter.

void SetPowderPatternX (const CrystVector_REAL &x)
 Set the x coordinate of the powder pattern : either the 2theta or time-of-flight values for each recorded point.

unsigned long GetNbPoint () const
 Number of points ?

unsigned long GetNbPointUsed () const
 Number of points actually calculated (below the chosen max(sin(theta)/lambda)) ?

void SetRadiation (const Radiation &radiation)
 Set the radiation.

const RadiationGetRadiation () const
 Neutron or x-ray experiment ?

RadiationGetRadiation ()
 Neutron or x-ray experiment ?

void SetRadiationType (const RadiationType radiation)
 Set the radiation type.

RadiationType GetRadiationType () const
 Neutron or x-ray experiment ?

void SetWavelength (const REAL lambda)
 Set the wavelength of the experiment (in Angstroems).

void SetWavelength (const string &XRayTubeElementName, const REAL alpha12ratio=0.5)
 Set the wavelength of the experiment to that of an X-Ray tube.

void SetEnergy (const REAL energy)
 Set the energy of the experiment [in keV, lambda(A)=12398/E(keV)].

REAL GetWavelength () const
 wavelength of the experiment (in Angstroems)

const CrystVector_REAL & GetPowderPatternCalc () const
 Get the calculated powder pattern.

const CrystVector_REAL & GetPowderPatternObs () const
 Get the observed powder pattern.

const CrystVector_REAL & GetPowderPatternObsSigma () const
 Get the sigma for each point of the observed powder pattern.

const CrystVector_REAL & GetPowderPatternVariance () const
 Get the variance (obs+model) for each point of the powder pattern.

const CrystVector_REAL & GetPowderPatternWeight () const
 Get the weight for each point of the powder pattern.

REAL GetPowderPatternXMin () const
 Get the Minimum 2theta.

REAL GetPowderPatternXStep () const
 Get the average step in 2theta.

REAL GetPowderPatternXMax () const
 Get the maximum 2theta.

const CrystVector_REAL & GetPowderPatternX () const
 Get the vector of X (2theta or time-of-flight) coordinates.

const CrystVector_REAL & GetChi2Cumul () const
 Get the powder pattern cumulative Chi^2.

const RefinableObjClockGetClockPowderPatternCalc () const
 Last time the pattern was calculated.

const RefinableObjClockGetClockPowderPatternPar () const
 When were the pattern parameters (2theta range, step) changed ?

const RefinableObjClockGetClockPowderPatternRadiation () const
 When were the radiation parameter (radiation type, wavelength) changed ?

const RefinableObjClockGetClockPowderPatternXCorr () const
 When were the parameters for 2theta/TOF correction (zero, transparency, displacement) last changed ?

void SetXZero (const REAL newZero)
 Change Zero in x (2theta,tof).

void Set2ThetaDisplacement (const REAL displacement)
 Change displacement correction $ (2\theta)_{obs} = (2\theta)_{real} + \frac{a}{\cos(\theta)} $.

void Set2ThetaTransparency (const REAL transparency)
 Change transparency correction $ (2\theta)_{obs} = (2\theta)_{real} + b\sin(2\theta) $.

void ImportPowderPatternFullprof (const string &fullprofFileName)
 Import fullprof-style diffraction data.

void ImportPowderPatternPSI_DMC (const string &filename)
 Import powder pattern, format DMC from PSI.

void ImportPowderPatternILL_D1A5 (const string &filename)
 Import powder pattern, format from ILL D1A/D2B (format without counter info).

void ImportPowderPatternXdd (const string &fileName)
 Import *.xdd diffraction data (Topas,...).

void ImportPowderPatternSietronicsCPI (const string &fileName)
 Import *.cpi Sietronics diffraction data.

void ImportPowderPattern2ThetaObsSigma (const string &fileName, const int nbSkip=0)
 Import file with 3 columns 2Theta Iobs Sigma.

void ImportPowderPatternFullprof4 (const string &fileName)
 Import diffraction data from a file, with the first line has 2ThetaMin, step, 2thetaMax, and the following lines alternate 10 Iobs and 10 sigma. Ends with null entries (to fill last Iobs line to reach last sigme line).

void ImportPowderPatternMultiDetectorLLBG42 (const string &fileName)
 diffraction data in a multi-detector format (fullprof format #6).

void ImportPowderPattern2ThetaObs (const string &fileName, const int nbSkip=0)
 Import file with 2 columns 2Theta Iobs.

void ImportPowderPatternTOF_ISIS_XYSigma (const string &fileName)
 Import TOF file (ISIS type, 3 columns t, Iobs, sigma(Iobs)).

void ImportPowderPatternGSAS (const string &fileName)
 Import GSAS standard powder pattern data (see GSAS manual).

void ImportPowderPatternCIF (const CIF &cif)
 Import CIF powder pattern data.

void SetPowderPatternObs (const CrystVector_REAL &obs)
 Set observed powder pattern from vector array.

void SavePowderPattern (const string &filename="powderPattern.out") const
 Save powder pattern to one file, text format, 3 columns theta Iobs Icalc.

void PrintObsCalcData (ostream &os=cout) const
 Print to thee screen/console the observed and calculated pattern (long, mostly useful for debugging).

REAL GetR () const
 Unweighted R-factor.

REAL GetIntegratedR () const
REAL GetRw () const
 Get the weighted R-factor.

REAL GetIntegratedRw () const
REAL GetChi2 () const
 Return conventionnal Chi^2.

void FitScaleFactorForR () const
 Fit the scale(s) factor of each component to minimize R.

void FitScaleFactorForIntegratedR () const
void FitScaleFactorForRw () const
 Fit the scale(s) factor of each component to minimize Rw.

void FitScaleFactorForIntegratedRw () const
void SetSigmaToSqrtIobs ()
 Set sigma=sqrt(Iobs).

void SetWeightToInvSigmaSq (const REAL minRelatSigma=1e-3)
 Set w = 1/sigma^2.

void SetWeightToUnit ()
 Set w = 1.

void SetWeightPolynomial (const REAL a, const REAL b, const REAL c, const REAL minRelatIobs=1e-3)
 Set w = 1/(a+ Iobs + b*Iobs^2+c*Iobs^3).

void AddExcludedRegion (const REAL min2Theta, const REAL max2theta)
 Add an Exclusion region, in 2theta, which will be ignored when computing R's XMLInput values must be, as always, in radians.

virtual void BeginOptimization (const bool allowApproximations=false, const bool enableRestraints=false)
 This should be called by any optimization class at the begining of an optimization.

virtual void GlobalOptRandomMove (const REAL mutationAmplitude, const RefParType *type=gpRefParTypeObjCryst)
 Make a random move of the current configuration.

virtual REAL GetLogLikelihood () const
 Get -log(likelihood) of the current configuration for the object.

virtual unsigned int GetNbLSQFunction () const
 Number of LSQ functions.

virtual const CrystVector_REAL & GetLSQCalc (const unsigned int) const
 Get the current calculated value for the LSQ function.

virtual const CrystVector_REAL & GetLSQObs (const unsigned int) const
 Get the observed values for the LSQ function.

virtual const CrystVector_REAL & GetLSQWeight (const unsigned int) const
 Get the weight values for the LSQ function.

virtual void XMLOutput (ostream &os, int indent=0) const
 Output to stream in well-formed XML.

virtual void XMLInput (istream &is, const XMLCrystTag &tag)
 Input From stream.

void Prepare ()
 Prepare everything (if necessary) for an optimization/calculation.

virtual void GetGeneGroup (const RefinableObj &obj, CrystVector_uint &groupIndex, unsigned int &firstGroup) const
 Get the gene group assigned to each parameter.

virtual void SetMaxSinThetaOvLambda (const REAL max)
 Set the maximum value for sin(theta)/lambda.

REAL GetMaxSinThetaOvLambda () const
 Get the maximum value for sin(theta)/lambda.

const CrystVector_long & GetIntegratedProfileMin () const
 Get the list of first pixels for the integration intervals.

const CrystVector_long & GetIntegratedProfileMax () const
 Get the list of last pixels for the integration intervals.

const RefinableObjClockGetIntegratedProfileLimitsClock () const
 When were the integration intervals last changed ?

REAL X2XCorr (const REAL x) const
 Get the experimental x (2theta, tof) from the theoretical value, taking into account all corrections (zero, transparency,..).

REAL X2PixelCorr (const REAL x) const
 Get the pixel number on the experimental pattern, from the theoretical (uncorrected) x coordinate, taking into account all corrections.

REAL X2Pixel (const REAL x) const
 Get the pixel number on the experimental pattern, corresponding to a given (experimental) x coordinate.

REAL STOL2X (const REAL stol) const
 Convert sin(theta)/lambda to X (i.e.

REAL X2STOL (const REAL x) const
 Convert X (either 2theta or TOF) to sin(theta)/lambda, depending on the type of radiation.

REAL STOL2Pixel (const REAL stol) const
 Convert sin(theta)/lambda to pixel, depending on the type of radiation.


Protected Member Functions

void CalcPowderPattern () const
 Calc the powder pattern.

void CalcPowderPatternIntegrated () const
 Calc the integrated powder pattern.

virtual void Init ()
 Init parameters and options.

void PrepareIntegratedRfactor () const
 Prepare the calculation of the integrated R-factors.

void CalcNbPointUsed () const
 Calculate the number of points of the pattern actually used, from the maximum value of sin(theta)/lambda.

virtual void InitOptions ()
 Initialize options.


Protected Attributes

CrystVector_REAL mPowderPatternCalc
 The calculated powder pattern.

CrystVector_REAL mPowderPatternIntegratedCalc
 The calculated powder pattern, integrated.

CrystVector_REAL mPowderPatternBackgroundCalc
 The calculated powder pattern part which corresponds to 'background' (eg non-scalable components).

CrystVector_REAL mPowderPatternBackgroundIntegratedCalc
 The calculated powder pattern part which corresponds to 'background' (eg non-scalable components), integrated.

CrystVector_REAL mPowderPatternObs
 The observed powder pattern.

CrystVector_REAL mPowderPatternObsSigma
 The sigma of the observed pattern.

CrystVector_REAL mPowderPatternWeight
 The weight for each point of the pattern.

CrystVector_REAL mPowderPatternVariance
 The complete variance associated to each point of the powder pattern, taking into account observation and model errors.

CrystVector_REAL mPowderPatternVarianceIntegrated
 The complete variance associated to each point of the powder pattern, taking into account observation and model errors.

CrystVector_REAL mChi2Cumul
 The cumulative Chi^2 (integrated or not, depending on the option).

CrystVector_REAL mX
 Vector of x coordinates (either 2theta or time-of-flight) for the pattern.

bool mIsXAscending
 Is the mX vector sorted in ascending order ? (true for 2theta, false for TOF).

unsigned long mNbPoint
 Number of points in the pattern.

Radiation mRadiation
 The Radiation corresponding to this experiment.

RefinableObjClock mClockPowderPatternPar
 When were the pattern parameters (2theta or time-of-flight range) changed ?

RefinableObjClock mClockPowderPatternRadiation
 When were the radiation parameter (radiation type, wavelength) changed ?

RefinableObjClock mClockPowderPatternCalc
 When was the powder pattern last computed ?

RefinableObjClock mClockPowderPatternIntegratedCalc
 When was the powder pattern (integrated) last computed ?

RefinableObjClock mClockPowderPatternXCorr
 Corrections to 2Theta.

RefinableObjClock mClockScaleFactor
 Last modification of the scale factor.

CrystVector_REAL mExcludedRegionMinX
 Min coordinate for for all excluded regions.

CrystVector_REAL mExcludedRegionMaxX
 Max coordinate for 2theta for all excluded regions.

REAL mXZero
 Zero correction : $ (2\theta)_{obs} = (2\theta)_{real} +(2\theta)_{0}$ Thus mPowderPattern2ThetaMin=(mPowderPattern2ThetaMin-m2ThetaZero).

REAL m2ThetaDisplacement
 Displacement correction : $ (2\theta)_{obs} = (2\theta)_{real} + \frac{a}{\cos(\theta)} $.

REAL m2ThetaTransparency
 Transparency correction : $ (2\theta)_{obs} = (2\theta)_{real} + b\sin(2\theta) $.

REAL mDIFC
 Time Of Flight (TOF) parameters : $ t = DIFC*\frac{\sin(\theta)}{\lambda} + DIFA*\left(\frac{\sin(\theta)}{\lambda}\right)^2 + mXZero$.

REAL mDIFA
 Time Of Flight (TOF) parameters : $ t = DIFC*\frac{\sin(\theta)}{\lambda} + DIFA*\left(\frac{\sin(\theta)}{\lambda}\right)^2 + mXZero$.

ObjRegistry< PowderPatternComponentmPowderPatternComponentRegistry
 The components (crystalline phases, background,...) of the powder pattern.

CrystVector_REAL mScaleFactor
 The scale factors for each component.

bool mUseFastLessPreciseFunc
 Use faster, less precise functions ?

bool mStatisticsExcludeBackground
 Should Statistics (R, Rw,..) exclude the background ?

CrystVector_int mScalableComponentIndex
CrystMatrix_REAL mFitScaleFactorM
 Used to fit the components' scale factors.

CrystMatrix_REAL mFitScaleFactorB
 Used to fit the components' scale factors.

CrystMatrix_REAL mFitScaleFactorX
 Used to fit the components' scale factors.

RefObjOpt mOptProfileIntegration
 Use Integrated profiles for Chi^2, R, Rwp...

CrystVector_long mIntegratedPatternMin
CrystVector_long mIntegratedPatternMax
CrystVector_REAL mIntegratedObs
CrystVector_REAL mIntegratedWeight
CrystVector_REAL mIntegratedWeightObs
CrystVector_REAL mIntegratedVarianceObs
RefinableObjClock mClockIntegratedFactorsPrep
REAL mChi2
REAL mChi2LikeNorm
 This is the logarithm of the part of log(Likelihood) which corresponds to the normalization terms of gaussian distribution for each obs/calc point.

REAL mR
REAL mRw
RefinableObjClock mClockChi2
 Clock the last time Chi^2 was computed.

REAL mMaxSinThetaOvLambda
 Maximum sin(theta)/lambda for all calculations (10 by default).

unsigned long mNbPointUsed
 Number of points actually used, due to the maximum value of sin(theta)/lambda.

unsigned long mNbIntegrationUsed
 Number of integration intervals actually used, due to the maximum value of sin(theta)/lambda.

RefinableObjClock mClockNbPointUsed
 Clock recording the last time the number of points used (PowderPattern::mNbPointUsed) was changed.


Detailed Description

Powder pattern class, with an observed pattern and several calculated components to modelize the pattern.

This can also be used for simulation, using a fake Iobs. Supports multiple phases.


Constructor & Destructor Documentation

ObjCryst::PowderPattern::PowderPattern  ) 
 

ObjCryst::PowderPattern::PowderPattern const PowderPattern  ) 
 

ObjCryst::PowderPattern::~PowderPattern  ) 
 


Member Function Documentation

void ObjCryst::PowderPattern::AddExcludedRegion const REAL  min2Theta,
const REAL  max2theta
 

Add an Exclusion region, in 2theta, which will be ignored when computing R's XMLInput values must be, as always, in radians.

Does not work yet with integrated R factors. Note that the pattern is still computed in these regions. They are only ignored by statistics functions (R, Rws).

void ObjCryst::PowderPattern::AddPowderPatternComponent PowderPatternComponent  ) 
 

Add a component (phase, backround) to this pattern.

It must have been allocated in the heap. The pattern parameters (2theta min, step, nbpoints, wavelength, radiation type) of the component are automatically changed to that of the PowderPattern object.

virtual void ObjCryst::PowderPattern::BeginOptimization const bool  allowApproximations = false,
const bool  enableRestraints = false
[virtual]
 

This should be called by any optimization class at the begining of an optimization.

This will also check that everything is ready, eg call the RefinableObj::Prepare() function. This also affects all sub-objects.

Note:
this may be called several time for some objects which are used by several other objects.
Parameters:
allowApproximations: if true, then the object can use faster but less precise functions during the optimization. This is useful for global optimization not using derivatives.
enableRestraints: if true, then restrained parameters will be allowed to go beyond theur hard limits. This implies that the algorithm will take into account the cost (penalty) related to the restraints. Objects which do not use restraints will simply ignore this. WARNING: this parameter may be removed with the new likelihood scheme.

Reimplemented from ObjCryst::RefinableObj.

void ObjCryst::PowderPattern::CalcNbPointUsed  )  const [protected]
 

Calculate the number of points of the pattern actually used, from the maximum value of sin(theta)/lambda.

void ObjCryst::PowderPattern::CalcPowderPattern  )  const [protected]
 

Calc the powder pattern.

void ObjCryst::PowderPattern::CalcPowderPatternIntegrated  )  const [protected]
 

Calc the integrated powder pattern.

void ObjCryst::PowderPattern::FitScaleFactorForIntegratedR  )  const
 

void ObjCryst::PowderPattern::FitScaleFactorForIntegratedRw  )  const
 

void ObjCryst::PowderPattern::FitScaleFactorForR  )  const
 

Fit the scale(s) factor of each component to minimize R.

void ObjCryst::PowderPattern::FitScaleFactorForRw  )  const
 

Fit the scale(s) factor of each component to minimize Rw.

REAL ObjCryst::PowderPattern::GetChi2  )  const
 

Return conventionnal Chi^2.

Returns:
$ \chi^2 = \sum_i w_i \left(I_i^{obs}-I_i^{calc} \right)^2 $

const CrystVector_REAL& ObjCryst::PowderPattern::GetChi2Cumul  )  const
 

Get the powder pattern cumulative Chi^2.

Depending on the chosen option, it will be calculated in an integrated manner or not.

The vector is recomputed on every call, so this is slow.

virtual const string& ObjCryst::PowderPattern::GetClassName  )  const [virtual]
 

Name for this class ("RefinableObj", "Crystal",...).

This is only useful to distinguish different classes when picking up objects from the RefinableObj Global Registry

Reimplemented from ObjCryst::RefinableObj.

const RefinableObjClock& ObjCryst::PowderPattern::GetClockPowderPatternCalc  )  const
 

Last time the pattern was calculated.

const RefinableObjClock& ObjCryst::PowderPattern::GetClockPowderPatternPar  )  const
 

When were the pattern parameters (2theta range, step) changed ?

const RefinableObjClock& ObjCryst::PowderPattern::GetClockPowderPatternRadiation  )  const
 

When were the radiation parameter (radiation type, wavelength) changed ?

const RefinableObjClock& ObjCryst::PowderPattern::GetClockPowderPatternXCorr  )  const
 

When were the parameters for 2theta/TOF correction (zero, transparency, displacement) last changed ?

virtual void ObjCryst::PowderPattern::GetGeneGroup const RefinableObj obj,
CrystVector_uint &  groupIndex,
unsigned int &  firstGroup
const [virtual]
 

Get the gene group assigned to each parameter.

Each parameter (a gene in terms of genetic algorithms) can be assigned to a gene group. Thus when mating two configurations, genes will be exchanged by groups. By default (in the base RefinabeObj class), each parameter is alone in its group. Derived classes can group genes for a better s** life.

The number identifying a gene group only has a meaning in a given object. It can also change on subsequent calls, and thus is not unique.

Parameters:
obj the , supplied by an algorithm class (OptimizationObj,..), which contains a list of parameters, some of which (but possibly all or none) are parameters belonging to this object.
groupIndex a vector of unsigned integers, one for each parameter in the input object, giving an unsigned integer value as gene group index. At the beginning this vector should contain only zeros (no group assigned).
firstGroup this is the number of groups which have already been assigned, plus one. The gene groups returned by this object will start from this value, and increment firstGroup for each gene group used, so that different RefinableObj cannot share a gene group.
Note:
this function is not optimized, and should only be called at the beginning of a refinement.

Reimplemented from ObjCryst::RefinableObj.

const RefinableObjClock& ObjCryst::PowderPattern::GetIntegratedProfileLimitsClock  )  const
 

When were the integration intervals last changed ?

const CrystVector_long& ObjCryst::PowderPattern::GetIntegratedProfileMax  )  const
 

Get the list of last pixels for the integration intervals.

const CrystVector_long& ObjCryst::PowderPattern::GetIntegratedProfileMin  )  const
 

Get the list of first pixels for the integration intervals.

REAL ObjCryst::PowderPattern::GetIntegratedR  )  const
 

REAL ObjCryst::PowderPattern::GetIntegratedRw  )  const
 

virtual REAL ObjCryst::PowderPattern::GetLogLikelihood  )  const [virtual]
 

Get -log(likelihood) of the current configuration for the object.

By default (no likelihood evaluation available), this is equal to 0.

This call should not be recursive, it is the task of the algorithm to get the sum of likelihoods for all objects invlolved.

Note:
contrary to the old "Cost Function" approach, with log(Likelihood) there is no 'choice' of cost function, so that it is the task of the object to give the optimized likelihood (possibly with user options).
Warning:
: this is in under heavy development, so expect changes...

Reimplemented from ObjCryst::RefinableObj.

virtual const CrystVector_REAL& ObjCryst::PowderPattern::GetLSQCalc const unsigned  int  )  const [virtual]
 

Get the current calculated value for the LSQ function.

Reimplemented from ObjCryst::RefinableObj.

virtual const CrystVector_REAL& ObjCryst::PowderPattern::GetLSQObs const unsigned  int  )  const [virtual]
 

Get the observed values for the LSQ function.

Reimplemented from ObjCryst::RefinableObj.

virtual const CrystVector_REAL& ObjCryst::PowderPattern::GetLSQWeight const unsigned  int  )  const [virtual]
 

Get the weight values for the LSQ function.

Reimplemented from ObjCryst::RefinableObj.

REAL ObjCryst::PowderPattern::GetMaxSinThetaOvLambda  )  const
 

Get the maximum value for sin(theta)/lambda.

virtual unsigned int ObjCryst::PowderPattern::GetNbLSQFunction  )  const [virtual]
 

Number of LSQ functions.

Reimplemented from ObjCryst::RefinableObj.

unsigned long ObjCryst::PowderPattern::GetNbPoint  )  const
 

Number of points ?

unsigned long ObjCryst::PowderPattern::GetNbPointUsed  )  const
 

Number of points actually calculated (below the chosen max(sin(theta)/lambda)) ?

unsigned int ObjCryst::PowderPattern::GetNbPowderPatternComponent  )  const
 

Number of components.

const CrystVector_REAL& ObjCryst::PowderPattern::GetPowderPatternCalc  )  const
 

Get the calculated powder pattern.

PowderPatternComponent& ObjCryst::PowderPattern::GetPowderPatternComponent const  int  ) 
 

Access to a component of the powder pattern.

PowderPatternComponent& ObjCryst::PowderPattern::GetPowderPatternComponent const string &  name  ) 
 

Access to a component of the powder pattern.

const PowderPatternComponent& ObjCryst::PowderPattern::GetPowderPatternComponent const  int  )  const
 

Access to a component of the powder pattern.

const PowderPatternComponent& ObjCryst::PowderPattern::GetPowderPatternComponent const string &  name  )  const
 

Access to a component of the powder pattern.

const CrystVector_REAL& ObjCryst::PowderPattern::GetPowderPatternObs  )  const
 

Get the observed powder pattern.

const CrystVector_REAL& ObjCryst::PowderPattern::GetPowderPatternObsSigma  )  const
 

Get the sigma for each point of the observed powder pattern.

const CrystVector_REAL& ObjCryst::PowderPattern::GetPowderPatternVariance  )  const
 

Get the variance (obs+model) for each point of the powder pattern.

const CrystVector_REAL& ObjCryst::PowderPattern::GetPowderPatternWeight  )  const
 

Get the weight for each point of the powder pattern.

const CrystVector_REAL& ObjCryst::PowderPattern::GetPowderPatternX  )  const
 

Get the vector of X (2theta or time-of-flight) coordinates.

REAL ObjCryst::PowderPattern::GetPowderPatternXMax  )  const
 

Get the maximum 2theta.

REAL ObjCryst::PowderPattern::GetPowderPatternXMin  )  const
 

Get the Minimum 2theta.

REAL ObjCryst::PowderPattern::GetPowderPatternXStep  )  const
 

Get the average step in 2theta.

Warning:
: this will only return (2ThetaMax-2ThetaMin)/(nbPoints-1), so this is the 2theta step only if the step is fixed.

Deprecated:

REAL ObjCryst::PowderPattern::GetR  )  const
 

Unweighted R-factor.

Returns:
$ R= \sqrt {\frac{\sum_i \left( I_i^{obs}-I_i^{calc} \right)^2} {\sum_i (I_i^{obs})^2} }$

Radiation& ObjCryst::PowderPattern::GetRadiation  ) 
 

Neutron or x-ray experiment ?

const Radiation& ObjCryst::PowderPattern::GetRadiation  )  const
 

Neutron or x-ray experiment ?

RadiationType ObjCryst::PowderPattern::GetRadiationType  )  const
 

Neutron or x-ray experiment ?

REAL ObjCryst::PowderPattern::GetRw  )  const
 

Get the weighted R-factor.

Returns:
$ R_{w}= \sqrt {\frac{\sum_i w_i\left( I_i^{obs}-I_i^{calc} \right)^2} {\sum_i w_i (I_i^{obs})^2} }$

REAL ObjCryst::PowderPattern::GetWavelength  )  const
 

wavelength of the experiment (in Angstroems)

virtual void ObjCryst::PowderPattern::GlobalOptRandomMove const REAL  mutationAmplitude,
const RefParType type = gpRefParTypeObjCryst
[virtual]
 

Make a random move of the current configuration.

This is for global optimization algorithms. the moves for each parameter are less than their global optimization step, multiplied by the mutation amplitude.

Warning:
: this makes a random move for the parameter declared for this object, and it is the duty of the object to decide whether the included objects should be moved and how. (eg an algorithm should only call for a move with the top object, and this object decides how he and his sub-objects moves). By default (RefinableObj implementation) all included objects are moved recursively.
RefinableObj::
Parameters:
mutationAmplitude: multiplier for the maximum move amplitude, for all parameters
type: restrain the change exclusively to parameters of a given type (same type or descendant from this RefParType).

Reimplemented from ObjCryst::RefinableObj.

void ObjCryst::PowderPattern::ImportPowderPattern2ThetaObs const string &  fileName,
const int  nbSkip = 0
 

Import file with 2 columns 2Theta Iobs.

Parameters:
fileName: the filename (surprise!)
nbSkip: the number of lines to skip at the beginning of the file (default=0)

void ObjCryst::PowderPattern::ImportPowderPattern2ThetaObsSigma const string &  fileName,
const int  nbSkip = 0
 

Import file with 3 columns 2Theta Iobs Sigma.

Parameters:
fileName: the filename (surprise!)
nbSkip: the number of lines to skip at the beginning of the file (default=0)

void ObjCryst::PowderPattern::ImportPowderPatternCIF const CIF cif  ) 
 

Import CIF powder pattern data.

void ObjCryst::PowderPattern::ImportPowderPatternFullprof const string &  fullprofFileName  ) 
 

Import fullprof-style diffraction data.

Parameters:
fullprofFileName: filename

void ObjCryst::PowderPattern::ImportPowderPatternFullprof4 const string &  fileName  ) 
 

Import diffraction data from a file, with the first line has 2ThetaMin, step, 2thetaMax, and the following lines alternate 10 Iobs and 10 sigma. Ends with null entries (to fill last Iobs line to reach last sigme line).

That's fullprof format #4.

Parameters:
fileName: filename

void ObjCryst::PowderPattern::ImportPowderPatternGSAS const string &  fileName  ) 
 

Import GSAS standard powder pattern data (see GSAS manual).

Warning:
: partial support (only CONST-constant wavelength- data so far)

void ObjCryst::PowderPattern::ImportPowderPatternILL_D1A5 const string &  filename  ) 
 

Import powder pattern, format from ILL D1A/D2B (format without counter info).

void ObjCryst::PowderPattern::ImportPowderPatternMultiDetectorLLBG42 const string &  fileName  ) 
 

diffraction data in a multi-detector format (fullprof format #6).

First line is text. Third entry of second line is the 2theta step. Third line has the 2thetamin, fourth line has monitors and temperatures. Then each line has ten pairs (I2,I8)of NbCounters,intensity. Ends with negative entries.

Parameters:
fileName: filename

void ObjCryst::PowderPattern::ImportPowderPatternPSI_DMC const string &  filename  ) 
 

Import powder pattern, format DMC from PSI.

void ObjCryst::PowderPattern::ImportPowderPatternSietronicsCPI const string &  fileName  ) 
 

Import *.cpi Sietronics diffraction data.

Parameters:
fileName: filename

void ObjCryst::PowderPattern::ImportPowderPatternTOF_ISIS_XYSigma const string &  fileName  ) 
 

Import TOF file (ISIS type, 3 columns t, Iobs, sigma(Iobs)).

Parameters:
fileName: the filename

void ObjCryst::PowderPattern::ImportPowderPatternXdd const string &  fileName  ) 
 

Import *.xdd diffraction data (Topas,...).

Parameters:
fileName: filename

virtual void ObjCryst::PowderPattern::Init  )  [protected, virtual]
 

Init parameters and options.

virtual void ObjCryst::PowderPattern::InitOptions  )  [protected, virtual]
 

Initialize options.

void ObjCryst::PowderPattern::Prepare  )  [virtual]
 

Prepare everything (if necessary) for an optimization/calculation.

Reimplemented from ObjCryst::RefinableObj.

void ObjCryst::PowderPattern::PrepareIntegratedRfactor  )  const [protected]
 

Prepare the calculation of the integrated R-factors.

void ObjCryst::PowderPattern::PrintObsCalcData ostream &  os = cout  )  const
 

Print to thee screen/console the observed and calculated pattern (long, mostly useful for debugging).

void ObjCryst::PowderPattern::SavePowderPattern const string &  filename = "powderPattern.out"  )  const
 

Save powder pattern to one file, text format, 3 columns theta Iobs Icalc.

If Iobs is missing, the column is omitted.

Todo:
export in other formats (.prf,...), with a list of reflection position for all phases...

void ObjCryst::PowderPattern::Set2ThetaDisplacement const REAL  displacement  ) 
 

Change displacement correction $ (2\theta)_{obs} = (2\theta)_{real} + \frac{a}{\cos(\theta)} $.

void ObjCryst::PowderPattern::Set2ThetaTransparency const REAL  transparency  ) 
 

Change transparency correction $ (2\theta)_{obs} = (2\theta)_{real} + b\sin(2\theta) $.

void ObjCryst::PowderPattern::SetEnergy const REAL  energy  ) 
 

Set the energy of the experiment [in keV, lambda(A)=12398/E(keV)].

virtual void ObjCryst::PowderPattern::SetMaxSinThetaOvLambda const REAL  max  )  [virtual]
 

Set the maximum value for sin(theta)/lambda.

All data (reflections,..) still exist but are ignored for all calculations.

void ObjCryst::PowderPattern::SetPowderPatternObs const CrystVector_REAL &  obs  ) 
 

Set observed powder pattern from vector array.

Note: powder pattern parameters must have been set before calling this function, for example by calling DiffractionDataPowder::InitPowderPatternPar().

void ObjCryst::PowderPattern::SetPowderPatternPar const REAL  min,
const REAL  step,
unsigned long  nbPoint
 

the powder pattern angular range & resolution parameter.

this will affect all components (phases) of the pattern.

Use this with caution, as the number of points must be correct with respect to the observed data (Iobs).

Parameters:
min: min 2theta (in radians) or time-of-flight (in microseconds) value,
step: step (assumed constant) in 2theta or time-of-flight (in microseconds).
nbPoints: number of points in the pattern.
Warning:
: use only this for constant-step patterns. Otherwise, use PowderPattern::SetPowderPatternX()

void ObjCryst::PowderPattern::SetPowderPatternX const CrystVector_REAL &  x  ) 
 

Set the x coordinate of the powder pattern : either the 2theta or time-of-flight values for each recorded point.

The step need not be constant, but the variation must be strictly monotonous.

2theta must be in radians and time-of-flight in microseconds

void ObjCryst::PowderPattern::SetRadiation const Radiation radiation  ) 
 

Set the radiation.

void ObjCryst::PowderPattern::SetRadiationType const RadiationType  radiation  ) 
 

Set the radiation type.

void ObjCryst::PowderPattern::SetSigmaToSqrtIobs  ) 
 

Set sigma=sqrt(Iobs).

void ObjCryst::PowderPattern::SetWavelength const string &  XRayTubeElementName,
const REAL  alpha12ratio = 0.5
 

Set the wavelength of the experiment to that of an X-Ray tube.

Parameters:
XRayTubeElementName : name of the anticathode element name. Known ones are Cr, Fe, Cu, Mo, Ag.
alpha2Alpha2ratio: Kalpha2/Kalpha1 ratio (0.5 by default)
Alpha1 and alpha2 wavelength are taken from R. Grosse-Kunstleve package, and the average wavelength is calculated using the alpha2/alpha1 weight. All structure factors computation are made using the average wavelength, and for powder diffraction, profiles are output at the alpha1 and alpha2 ratio for the calculated pattern.

NOTE : if the name of the wavelength is generic (eg"Cu"), then the program considers that there are both Alpha1 and Alpha2, and thus automatically changes the WavelengthType to WAVELENGTH_ALPHA12. If instead either alpha1 or alpha2 (eg "CuA1") is asked for, the WavelengthType is set to WAVELENGTH_MONOCHROMATIC. In both cases, the radiation type is set to X-Ray.

void ObjCryst::PowderPattern::SetWavelength const REAL  lambda  ) 
 

Set the wavelength of the experiment (in Angstroems).

Note:
: this is only useful for a monochromatic (X-Ray or neutron) powder pattern.

void ObjCryst::PowderPattern::SetWeightPolynomial const REAL  a,
const REAL  b,
const REAL  c,
const REAL  minRelatIobs = 1e-3
 

Set w = 1/(a+ Iobs + b*Iobs^2+c*Iobs^3).

To filter too small or null intensities: if Iobs < [minRelatIobs * max(Iobs)], then use Iobs=minRelatIobs * max(Iobs) to compute the weight.

Typical values: a=2*min(Iobs) b=2/max(Iobs) c=0

void ObjCryst::PowderPattern::SetWeightToInvSigmaSq const REAL  minRelatSigma = 1e-3  ) 
 

Set w = 1/sigma^2.

To filter too small or null intensities :If sigma< minRelatSigma* max(sigma), then w=1/(minRelatSigma* max(sigma))^2

void ObjCryst::PowderPattern::SetWeightToUnit  ) 
 

Set w = 1.

void ObjCryst::PowderPattern::SetXZero const REAL  newZero  ) 
 

Change Zero in x (2theta,tof).

REAL ObjCryst::PowderPattern::STOL2Pixel const REAL  stol  )  const
 

Convert sin(theta)/lambda to pixel, depending on the type of radiation.

This does not take into account any zero/transparency, etc... correction

REAL ObjCryst::PowderPattern::STOL2X const REAL  stol  )  const
 

Convert sin(theta)/lambda to X (i.e.

either to 2theta or to TOF), depending on the type of radiation.

This does not take into account any zero/transparency, etc... correction

REAL ObjCryst::PowderPattern::X2Pixel const REAL  x  )  const
 

Get the pixel number on the experimental pattern, corresponding to a given (experimental) x coordinate.

Parameters:
x: the x (2theta, tof) value.
Returns:
the x (2theta, tof) value as it appears on the pattern.
Warning:
: this can be real slow, especially for non-fixed steps.

: this returns the exact pixel coordinate, as a floating-point value, and not the closest pixel coordinate.

REAL ObjCryst::PowderPattern::X2PixelCorr const REAL  x  )  const
 

Get the pixel number on the experimental pattern, from the theoretical (uncorrected) x coordinate, taking into account all corrections.

(zero, transparency,..).

For internal use only.

Parameters:
x: the theoretical x (2theta, tof) value.
Returns:
the x (2theta, tof) value as it appears on the pattern.
Warning:
: this can be real slow, especially for non-fixed steps.

: this returns the exact pixel coordinate, as a floating-point value, and not the closest pixel coordinate.

REAL ObjCryst::PowderPattern::X2STOL const REAL  x  )  const
 

Convert X (either 2theta or TOF) to sin(theta)/lambda, depending on the type of radiation.

This does not take into account any zero/transparency, etc... correction

REAL ObjCryst::PowderPattern::X2XCorr const REAL  x  )  const
 

Get the experimental x (2theta, tof) from the theoretical value, taking into account all corrections (zero, transparency,..).

For internal use only.

Parameters:
ttheta: the theoretical x (2theta, tof) value.
Returns:
the x (2theta, tof) value as it appears on the pattern.

virtual void ObjCryst::PowderPattern::XMLInput istream &  is,
const XMLCrystTag tag
[virtual]
 

Input From stream.

Todo:
Add an bool XMLInputTag(is,tag) function to recognize all the tags from the stream. So that each inherited class can use the XMLInputTag function from its parent (ie take advantage of inheritance). The children class would first try to interpret the tag, then if unsuccessful would pass it to its parent (thus allowing overloading), etc...

Reimplemented from ObjCryst::RefinableObj.

virtual void ObjCryst::PowderPattern::XMLOutput ostream &  os,
int  indent = 0
const [virtual]
 

Output to stream in well-formed XML.

Todo:
Use inheritance.. as for XMLInputTag()...

Reimplemented from ObjCryst::RefinableObj.


Member Data Documentation

REAL ObjCryst::PowderPattern::m2ThetaDisplacement [protected]
 

Displacement correction : $ (2\theta)_{obs} = (2\theta)_{real} + \frac{a}{\cos(\theta)} $.

REAL ObjCryst::PowderPattern::m2ThetaTransparency [protected]
 

Transparency correction : $ (2\theta)_{obs} = (2\theta)_{real} + b\sin(2\theta) $.

REAL ObjCryst::PowderPattern::mChi2 [mutable, protected]
 

CrystVector_REAL ObjCryst::PowderPattern::mChi2Cumul [mutable, protected]
 

The cumulative Chi^2 (integrated or not, depending on the option).

REAL ObjCryst::PowderPattern::mChi2LikeNorm [mutable, protected]
 

This is the logarithm of the part of log(Likelihood) which corresponds to the normalization terms of gaussian distribution for each obs/calc point.

In practice, this is the sum of 1/2*log(2pi*sig(i)^2), although we discard the 2pi terms.

RefinableObjClock ObjCryst::PowderPattern::mClockChi2 [mutable, protected]
 

Clock the last time Chi^2 was computed.

RefinableObjClock ObjCryst::PowderPattern::mClockIntegratedFactorsPrep [mutable, protected]
 

RefinableObjClock ObjCryst::PowderPattern::mClockNbPointUsed [mutable, protected]
 

Clock recording the last time the number of points used (PowderPattern::mNbPointUsed) was changed.

RefinableObjClock ObjCryst::PowderPattern::mClockPowderPatternCalc [mutable, protected]
 

When was the powder pattern last computed ?

RefinableObjClock ObjCryst::PowderPattern::mClockPowderPatternIntegratedCalc [mutable, protected]
 

When was the powder pattern (integrated) last computed ?

RefinableObjClock ObjCryst::PowderPattern::mClockPowderPatternPar [protected]
 

When were the pattern parameters (2theta or time-of-flight range) changed ?

RefinableObjClock ObjCryst::PowderPattern::mClockPowderPatternRadiation [protected]
 

When were the radiation parameter (radiation type, wavelength) changed ?

RefinableObjClock ObjCryst::PowderPattern::mClockPowderPatternXCorr [protected]
 

Corrections to 2Theta.

RefinableObjClock ObjCryst::PowderPattern::mClockScaleFactor [mutable, protected]
 

Last modification of the scale factor.

REAL ObjCryst::PowderPattern::mDIFA [protected]
 

Time Of Flight (TOF) parameters : $ t = DIFC*\frac{\sin(\theta)}{\lambda} + DIFA*\left(\frac{\sin(\theta)}{\lambda}\right)^2 + mXZero$.

REAL ObjCryst::PowderPattern::mDIFC [protected]
 

Time Of Flight (TOF) parameters : $ t = DIFC*\frac{\sin(\theta)}{\lambda} + DIFA*\left(\frac{\sin(\theta)}{\lambda}\right)^2 + mXZero$.

CrystVector_REAL ObjCryst::PowderPattern::mExcludedRegionMaxX [protected]
 

Max coordinate for 2theta for all excluded regions.

CrystVector_REAL ObjCryst::PowderPattern::mExcludedRegionMinX [protected]
 

Min coordinate for for all excluded regions.

CrystMatrix_REAL ObjCryst::PowderPattern::mFitScaleFactorB [mutable, protected]
 

Used to fit the components' scale factors.

CrystMatrix_REAL ObjCryst::PowderPattern::mFitScaleFactorM [mutable, protected]
 

Used to fit the components' scale factors.

CrystMatrix_REAL ObjCryst::PowderPattern::mFitScaleFactorX [mutable, protected]
 

Used to fit the components' scale factors.

CrystVector_REAL ObjCryst::PowderPattern::mIntegratedObs [mutable, protected]
 

CrystVector_long ObjCryst::PowderPattern::mIntegratedPatternMax [mutable, protected]
 

CrystVector_long ObjCryst::PowderPattern::mIntegratedPatternMin [mutable, protected]
 

CrystVector_REAL ObjCryst::PowderPattern::mIntegratedVarianceObs [mutable, protected]
 

CrystVector_REAL ObjCryst::PowderPattern::mIntegratedWeight [mutable, protected]
 

CrystVector_REAL ObjCryst::PowderPattern::mIntegratedWeightObs [mutable, protected]
 

bool ObjCryst::PowderPattern::mIsXAscending [protected]
 

Is the mX vector sorted in ascending order ? (true for 2theta, false for TOF).

REAL ObjCryst::PowderPattern::mMaxSinThetaOvLambda [protected]
 

Maximum sin(theta)/lambda for all calculations (10 by default).

This keeps all data in memory, but only the part which is below the max is calculated.

unsigned long ObjCryst::PowderPattern::mNbIntegrationUsed [mutable, protected]
 

Number of integration intervals actually used, due to the maximum value of sin(theta)/lambda.

unsigned long ObjCryst::PowderPattern::mNbPoint [protected]
 

Number of points in the pattern.

unsigned long ObjCryst::PowderPattern::mNbPointUsed [mutable, protected]
 

Number of points actually used, due to the maximum value of sin(theta)/lambda.

RefObjOpt ObjCryst::PowderPattern::mOptProfileIntegration [protected]
 

Use Integrated profiles for Chi^2, R, Rwp...

CrystVector_REAL ObjCryst::PowderPattern::mPowderPatternBackgroundCalc [mutable, protected]
 

The calculated powder pattern part which corresponds to 'background' (eg non-scalable components).

It is already included in mPowderPatternCalc

CrystVector_REAL ObjCryst::PowderPattern::mPowderPatternBackgroundIntegratedCalc [mutable, protected]
 

The calculated powder pattern part which corresponds to 'background' (eg non-scalable components), integrated.

CrystVector_REAL ObjCryst::PowderPattern::mPowderPatternCalc [mutable, protected]
 

The calculated powder pattern.

It is mutable since it is completely defined by other parameters (eg it is not an 'independent parameter')

ObjRegistry<PowderPatternComponent> ObjCryst::PowderPattern::mPowderPatternComponentRegistry [protected]
 

The components (crystalline phases, background,...) of the powder pattern.

CrystVector_REAL ObjCryst::PowderPattern::mPowderPatternIntegratedCalc [mutable, protected]
 

The calculated powder pattern, integrated.

CrystVector_REAL ObjCryst::PowderPattern::mPowderPatternObs [protected]
 

The observed powder pattern.

CrystVector_REAL ObjCryst::PowderPattern::mPowderPatternObsSigma [protected]
 

The sigma of the observed pattern.

CrystVector_REAL ObjCryst::PowderPattern::mPowderPatternVariance [mutable, protected]
 

The complete variance associated to each point of the powder pattern, taking into account observation and model errors.

CrystVector_REAL ObjCryst::PowderPattern::mPowderPatternVarianceIntegrated [mutable, protected]
 

The complete variance associated to each point of the powder pattern, taking into account observation and model errors.

Integrated.

CrystVector_REAL ObjCryst::PowderPattern::mPowderPatternWeight [mutable, protected]
 

The weight for each point of the pattern.

REAL ObjCryst::PowderPattern::mR [mutable, protected]
 

Radiation ObjCryst::PowderPattern::mRadiation [protected]
 

The Radiation corresponding to this experiment.

REAL ObjCryst::PowderPattern::mRw [mutable, protected]
 

CrystVector_int ObjCryst::PowderPattern::mScalableComponentIndex [mutable, protected]
 

For internal use only.

To compute scale factors, which are the components (phases) that can be scaled ?

CrystVector_REAL ObjCryst::PowderPattern::mScaleFactor [mutable, protected]
 

The scale factors for each component.

For unscalable phases, this is set to 1 (constant).

This is mutable because generally we use the 'best' scale factor, but it should not be...

bool ObjCryst::PowderPattern::mStatisticsExcludeBackground [protected]
 

Should Statistics (R, Rw,..) exclude the background ?

bool ObjCryst::PowderPattern::mUseFastLessPreciseFunc [protected]
 

Use faster, less precise functions ?

CrystVector_REAL ObjCryst::PowderPattern::mX [protected]
 

Vector of x coordinates (either 2theta or time-of-flight) for the pattern.

Stored in ascending order for 2theta, and descending for TOF, i.e. always in ascending order for the corresponding sin(theta)/lambda.

REAL ObjCryst::PowderPattern::mXZero [protected]
 

Zero correction : $ (2\theta)_{obs} = (2\theta)_{real} +(2\theta)_{0}$ Thus mPowderPattern2ThetaMin=(mPowderPattern2ThetaMin-m2ThetaZero).


The documentation for this class was generated from the following file:
Generated on Tue Nov 14 15:04:34 2006 for ObjCryst++ by doxygen 1.3.6