helper module
Define misc helper functions.
Todo
Clean this, check what is still used.
- recursive_getter(wanted_key, dictionary, **kwargs)[source]
Get first key in a possibly nested dictionary.
- chunks(lst, n_size)[source]
Yield successive
n_size-ed chunks fromlst.https://stackoverflow.com/questions/312443/how-do-i-split-a-list-into-equally-sized-chunks
- remove_duplicates(iterable)[source]
Create an iterator without duplicates.
Taken from: https://stackoverflow.com/questions/32012878/iterator-object-for-removing-duplicates-in-python
- pascal_case(message)[source]
Convert a string to Pascal case (as class names).
Todo
Second example does not work
Examples
>>> pascal_case("bonjoure sa_vA") "BonjoureSaVa" >>> pascal_case("BonjoureSaVa") "BonjoureSaVa"
- get_constructor(name, constructors)[source]
Get the proper class from a string and dict of classes.
- resample(x_1, y_1, x_2, y_2)[source]
Downsample y_highres(olution) to x_1 or x_2 (the one with low res).
- save_energy_phase_tm(lin)[source]
Save energy, phase, transfer matrix as a function of s.
s [m] E[MeV] phi[rad] M_11 M_12 M_21 M_22
- save_vcav_and_phis(lin)[source]
Output the Vcav and phi_s as a function of z.
s [m] V_cav [MV] phi_s [deg]
- Parameters:
accelerator (Accelerator) – Object of corresponding to desired output.
lin (
object)
- Return type: