:mod:`ocelot.cpbd.io` ===================== .. py:module:: ocelot.cpbd.io Module Contents --------------- Functions ~~~~~~~~~ .. autoapisummary:: ocelot.cpbd.io.save_particle_array2npz ocelot.cpbd.io.load_particle_array_from_npz ocelot.cpbd.io.load_particle_array ocelot.cpbd.io.save_particle_array ocelot.cpbd.io.find_drifts ocelot.cpbd.io.find_objects ocelot.cpbd.io.create_var_name ocelot.cpbd.io.find_obj_and_create_name ocelot.cpbd.io.lat2input ocelot.cpbd.io.get_elements ocelot.cpbd.io.matrix_def_string ocelot.cpbd.io.element_def_string ocelot.cpbd.io.pprinting ocelot.cpbd.io.print_elements ocelot.cpbd.io.sort_elements ocelot.cpbd.io.elements2input ocelot.cpbd.io.cell2input ocelot.cpbd.io.twiss2input ocelot.cpbd.io.beam2input ocelot.cpbd.io.rem_drifts ocelot.cpbd.io.write_power_supply_id ocelot.cpbd.io.write_lattice .. data:: __author__ :annotation: = Sergey Tomin module contains lat2input function which creates python input string (ocelot lattice) for a lattice object author sergey.tomin .. function:: save_particle_array2npz(filename, p_array) .. function:: load_particle_array_from_npz(filename, print_params=False) Load beam file in npz format and return ParticleArray :param filename: :return: .. function:: load_particle_array(filename, print_params=False) Universal function to load beam file, *.ast (ASTRA), *.fmt1 (CSRTrack) or *.npz format Note that downloading ParticleArray from the astra file (.ast) and saving it back does not give the same distribution. The difference arises because the array of particles does not have a reference particle, and in this case the first particle is used as a reference. :param filename: path to file, filename.ast or filename.npz :return: ParticleArray .. function:: save_particle_array(filename, p_array) Universal function to save beam file, *.ast (ASTRA), *.fmt1 (CSRTrack) or *.npz format Note that downloading ParticleArray from the astra file (.ast) and saving it back does not give the same distribution. The difference arises because the array of particles does not have a reference particle, and in this case the first particle is used as a reference. :param filename: path to file, filename.ast or filename.npz :return: ParticleArray .. function:: find_drifts(lat) .. function:: find_objects(lat, types) Function finds objects by types and adds it to list if object is unique. :param lat: MagneticLattice :param types: types of the Elements :return: list of elements .. function:: create_var_name(objects) .. function:: find_obj_and_create_name(lat, types) .. function:: lat2input(lattice, tws0=None) returns python input string for the lattice in the lat object .. function:: get_elements(lattice) .. function:: matrix_def_string(element, params) .. function:: element_def_string(element) .. function:: pprinting(element, element_type, params) .. function:: print_elements(elements_dict) .. function:: sort_elements(elements) .. function:: elements2input(lattice) .. function:: cell2input(lattice, split=False) .. function:: twiss2input(tws) .. function:: beam2input(beam) .. function:: rem_drifts(lat) .. function:: write_power_supply_id(lattice, lines=[]) .. function:: write_lattice(lattice, tws0=None, file_name='lattice.py', remove_rep_drifts=True, power_supply=False) saves lattice as python imput file lattice - MagneticLattice file_name - name of the file remove_rep_drifts - if True, remove the drifts with the same lengths from the lattice drifts definition