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

ObjCryst::PowderPattern Class Reference

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

#include <PowderPattern.h>

Inheritance diagram for ObjCryst::PowderPattern::

ObjCryst::RefinableObj List of all members.

Public Methods

 PowderPattern ()
 PowderPattern (const PowderPattern &)
 ~PowderPattern ()
virtual const string GetClassName () const
 Name for this class ("RefinableObj", "Crystal",...). This is only useful to distinguish different classes when picking up objects from the RefinableObj Global Registry.

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

unsigned int GetNbPowderPatternComponent () const
 Number of components.

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

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

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

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

void SetPowderPatternPar (const double tthetaMin, const double tthetaStep, unsigned long nbPoint)
 \briefSet the powder spectrum angular range & resolution parameter. More...

unsigned long GetNbPoint () const
 Number of points ?

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

const RadiationGetRadiation () const
 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 double lambda)
 Set the wavelength of the experiment (in Angstroems).

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

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

double GetWavelength () const
 wavelength of the experiment (in Angstroems).

void SetUseFastLessPreciseFunc (const bool useItOrNot)
 Use of faster, less precise approximations to compute the powder spectrums This can be useful fot global optimization, but should be avoided for precise (eg derivative calculation) work.

void SetUseOnlyLowAngleData (const bool useOnlyLowAngle, const double angle)
 Set an option so that only low-amgle reflections (theta < angle) are used. More...

const CrystVector_double & GetPowderPatternCalc () const
 Get the calculated powder spectrum.

const CrystVector_double & GetPowderPatternObs () const
 Get the observed powder spectrum.

const CrystVector_double & GetPowderPatternObsSigma () const
 Get the sigma for each point of the observed powder spectrum.

const CrystVector_double & GetPowderPatternWeight () const
 Get the weight for each point of the powder spectrum.

double Get2ThetaMin () const
 Get the Minimum 2theta.

double Get2ThetaStep () const
 Get the step in 2theta.

double Get2ThetaMax () const
 Get the maximum 2theta.

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

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

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

void Set2ThetaZero (const double newZero)
 Change Zero in 2Theta.

void Set2ThetaDisplacement (const double displacement)
 Change displacement correction .

void Set2ThetaTransparency (const double transparency)
 Change transparency correction .

double Get2ThetaCorr (const double ttheta) const
 Get the experimental 2theta from the theoretical value, taking into account all corrections (zero, transparency,..).
Parameters:
ttheta:  the theoretical 2theta value.
Returns:
the 2theta value as it appears on the spectrum.


long Get2ThetaCorrPixel (const double ttheta) const
 Get the pixel number on the experimental spectrum, from the theoretical (uncorrected) value of 2theta, taking into account all corrections. (zero, transparency,..).
Parameters:
ttheta:  the theoretical 2theta value.
Returns:
the 2theta value as it appears on the spectrum.


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

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

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

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

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

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

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

void SetPowderPatternObs (const CrystVector_double &obs)
 Set observed powder spectrum from vector array. More...

void SavePowderPattern (const string &filename="powderPattern.out") const
 Save powder spectrum to one file, text format, 3 columns theta Iobs Icalc.If Iobs is missing, the column is omitted. position for all phases... More...

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

double GetR () const
 Unweighted R-factor. More...

double GetRw () const
 Get the weighted R-factor. More...

double GetChiSq () const
 Return conventionnal Chi^2. More...

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

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

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

