streaking

Submodules

streaking.base_classes_streaking module

streaking.base_classes_streaking.estimate_vectorpotential_max_scale(tau_arr, momentum_au, measured_trace)[source]

Approximates the max scale of the vectorpotential in the f-domain, based on the wiggles in the streaaking trace.

streaking.base_classes_streaking.normalize_population(population, measurement_info, descent_info, pulse_or_gate)[source]

Forstreaking the absolute scale of the vectorpotential is crucial. Thus it is not normalized but just rescaled if the scale grows out of bounds.

class streaking.base_classes_streaking.ClassicalAlgorithmsBASESTREAKING(*args, **kwargs)[source]

Bases: ClassicAlgorithmsBASE

The Base-Class for all classical solvers (e.g. Generalized Projection, …). Inherits from AlgorithmsBASE.

local_gamma

step size for local iterations

Type:

float

global_gamma

step size for global iterations

Type:

float

linesearch

enables/disables a linesearch. Can be False, backtracking or zoom.

Type:

bool, str

max_steps_linesearch

maximum number of linesearch steos

Type:

int

c1

constant for the Armijo-condition

Type:

float

c2

constant for the strong Wolfe-condition

Type:

float

delta_gamma

a factor which by which gamma is increased each iteration

Type:

float

local_newton

enables/disables the use of a hessian in local iterations. Can be False, lbfgs or diagonal.

Type:

bool, str

global_newton

enables/disables the use of a hessian in global iterations. Can be False, lbfgs, diagonal or full.

Type:

bool, str

lambda_lm

a Levenberg-Marquardt style damping coefficient.

Type:

float

lbfgs_memory

the number of past iterations to use in LBFGS

Type:

int

linalg_solver

chooses a library/method for inverting the hessian. Can be scipy, lineax or a specific lineax solver.

Type:

str, lineax-solver

conjugate_gradients

enables/diables the use of the Nonlinear Conjugate Gradients method. Can be False, Fletcher-Reeves, Hestenes-Stiefel, Dai-Yuan, Polak-Ribiere or average.

Type:

bool, str

r_local_method

chooses the method on the calculation of S_prime in local iterations. Can be projection or iteration.

Type:

str

r_global_method

chooses the method on the calculation of S_prime in global iterations. Can be projection or iteration.

Type:

str

r_gradient

if r_method=iteration, chooses the type of residual to optimize. Can be amplitude or intensity.

Type:

str

r_newton

enables/diables the use of the diagonal hessian if r_method=iteration

Type:

bool

r_no_iterations

the number of iterations if r_method=iteration

Type:

int

xi

a damping coefficient for adaptive step-sizes, avoids division by zero

Type:

float

local_adaptive_scaling

enables/disables adaptive step sized in local iterations. Can be one of False, pade_10 (linear), pade_20 (nonlinear), pade_11, pade_01 or pade_02

Type:

bool, str

global_adaptive_scaling

enables/disables adaptive step sized in global iterations. Can be one of False, pade_10 (linear), pade_20 (nonlinear), pade_11, pade_01 or pade_02

Type:

bool, str

momentum_is_being_used

what the name says

Type:

bool

normalize_after_every_step

what the name says, is usually True, but e.g. in attosecond streaking it needs to be False

Type:

bool

create_initial_population(population_size=1, guess_type='random')[source]

Creates an initial population of pulses, parametrized as complex values on a grid.

Parameters:
  • population_size (int) – the number of guesses to be optimized

  • guess_type (str) – Has to be one of random, random_phase, constant or constant_phase.

Returns:

tuple[jnp.array, jnp.array, jnp.array or None, jnp.array or None], initial populations for the pulse and possibly the gate-pulse in time domain or frequency domain for ChirpScans

class streaking.base_classes_streaking.GeneralizedProjectionBASESTREAKING(*args, **kwargs)[source]

Bases: ClassicalAlgorithmsBASESTREAKING, GeneralizedProjectionBASE

Implements the Generalized Projection Algorithm.

    1. DeLong et al., Opt. Lett. 19, 2152-2154 (1994)

no_steps_descent

the numer of descent steps per iteration

Type:

int

optimize_spectral_phase_directly
Type:

bool

do_descent_Z_error_step(descent_state, signal_t_new, measurement_info, descent_info)[source]

Does one Z-error descent step. Calls descent_Z_error_step for pulse and or gate.

class streaking.base_classes_streaking.COPRABASESTREAKING(*args, **kwargs)[source]

Bases: ClassicalAlgorithmsBASESTREAKING, COPRABASE

Implements a version of the Common Pulse Retrieval Algorithm (COPRA).

    1. Geib et al., Optica 6, 495-505 (2019)

