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
Stratagemas a context manager (i.e.withstatement) 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 ofstratadllogger.dll(optional). IfNone, the path is found in the Windows registry underSoftware\SAMx\Stratagem\Configuration. If the DLL is not found aStratagemErroris 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
Stratagemis used as a context manager.
-
close()¶ Closes the connection to the STRATAGem DLL. It does not have to be used if
Stratagemis 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 (seecompute()).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
tupleof 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_PAPorPRZMODE_GAUReturn type: int
-
prz_mode¶ Property to get/set prz mode
-
get_fluorescence()¶ Returns the fluorescence flag.
Returns: either FLUORESCENCE_NONE,FLUORESCENCE_LINEorFLUORESCENCE_LINE_CONTReturn 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
-
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: Returns: tuplecontaininglistof thicknessesdictwhere the keys are experiments (as defined byadd_experiment()) and the values arelistcontaining 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: Returns: tuplecontaininglistof energies in electronvoltsdictwhere the keys are experiments (as defined byadd_experiment()) and the values arelistcontaining k-ratios for each energy
-
compute_kratios()¶ Computes the k-ratios of the different experiments.
Returns: dictwhere the keys are experiments (as defined byadd_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: Returns: a
dictwhere 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)\)
- dll_path (