Stratagem

Main class of the interface. It setups the experimental parameters such as the Experiment‘s and Sample, geometry (geometry), type of \(\phi(\rho z)\) model (prz_mode) and fluorescence mode (fluorescence).

stratagemtools.stratagem.PRZMODE_XPP = 0

\(\phi(\rho z)\) from XPP

stratagemtools.stratagem.PRZMODE_PAP = 1

\(\phi(\rho z)\) from PAP

stratagemtools.stratagem.PRZMODE_GAU = 2

\(\phi(\rho z)\) unknown, possibly two Gaussians

stratagemtools.stratagem.FLUORESCENCE_NONE = 0

No fluorescence

stratagemtools.stratagem.FLUORESCENCE_LINE = 1

Only characteristic fluorescence

stratagemtools.stratagem.FLUORESCENCE_LINE_CONT = 2

Characteristic and Bremsstrahlung fluorescence

exception stratagemtools.stratagem.StratagemError

Exception raised for all errors related to the STRATAGem interface.

class stratagemtools.stratagem.Stratagem(dll_path=None, display_error=True)

Main interface establishing a connection to the STRATAGem OEM interface and perform calculations using SAMx’s STRATAGem. It is highly recommended to use Stratagem as a context manager (i.e. with statement) to ensure that the connection to the DLL is properly closed. For instance:

>>> with Stratagem() as strata:
...     strata.prz_mode = PRZMODE_XPP

Otherwise the following series of method must be called:

>>> strata = Stratagem()
>>> strata.init()
>>> strata.prz_mode = PRZMODE_XPP
>>> strata.close()
Parameters:
  • dll_path (str) – complete path to the location of stratadllogger.dll (optional). If None, the path is found in the Windows registry under Software\SAMx\Stratagem\Configuration. If the DLL is not found a StratagemError is raised.
  • display_error (bool) – whether to display a message dialog on error
init()

Initializes and setups STRATAGem. It does not have to be used if Stratagem is used as a context manager.

close()

Closes the connection to the STRATAGem DLL. It does not have to be used if Stratagem is used as a context manager.

reset()

Resets all parameters to the defaults, remove all experiments and sample.

set_sample(sample)

Sets the sample, which will be used in all subsequent calculations. Note that only one sample can be defined.

Parameters:sample (Sample) – sample definition
get_sample()

Returns the current sample. It can correspond to the sample defined by set_sample() or the sample resulting from the computations (see compute()).

Note

a new sample is returned every time this method is called

Returns:current sample
Return type:Sample
sample

Property to set/get sample

add_experiment(experiment)

Adds an experiment, i.e. measurements of k-ratio at different energies.

Hint

Use reset() method to remove defined experiments.

Parameters:experiment (Experiment) – experiment
add_experiments(*exps)

Adds several experiments:

>>> strata.add_experiments(exp1, exp2, exp3)
get_experiments()

Returns a tuple of all defined experiments.

Return type:tuple
set_geometry(toa, tilt, azimuth)

Sets the geometry.

Parameters:
  • toa – take off angle (in radians)
  • tilt – tilt angle (in radians)
  • azimuth – azimuthal angle (in radians)
get_geometry()

Returns the geometry.

Returns:take off angle (in radians), tilt angle (in radians), azimuthal angle (in radians)
geometry

Property to get geometry

set_prz_mode(mode)

Sets the type of model to use for the \(\phi(\rho z)\).

Parameters:mode (int) –

type of model, either

get_prz_mode()

Returns the type of model to use for the \(\phi(\rho z)\).

Returns:either PRZMODE_XPP, PRZMODE_PAP or PRZMODE_GAU
Return type:int
prz_mode

Property to get/set prz mode

set_fluorescence(flag)

Sets the fluorescence flag.

Parameters:flag (int) –

either

get_fluorescence()

Returns the fluorescence flag.

Returns:either FLUORESCENCE_NONE, FLUORESCENCE_LINE or FLUORESCENCE_LINE_CONT
Return type:int
fluorescence

Property to get/set fluorescence

set_standard_directory(dirpath)

Sets the directory where standard files are stored.

Parameters:dirpath (str) – path to directory
get_standard_directory()

Returns the directory where standard files are stored.

Return type:str
standard_directory

Property to get/set standard directory

compute_kratio_vs_thickness(layer, thickness_low_m, thickness_high_m, step)

Computes the variation of the k-ratio as a function of the thickness for a layer.

Parameters:
  • layer (Layer) – layer of a sample (must have been previously added)
  • thickness_low_m (float) – lower limit of the thickness in meters
  • thickness_high_m (float) – upper limit of the thickness in meters
  • step (int) – number of steps
Returns:

tuple containing

  • list of thicknesses
  • dict where the keys are experiments (as defined by add_experiment()) and the values are list containing k-ratios for each thickness

compute_kratio_vs_energy(energy_high_eV, step)

Computes the variation of the k-ratio as a function of the incident energy. Note that the computation also starts at 0 keV up to the specified energy.

Parameters:
  • energy_high_eV (float) – upper limit of the thickness in electronvolts
  • step (int) – number of steps
Returns:

tuple containing

  • list of energies in electronvolts
  • dict where the keys are experiments (as defined by add_experiment()) and the values are list containing k-ratios for each energy

compute_kratios()

Computes the k-ratios of the different experiments.

Returns:dict where the keys are experiments (as defined by add_experiment()) and the values are k-ratios (float).
compute(iteration_max=50)

Computes the unknown composition(s) and thickness(es) in the specified sample.

Parameters:iteration_max (int) – maximum number of iterations of the solve (default: 50)
Returns:calculated sample
Return type:Sample
compute_prz(maxdepth_m=None, bins=100)

Compute \(\phi(\rho z)\) of all experiments.

Warning

Only available for substrate (no layers).

Parameters:
  • maxdepth_m (float) – maximum depth of the \(\phi(\rho z)\) distribution in meters. If None, Kanaya-Okayama electron range is used with a safety factor of 1.5.
  • bins (int) – number of bins in the \(\phi(\rho z)\) distribution
Returns:

a dict where the keys are the experiments and the values are a tuple containing three lists:

  • \(\rho z\) coordinates (in g/cm2)
  • generated intensities of \(\phi(\rho z)\) (no absorption)
  • emitted intensites of \(\phi(\rho z)\)