local_iteration(descent_state, transform_arr_m, trace_line, measurement_info, descent_info)[source]

Peforms one local iteration. Calls do_iteration() with the appropriate (randomized) signal fields.

global_step(descent_state, measurement_info, descent_info)[source]

Performs one global iteration of the Common Pulse Retrieval Algorithm. This means the method updates the population once using all measured data at once.

Parameters:
  • descent_state (Pytree)

  • measurement_info (Pytree)

  • descent_info (Pytree)

Returns:

tuple[Pytree, jnp.array], the updated descent state and the current trace errors of the population.

class streaking.base_classes_streaking.GeneralOptimizationBASESTREAKING(*args, **kwargs)[source]

Bases: GeneralOptimizationBASE

The Base-Class for all general solvers. Inherits from AlgorithmsBASE.

error_metric

an arbitrary loss-function, needs to expect (trace, measured_trace) as input

Type:

Callable

create_initial_population(population_size, amp_type='gaussian', phase_type='polynomial', no_funcs_amp=5, no_funcs_phase=6)[source]

Creates an initial guess either explicit or parametrized. For bsplines one has to provide the B-Spline order k via bsplines_k

Parameters:
  • population_size (int) – the number of individuals

  • amp_type (str) – the representation of the spectral amplitude, can be one of gaussian, lorentzian, bsplines, continuous or an input for Classical Algorithms

  • phase_type (str) – the representation of the spectral phase, can be one of polynomial, sinusoidal, sigmoidal, bsplines, continuous or an input for Classical Algorithms

  • no_funcs_amp (int) – the number of basis functions for the spectral amplitude (only used if not on a grid)

  • no_funcs_phase (int) – the number of basis functions for the spectral phase (only used if not on grid)

Returns:

Pytree, the initial guess population

split_population_in_amp_and_phase(population)[source]

Splits a population into an amplitude and phase population.

merge_population_from_amp_and_phase(population_amp, population_phase)[source]

Undoes split_population_in_amp_and_phase()

get_pulses_f_from_population(population, measurement_info, descent_info)[source]

Evaluates a parametrized population onto the frequency axis.

class streaking.base_classes_streaking.DifferentialEvolutionBASESTREAKING(*args, strategy='best1_bin', selection_mechanism='greedy', mutation_rate=0.5, crossover_rate=0.7, **kwargs)[source]

Bases: GeneralOptimizationBASESTREAKING, DifferentialEvolutionBASE

Implements a Differential-Evolution Algorithm. Based on Qiang, J., Mitchell, C., A Unified Differential Evolution Algorithm for Global Optimization, 2014, https://www.osti.gov/servlets/purl/1163659

strategy

the mutation and selection strategy, analogous to scipy’s differential evolution.

Type:

str

mutation_rate

the mutation rate

Type:

float

crossover_rate

the crossover rate

Type:

float

selection_mechanism

the selection mechanism, can be greedy or global, defined in select_population().

Type:

str

temperature

a temperature value for the global selection mechanism

Type:

float

class streaking.base_classes_streaking.EvosaxBASESTREAKING(*args, solver=None, **kwargs)[source]

Bases: GeneralOptimizationBASESTREAKING, EvosaxBASE

Employs the evosax package to perform the optimization.

Robert Tjarko Lange, evosax: JAX-based Evolution Strategies, arXiv preprint arXiv:2212.04180 (2022)

solver

any evosax-solver should work

Type:

evosax-solver

solver_params

user defined parameters for the evosax-solver, if None the default params set in evosax are used

Type:

any

solver_kwargs

some evosax-solver require additional input arguments. These can be supplied via this aattribute.

Type:

dict

class streaking.base_classes_streaking.AutoDiffBASESTREAKING(*args, solver=None, **kwargs)[source]

Bases: GeneralOptimizationBASESTREAKING, AutoDiffBASE

Employs the optimistix package to perform the optimization via Automatic-Differentiation.

J. Rader, T. Lyons and P.Kidger, Optimistix: modular optimisation in JAX and Equinox, arXiv:2402.09983 (2024) DeepMind et al., The DeepMind JAX Ecosystem, http://github.com/google-deepmind (2020)

solver

solvers need to be initialized

Type:

optimistix-solver, optax-solver

alternating_optimization

if true, the optimizer alternates between amplitude and phase

Type:

bool

optimize_group_delay

if true, the group delay will be optimized instead of the spectral phase

Type:

bool

loss_function(individual, measurement_info, descent_info)[source]

Wraps around self.calculate_error_individual() to return the error of the current guess.

streaking.classical_algorithms_streaking module