void SetWeightToInvSigmaSq (const double 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 SetWeightToSinTheta (const double power=1.)
 Set w = sin(theta). Not really usful, huh ?

void SetWeightToUnit ()
 Set w = 1.

void SetWeightPolynomial (const double a, const double b, const double c, const double 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 Add2ThetaExcludedRegion (const double min2Theta, const double 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).

unsigned int GetNbCostFunction () const
 Number of Cost functions.

const string & GetCostFunctionName (const unsigned int) const
 Get a Cost function name from its id#.

const string & GetCostFunctionDescription (const unsigned int) const
 Get the (short) description of a cost function.

virtual double GetCostFunctionValue (const unsigned int)
 Get the current value of a cost function this should be const...

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

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

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


Protected Methods

void CalcPowderPattern () const
 Calc the powder spectrum.

virtual void Init ()
 Init parameters and options.


Protected Attributes

CrystVector_double mPowderPatternCalc
 The calculated powder spectrum. It is mutable since it is completely defined by other parameters (eg it is not an 'independent parameter').

CrystVector_double mPowderPatternBackgroundCalc
 The calculated powder spectrum part which corresponds to 'background' (eg non-scalable components). It is already included in mPowderPatternCalc.

CrystVector_double mPowderPatternObs
 The observed powder spectrum.

CrystVector_double mPowderPatternObsSigma
 The sigma of the observed spectrum.

CrystVector_double mPowderPatternWeight
 The weight for each point of the spectrum.

double m2ThetaMin
 2theta min and step for the spectrum.

double m2ThetaStep
 2theta min and step for the spectrum.

unsigned long mNbPoint
 Number of points in the spectrum.

double mWavelength
 The wavelength of the experiment, in Angstroems.
Warning:
This should be removed, as it is also available in mRadiation.


Radiation mRadiation
 The wavelength of the experiment, in Angstroems.

RefinableObjClock mClockPowderPatternPar
 When were the spectrum parameters (2theta range, step) changed ?

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

RefinableObjClock mClockPowderPatternCalc
 When was the powder spectrum last computed ?

RefinableObjClock mClockPowderPattern2ThetaCorr
 Corrections to 2Theta.

RefinableObjClock mClockScaleFactor
 Last modification of the scale factor.

CrystVector_double mExcludedRegionMin2Theta
 Min value for 2theta for all excluded regions.

CrystVector_double mExcludedRegionMax2Theta
 Max value for 2theta for all excluded regions.

double m2ThetaZero
 Zero correction : Thus mPowderPattern2ThetaMin=(mPowderPattern2ThetaMin-m2ThetaZero).

double m2ThetaDisplacement
 Displacement correction : .

double m2ThetaTransparency
 Transparency correction : .

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

CrystVector_double mScaleFactor
 The scale factors for each component. For unscalable phases, this is set to 1 (constant).

bool mUseFastLessPreciseFunc
 Use faster, less precise functions ?

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

bool mStatisticsUseIntegratedPeak
 Use integrated R & Rw factors (=>don't care about peak profiles) NOT IMPLEMENTED yet. Requires delicate tuning for the width of integration.

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

CrystMatrix_double mFitScaleFactorM
  Used to fit the components' scale factors.

CrystMatrix_double mFitScaleFactorB
  Used to fit the components' scale factors.

CrystMatrix_double mFitScaleFactorX
  Used to fit the components' scale factors.

bool mUseOnlyLowAngleData
 Flag forcing the use of only low-angle reflections. More...

double mUseOnlyLowAngleDataLimit
 Limit (theta angle, in radian) for the above option. More...


Detailed Description

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

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


Member Function Documentation

void AddPowderPatternComponent PowderPatternComponent  
 

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

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

double GetChiSq   const
 

Return conventionnal Chi^2.

Returns:

double GetR   const
 

Unweighted R-factor.

Returns:

double GetRw   const
 

Get the weighted R-factor.

Returns:

void ImportPowderPattern2ThetaObs const string &    fileName,
const int    nbSkip = 0
 

Import file with 2 columns 2Theta Iobs.

Warning:
the 2theta step is assumed to be constant !!!
Parameters:
fileName:  the filename (surprise!)
nbSkip:  the number of lines to skip at the beginning of the file (default=0)

void ImportPowderPattern2ThetaObsSigma const string &    fileName,
const int    nbSkip = 0
 

Import file with 3 columns 2Theta Iobs Sigma.

Warning:
the 2theta step is assumed to be constant !!!
Parameters:
fileName:  the filename (surprise!)
nbSkip:  the number of lines to skip at the beginning of the file (default=0)

void ImportPowderPatternFullprof const string &    fullprofFileName
 

Import fullprof-style diffraction data.

Parameters:
fullprofFileName:  filename

void ImportPowderPatternSietronicsCPI const string &    fileName
 

Import *.cpi Sietronics diffraction data.

Parameters:
fileName:  filename

void ImportPowderPatternXdd const string &    fileName
 

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

Parameters:
fileName:  filename

void SavePowderPattern const string &    filename = "powderPattern.out" const
 

Save powder spectrum to one file, text format, 3 columns theta Iobs Icalc.If Iobs is missing, the column is omitted. position for all phases...

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

void SetPowderPatternObs const CrystVector_double &    obs
 

Set observed powder spectrum from vector array.

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

void SetPowderPatternPar const double    tthetaMin,
const double    tthetaStep,
unsigned long    nbPoint
 

\briefSet the powder spectrum angular range & resolution parameter.

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

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

Parameters:
tthetaMin:  min 2theta value, in radians
tthetaStep:  step (assumed constant) in 2theta.
nbPoints:  number of points in the spectrum.

void SetUseOnlyLowAngleData const bool    useOnlyLowAngle,
const double    angle
 

Set an option so that only low-amgle reflections (theta < angle) are used.

See DiffractionData::mUseOnlyLowAngleData

Deprecated:

void SetWavelength const string &    XRayTubeElementName,
const double    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.

virtual void 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 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

bool mUseOnlyLowAngleData [protected]
 

Flag forcing the use of only low-angle reflections.

Mainly for use during global optimizations, or more generally when the program is far from the real structure. In this case high-angle reflection are not significant and only lead to slower calculations and also in fooling the optimization (bad agreement at low angle and good with the more numerous high-angle reflections). By default this is set to false.

Practically, this means that any reflections below the limit is simply ignored, not calculated, not taken into account in statistics.

Deprecated:

double mUseOnlyLowAngleDataLimit [protected]
 

Limit (theta angle, in radian) for the above option.

Deprecated:


The documentation for this class was generated from the following file:
Generated on Wed Nov 14 19:48:37 2001 for ObjCryst++ by doxygen1.2.11.1 written by Dimitri van Heesch, © 1997-2001