Usage
Explicit example scripts can be found here.
How to simulate a trace?
Through the pulsedjax.simulate_trace module artificial pulses as well as traces can be generated. This is fasciliated via the MakeTrace(MakePulse) class. Pulses can be defined via the predefined dataclasses GaussianAmplitude, LorentzianAmplitude, PolynomialPhase, SinusoidalPhase, RandomPhase and MultiPulse. In addition the CustomPulse can be used to provide an externally defined pulse.
from pulsedjax.simulate_trace import MakeTrace, GaussianAmplitude, PolynomialPhase
amp = GaussianAmplitude(1, 0.3, 0.1, 1)
phase = PolynomialPhase(0.3, (0,0,20,0))
mp = MakeTrace(N=1024, f_max=2)
time, frequency, pulse_t, pulse_f = mp.generate_pulse((amp, phase))
Using a pulse and user specified measurement parameters a trace can be calculated.
# method has to be replaced with the method name
theta, frequency, trace, spectra = mp.generate_method(time, frequency, pulse_t, pulse_f, ... )
How to run a retrieval?
All retrieval algorithm implementations follow the same pattern. During the class instantiation the measurement data and parameters as well as some or all algorithm parameters are provided.
from pulsedjax.method import algorithm
myalgorithm = algorithm(theta, frequency, trace, nonlinear_method, ... )
In addition measured spectra or a known gate pulse may optionally be provided.
myalgorithm.use_measured_spectrum(frequency_spectrum, spectrum_pulse, "pulse")
myalgorithm.use_measured_spectrum(frequency_spectrum, spectrum_gate_pulse, "gate")
myalgorithm.get_gate_pulse(frequency_gate, pulse_f_gate) # needs to be in frequency domain
Further algorithm parameters may be set via attributes or as described in Nonlinear Optimization.
An initial guess has to be created using myalgorithm.create_initial_guess(). Depending on the type of the algorithm the inputs to this function may differ. For a ClassicalAlgorithm the guess options are "random", "random_phase", "constant" and "constant_phase". For a GeneralAlgorithm different options can be specified for the spectral amplitude and phase. For the amplitude these are "gaussian" and "lorentizan". For the phase they are "polynomial", "sinusoidal" and "sigmoidal". The inputs "bsplines_k", "constinuous" and the inputs for ClassicalAlgorithms are available for both amplitude and phase. For B-Splines [1] the order is defined via k. So 5th-order B-Splines are defined as "bsplines_5".
# For a classical algorithm
population = myalgorithm.create_initial_guess(population_size, guess_type)
# For a general algorithm, no_funcs defines the number of basis functions
population = myalgorithm.create_initial_guess(population_size, amp_type, phase_type, no_funcs_amp, no_funcs_phase)
Finally, the retrieval is run via the myalgorithm.run() function. Parts of the returned object can be visalized via myalgorithm.plot_results().
final_result = myalgorithm.run(population, no_iterations)
myalgorithm.plot_results(final_result)