class streaking.classical_algorithms_streaking.GeneralizedProjection(delay_fs, energy_eV, measured_trace, Ip_eV=Array([0], dtype=int32), retrieve_dtme=False, cross_correlation='doubleblind', interferometric=False, **kwargs)[source]

Bases: GeneralizedProjectionBASESTREAKING, RetrievePulsesSTREAKING

Implements the Generalized Projection Algorithm.

    1. DeLong et al., Opt. Lett. 19, 2152-2154 (1994)

no_steps_descent

the numer of descent steps per iteration

Type:

int

optimize_spectral_phase_directly
Type:

bool

calculate_Z_gradient_individual(signal_t, signal_t_new, tau_arr, measurement_info, pulse_or_gate)[source]

Calculates the Z-error gradient for an individual.

calculate_Z_newton_direction(grad, signal_t_new, signal_t, tau_arr, descent_state, measurement_info, descent_info, full_or_diagonal, pulse_or_gate)[source]

Calculates the Z-error newton direction for a population.

class streaking.classical_algorithms_streaking.COPRA(delay_fs, energy_eV, measured_trace, Ip_eV=Array([0], dtype=int32), retrieve_dtme=False, cross_correlation='doubleblind', interferometric=False, **kwargs)[source]

Bases: COPRABASESTREAKING, RetrievePulsesSTREAKING

Implements a version of the Common Pulse Retrieval Algorithm (COPRA).

    1. Geib et al., Optica 6, 495-505 (2019)

get_Z_gradient_individual(signal_t, signal_t_new, tau_arr, measurement_info, pulse_or_gate)[source]

Calculates the Z-error gradient for an individual.

get_Z_newton_direction(grad, signal_t, signal_t_new, tau_arr, local_or_global_state, measurement_info, descent_info, full_or_diagonal, pulse_or_gate)[source]

Calculates the Z-error newton direction for a population.

streaking.general_algorithms_streaking module

class streaking.general_algorithms_streaking.DifferentialEvolution(delay_fs, energy_eV, measured_trace, Ip_eV=Array([0], dtype=int32), retrieve_dtme=False, cross_correlation='doubleblind', interferometric=False, strategy='best1_bin', selection_mechanism='greedy', mutation_rate=0.5, crossover_rate=0.7, **kwargs)[source]

Bases: DifferentialEvolutionBASESTREAKING, RetrievePulsesSTREAKING

Implements a Differential-Evolution Algorithm. Based on Qiang, J., Mitchell, C., A Unified Differential Evolution Algorithm for Global Optimization, 2014, https://www.osti.gov/servlets/purl/1163659

strategy

the mutation and selection strategy, analogous to scipy’s differential evolution.

Type:

str

mutation_rate

the mutation rate

Type:

float

crossover_rate

the crossover rate

Type:

float

selection_mechanism

the selection mechanism, can be greedy or global, defined in select_population().

Type:

str

temperature

a temperature value for the global selection mechanism

Type:

float

class streaking.general_algorithms_streaking.Evosax(delay_fs, energy_eV, measured_trace, Ip_eV=Array([0], dtype=int32), retrieve_dtme=False, cross_correlation='doubleblind', interferometric=False, solver=None, **kwargs)[source]

Bases: EvosaxBASESTREAKING, RetrievePulsesSTREAKING

Employs the evosax package to perform the optimization.

Robert Tjarko Lange, evosax: JAX-based Evolution Strategies, arXiv preprint arXiv:2212.04180 (2022)

solver

any evosax-solver should work

Type:

evosax-solver

solver_params

user defined parameters for the evosax-solver, if None the default params set in evosax are used

Type:

any

solver_kwargs

some evosax-solver require additional input arguments. These can be supplied via this aattribute.

Type:

dict

class streaking.general_algorithms_streaking.AutoDiff(delay_fs, energy_eV, measured_trace, Ip_eV=Array([0], dtype=int32), retrieve_dtme=False, cross_correlation='doubleblind', interferometric=False, solver=None, **kwargs)[source]

Bases: AutoDiffBASESTREAKING, RetrievePulsesSTREAKING

Employs the optimistix package to perform the optimization via Automatic-Differentiation.

J. Rader, T. Lyons and P.Kidger, Optimistix: modular optimisation in JAX and Equinox, arXiv:2402.09983 (2024) DeepMind et al., The DeepMind JAX Ecosystem, http://github.com/google-deepmind (2020)

solver

solvers need to be initialized

Type:

optimistix-solver, optax-solver

alternating_optimization

if true, the optimizer alternates between amplitude and phase

Type:

bool

optimize_group_delay

if true, the group delay will be optimized instead of the spectral phase

Type:

bool

Module contents