xtrack 0.90.1__tar.gz → 0.92.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {xtrack-0.90.1/xtrack.egg-info → xtrack-0.92.0}/PKG-INFO +2 -1
- {xtrack-0.90.1 → xtrack-0.92.0}/setup.py +1 -1
- xtrack-0.92.0/tests/test_json.py +94 -0
- {xtrack-0.90.1 → xtrack-0.92.0}/tests/test_mad_writer.py +0 -1
- {xtrack-0.90.1 → xtrack-0.92.0}/tests/test_rbend_straight_body.py +59 -1
- {xtrack-0.90.1 → xtrack-0.92.0}/tests/test_twiss.py +1 -1
- xtrack-0.92.0/tests/test_twiss_to_file.py +88 -0
- {xtrack-0.90.1 → xtrack-0.92.0}/xtrack/__init__.py +2 -2
- xtrack-0.92.0/xtrack/_version.py +1 -0
- {xtrack-0.90.1 → xtrack-0.92.0}/xtrack/beam_elements/elements.py +4 -8
- {xtrack-0.90.1 → xtrack-0.92.0}/xtrack/environment.py +5 -5
- {xtrack-0.90.1 → xtrack-0.92.0}/xtrack/general.py +10 -3
- xtrack-0.92.0/xtrack/json.py +96 -0
- {xtrack-0.90.1 → xtrack-0.92.0}/xtrack/line.py +1 -0
- xtrack-0.92.0/xtrack/load.py +140 -0
- {xtrack-0.90.1 → xtrack-0.92.0}/xtrack/mad_parser/loader.py +5 -3
- {xtrack-0.90.1 → xtrack-0.92.0}/xtrack/mad_writer.py +6 -1
- xtrack-0.92.0/xtrack/prebuilt_kernel_definitions/__init__.py +7 -0
- xtrack-0.92.0/xtrack/prebuilt_kernel_definitions/element_inits.py +38 -0
- xtrack-0.92.0/xtrack/prebuilt_kernel_definitions/element_types.py +114 -0
- {xtrack-0.90.1 → xtrack-0.92.0}/xtrack/survey.py +1 -2
- xtrack-0.92.0/xtrack/table.py +1604 -0
- {xtrack-0.90.1 → xtrack-0.92.0}/xtrack/twiss.py +61 -7
- {xtrack-0.90.1 → xtrack-0.92.0/xtrack.egg-info}/PKG-INFO +2 -1
- {xtrack-0.90.1 → xtrack-0.92.0}/xtrack.egg-info/SOURCES.txt +6 -0
- {xtrack-0.90.1 → xtrack-0.92.0}/xtrack.egg-info/requires.txt +1 -0
- xtrack-0.90.1/xtrack/_version.py +0 -1
- xtrack-0.90.1/xtrack/json.py +0 -48
- xtrack-0.90.1/xtrack/load.py +0 -68
- {xtrack-0.90.1 → xtrack-0.92.0}/LICENSE +0 -0
- {xtrack-0.90.1 → xtrack-0.92.0}/MANIFEST.in +0 -0
- {xtrack-0.90.1 → xtrack-0.92.0}/README.md +0 -0
- {xtrack-0.90.1 → xtrack-0.92.0}/ducktrack/__init__.py +0 -0
- {xtrack-0.90.1 → xtrack-0.92.0}/ducktrack/base_classes.py +0 -0
- {xtrack-0.90.1 → xtrack-0.92.0}/ducktrack/be_beamfields/BB6D.py +0 -0
- {xtrack-0.90.1 → xtrack-0.92.0}/ducktrack/be_beamfields/BB6Ddata.py +0 -0
- {xtrack-0.90.1 → xtrack-0.92.0}/ducktrack/be_beamfields/__init__.py +0 -0
- {xtrack-0.90.1 → xtrack-0.92.0}/ducktrack/be_beamfields/beambeam.py +0 -0
- {xtrack-0.90.1 → xtrack-0.92.0}/ducktrack/be_beamfields/boost.py +0 -0
- {xtrack-0.90.1 → xtrack-0.92.0}/ducktrack/be_beamfields/gaussian_fields.py +0 -0
- {xtrack-0.90.1 → xtrack-0.92.0}/ducktrack/be_beamfields/propagate_sigma_matrix.py +0 -0
- {xtrack-0.90.1 → xtrack-0.92.0}/ducktrack/be_beamfields/qgauss.py +0 -0
- {xtrack-0.90.1 → xtrack-0.92.0}/ducktrack/be_beamfields/slicing.py +0 -0
- {xtrack-0.90.1 → xtrack-0.92.0}/ducktrack/be_beamfields/spacecharge.py +0 -0
- {xtrack-0.90.1 → xtrack-0.92.0}/ducktrack/elements.py +0 -0
- {xtrack-0.90.1 → xtrack-0.92.0}/ducktrack/line.py +0 -0
- {xtrack-0.90.1 → xtrack-0.92.0}/ducktrack/mathlibs.py +0 -0
- {xtrack-0.90.1 → xtrack-0.92.0}/ducktrack/particles.py +0 -0
- {xtrack-0.90.1 → xtrack-0.92.0}/ducktrack/temp_pyparticles.py +0 -0
- {xtrack-0.90.1 → xtrack-0.92.0}/pyproject.toml +0 -0
- {xtrack-0.90.1 → xtrack-0.92.0}/setup.cfg +0 -0
- {xtrack-0.90.1 → xtrack-0.92.0}/tests/test_acceleration.py +0 -0
- {xtrack-0.90.1 → xtrack-0.92.0}/tests/test_amplitude_detuning.py +0 -0
- {xtrack-0.90.1 → xtrack-0.92.0}/tests/test_aperture_table.py +0 -0
- {xtrack-0.90.1 → xtrack-0.92.0}/tests/test_aperture_turn_ele_and_monitor.py +0 -0
- {xtrack-0.90.1 → xtrack-0.92.0}/tests/test_apertures.py +0 -0
- {xtrack-0.90.1 → xtrack-0.92.0}/tests/test_attr_replicas_and_slices.py +0 -0
- {xtrack-0.90.1 → xtrack-0.92.0}/tests/test_bucket_with_ref_energy_change.py +0 -0
- {xtrack-0.90.1 → xtrack-0.92.0}/tests/test_cavity_absolute_time.py +0 -0
- {xtrack-0.90.1 → xtrack-0.92.0}/tests/test_chromatic_functions_vs_madx.py +0 -0
- {xtrack-0.90.1 → xtrack-0.92.0}/tests/test_coasting.py +0 -0
- {xtrack-0.90.1 → xtrack-0.92.0}/tests/test_collective_tracker.py +0 -0
- {xtrack-0.90.1 → xtrack-0.92.0}/tests/test_collimation.py +0 -0
- {xtrack-0.90.1 → xtrack-0.92.0}/tests/test_coupling_edwards_teng.py +0 -0
- {xtrack-0.90.1 → xtrack-0.92.0}/tests/test_electron_cooler.py +0 -0
- {xtrack-0.90.1 → xtrack-0.92.0}/tests/test_element_characterization_functions.py +0 -0
- {xtrack-0.90.1 → xtrack-0.92.0}/tests/test_element_internal_record.py +0 -0
- {xtrack-0.90.1 → xtrack-0.92.0}/tests/test_elements.py +0 -0
- {xtrack-0.90.1 → xtrack-0.92.0}/tests/test_elements_classflags.py +0 -0
- {xtrack-0.90.1 → xtrack-0.92.0}/tests/test_elements_thick.py +0 -0
- {xtrack-0.90.1 → xtrack-0.92.0}/tests/test_environment.py +0 -0
- {xtrack-0.90.1 → xtrack-0.92.0}/tests/test_fcc_ee_solenoid_correction.py +0 -0
- {xtrack-0.90.1 → xtrack-0.92.0}/tests/test_fcc_ee_solenoid_correction_new_optimize_api.py +0 -0
- {xtrack-0.90.1 → xtrack-0.92.0}/tests/test_footprint.py +0 -0
- {xtrack-0.90.1 → xtrack-0.92.0}/tests/test_freeze_longitudinal.py +0 -0
- {xtrack-0.90.1 → xtrack-0.92.0}/tests/test_full_rings.py +0 -0
- {xtrack-0.90.1 → xtrack-0.92.0}/tests/test_h6_sps_beamline.py +0 -0
- {xtrack-0.90.1 → xtrack-0.92.0}/tests/test_hvkick.py +0 -0
- {xtrack-0.90.1 → xtrack-0.92.0}/tests/test_ions.py +0 -0
- {xtrack-0.90.1 → xtrack-0.92.0}/tests/test_legacy_multiline_to_env.py +0 -0
- {xtrack-0.90.1 → xtrack-0.92.0}/tests/test_lhc_env.py +0 -0
- {xtrack-0.90.1 → xtrack-0.92.0}/tests/test_lhc_match_phase_15.py +0 -0
- {xtrack-0.90.1 → xtrack-0.92.0}/tests/test_line.py +0 -0
- {xtrack-0.90.1 → xtrack-0.92.0}/tests/test_load.py +0 -0
- {xtrack-0.90.1 → xtrack-0.92.0}/tests/test_load_vars.py +0 -0
- {xtrack-0.90.1 → xtrack-0.92.0}/tests/test_lumi.py +0 -0
- {xtrack-0.90.1 → xtrack-0.92.0}/tests/test_madloader.py +0 -0
- {xtrack-0.90.1 → xtrack-0.92.0}/tests/test_madnginterface.py +0 -0
- {xtrack-0.90.1 → xtrack-0.92.0}/tests/test_magnet.py +0 -0
- {xtrack-0.90.1 → xtrack-0.92.0}/tests/test_match_and_track_from_element.py +0 -0
- {xtrack-0.90.1 → xtrack-0.92.0}/tests/test_match_coupling_knob.py +0 -0
- {xtrack-0.90.1 → xtrack-0.92.0}/tests/test_match_nested.py +0 -0
- {xtrack-0.90.1 → xtrack-0.92.0}/tests/test_match_optics_and_ip_knob.py +0 -0
- {xtrack-0.90.1 → xtrack-0.92.0}/tests/test_match_optics_and_ip_knob_new_optimize_api.py +0 -0
- {xtrack-0.90.1 → xtrack-0.92.0}/tests/test_match_orbit_bump.py +0 -0
- {xtrack-0.90.1 → xtrack-0.92.0}/tests/test_match_tune_chroma_cminus.py +0 -0
- {xtrack-0.90.1 → xtrack-0.92.0}/tests/test_misalign.py +0 -0
- {xtrack-0.90.1 → xtrack-0.92.0}/tests/test_monitor.py +0 -0
- {xtrack-0.90.1 → xtrack-0.92.0}/tests/test_multi_bunch_gauss.py +0 -0
- {xtrack-0.90.1 → xtrack-0.92.0}/tests/test_multiline.py +0 -0
- {xtrack-0.90.1 → xtrack-0.92.0}/tests/test_multisetter.py +0 -0
- {xtrack-0.90.1 → xtrack-0.92.0}/tests/test_multispecies.py +0 -0
- {xtrack-0.90.1 → xtrack-0.92.0}/tests/test_native_madloader.py +0 -0
- {xtrack-0.90.1 → xtrack-0.92.0}/tests/test_optimize_for_tracking.py +0 -0
- {xtrack-0.90.1 → xtrack-0.92.0}/tests/test_particles.py +0 -0
- {xtrack-0.90.1 → xtrack-0.92.0}/tests/test_particles_basics.py +0 -0
- {xtrack-0.90.1 → xtrack-0.92.0}/tests/test_particles_pdg.py +0 -0
- {xtrack-0.90.1 → xtrack-0.92.0}/tests/test_pipeline.py +0 -0
- {xtrack-0.90.1 → xtrack-0.92.0}/tests/test_prebuild_kernels.py +0 -0
- {xtrack-0.90.1 → xtrack-0.92.0}/tests/test_ps_against_ptc.py +0 -0
- {xtrack-0.90.1 → xtrack-0.92.0}/tests/test_ps_multiturn_twiss.py +0 -0
- {xtrack-0.90.1 → xtrack-0.92.0}/tests/test_psb_chicane.py +0 -0
- {xtrack-0.90.1 → xtrack-0.92.0}/tests/test_pyht_interface.py +0 -0
- {xtrack-0.90.1 → xtrack-0.92.0}/tests/test_quadrupole_fringe_ptc.py +0 -0
- {xtrack-0.90.1 → xtrack-0.92.0}/tests/test_quadrupole_wedge.py +0 -0
- {xtrack-0.90.1 → xtrack-0.92.0}/tests/test_radial_steering.py +0 -0
- {xtrack-0.90.1 → xtrack-0.92.0}/tests/test_radiation.py +0 -0
- {xtrack-0.90.1 → xtrack-0.92.0}/tests/test_radiation_equilibrium_emittances.py +0 -0
- {xtrack-0.90.1 → xtrack-0.92.0}/tests/test_radiation_equilibrium_emittances_thick.py +0 -0
- {xtrack-0.90.1 → xtrack-0.92.0}/tests/test_radiation_integrals.py +0 -0
- {xtrack-0.90.1 → xtrack-0.92.0}/tests/test_random_gen.py +0 -0
- {xtrack-0.90.1 → xtrack-0.92.0}/tests/test_random_gen_exp.py +0 -0
- {xtrack-0.90.1 → xtrack-0.92.0}/tests/test_random_gen_gauss.py +0 -0
- {xtrack-0.90.1 → xtrack-0.92.0}/tests/test_random_gen_ruth.py +0 -0
- {xtrack-0.90.1 → xtrack-0.92.0}/tests/test_rbend_rbarc.py +0 -0
- {xtrack-0.90.1 → xtrack-0.92.0}/tests/test_rf_track.py +0 -0
- {xtrack-0.90.1 → xtrack-0.92.0}/tests/test_rotation_signs.py +0 -0
- {xtrack-0.90.1 → xtrack-0.92.0}/tests/test_second_order_taylor_map.py +0 -0
- {xtrack-0.90.1 → xtrack-0.92.0}/tests/test_seeds.py +0 -0
- {xtrack-0.90.1 → xtrack-0.92.0}/tests/test_slice_and_insert_with_replicas.py +0 -0
- {xtrack-0.90.1 → xtrack-0.92.0}/tests/test_slice_elements.py +0 -0
- {xtrack-0.90.1 → xtrack-0.92.0}/tests/test_slicing.py +0 -0
- {xtrack-0.90.1 → xtrack-0.92.0}/tests/test_solenoid_bz_map_vs_boris.py +0 -0
- {xtrack-0.90.1 → xtrack-0.92.0}/tests/test_solenoid_bz_map_vs_boris_legacy.py +0 -0
- {xtrack-0.90.1 → xtrack-0.92.0}/tests/test_spacecharge_in_ring.py +0 -0
- {xtrack-0.90.1 → xtrack-0.92.0}/tests/test_spin.py +0 -0
- {xtrack-0.90.1 → xtrack-0.92.0}/tests/test_sps_thick.py +0 -0
- {xtrack-0.90.1 → xtrack-0.92.0}/tests/test_survey.py +0 -0
- {xtrack-0.90.1 → xtrack-0.92.0}/tests/test_tapering.py +0 -0
- {xtrack-0.90.1 → xtrack-0.92.0}/tests/test_thick_kickers_rf_crab.py +0 -0
- {xtrack-0.90.1 → xtrack-0.92.0}/tests/test_thick_lhc.py +0 -0
- {xtrack-0.90.1 → xtrack-0.92.0}/tests/test_tilt_shifts.py +0 -0
- {xtrack-0.90.1 → xtrack-0.92.0}/tests/test_tracker.py +0 -0
- {xtrack-0.90.1 → xtrack-0.92.0}/tests/test_trajectory_correcton.py +0 -0
- {xtrack-0.90.1 → xtrack-0.92.0}/tests/test_twiss_vs_madx_psb.py +0 -0
- {xtrack-0.90.1 → xtrack-0.92.0}/tests/test_vs_madx.py +0 -0
- {xtrack-0.90.1 → xtrack-0.92.0}/tests/test_xmask_orbit_correction.py +0 -0
- {xtrack-0.90.1 → xtrack-0.92.0}/xtrack/_temp/__init__.py +0 -0
- {xtrack-0.90.1 → xtrack-0.92.0}/xtrack/_temp/boris_and_solenoid_map/__init__.py +0 -0
- {xtrack-0.90.1 → xtrack-0.92.0}/xtrack/_temp/boris_and_solenoid_map/boris.h +0 -0
- {xtrack-0.90.1 → xtrack-0.92.0}/xtrack/_temp/boris_and_solenoid_map/solenoid_field.py +0 -0
- {xtrack-0.90.1 → xtrack-0.92.0}/xtrack/_temp/lhc_match/__init__.py +0 -0
- {xtrack-0.90.1 → xtrack-0.92.0}/xtrack/_temp/lhc_match/gen_madx_optics_file.py +0 -0
- {xtrack-0.90.1 → xtrack-0.92.0}/xtrack/_temp/lhc_match/lhc_match.py +0 -0
- {xtrack-0.90.1 → xtrack-0.92.0}/xtrack/_temp/lhc_match/var_limits.py +0 -0
- {xtrack-0.90.1 → xtrack-0.92.0}/xtrack/aperture_meas.py +0 -0
- {xtrack-0.90.1 → xtrack-0.92.0}/xtrack/base_element.py +0 -0
- {xtrack-0.90.1 → xtrack-0.92.0}/xtrack/beam_elements/__init__.py +0 -0
- {xtrack-0.90.1 → xtrack-0.92.0}/xtrack/beam_elements/apertures.py +0 -0
- {xtrack-0.90.1 → xtrack-0.92.0}/xtrack/beam_elements/apertures_src/limitellipse.h +0 -0
- {xtrack-0.90.1 → xtrack-0.92.0}/xtrack/beam_elements/apertures_src/limitpolygon.h +0 -0
- {xtrack-0.90.1 → xtrack-0.92.0}/xtrack/beam_elements/apertures_src/limitracetrack.h +0 -0
- {xtrack-0.90.1 → xtrack-0.92.0}/xtrack/beam_elements/apertures_src/limitrect.h +0 -0
- {xtrack-0.90.1 → xtrack-0.92.0}/xtrack/beam_elements/apertures_src/limitrectellipse.h +0 -0
- {xtrack-0.90.1 → xtrack-0.92.0}/xtrack/beam_elements/apertures_src/longitudinallimitrect.h +0 -0
- {xtrack-0.90.1 → xtrack-0.92.0}/xtrack/beam_elements/beam_interaction.py +0 -0
- {xtrack-0.90.1 → xtrack-0.92.0}/xtrack/beam_elements/elements_src/bend.h +0 -0
- {xtrack-0.90.1 → xtrack-0.92.0}/xtrack/beam_elements/elements_src/cavity.h +0 -0
- {xtrack-0.90.1 → xtrack-0.92.0}/xtrack/beam_elements/elements_src/crab_cavity.h +0 -0
- {xtrack-0.90.1 → xtrack-0.92.0}/xtrack/beam_elements/elements_src/default_magnet_config.h +0 -0
- {xtrack-0.90.1 → xtrack-0.92.0}/xtrack/beam_elements/elements_src/dipole_fringe.h +0 -0
- {xtrack-0.90.1 → xtrack-0.92.0}/xtrack/beam_elements/elements_src/dipoleedge.h +0 -0
- {xtrack-0.90.1 → xtrack-0.92.0}/xtrack/beam_elements/elements_src/drift.h +0 -0
- {xtrack-0.90.1 → xtrack-0.92.0}/xtrack/beam_elements/elements_src/drift_exact.h +0 -0
- {xtrack-0.90.1 → xtrack-0.92.0}/xtrack/beam_elements/elements_src/drift_exact_slice.h +0 -0
- {xtrack-0.90.1 → xtrack-0.92.0}/xtrack/beam_elements/elements_src/drift_slice.h +0 -0
- {xtrack-0.90.1 → xtrack-0.92.0}/xtrack/beam_elements/elements_src/drift_slice_bend.h +0 -0
- {xtrack-0.90.1 → xtrack-0.92.0}/xtrack/beam_elements/elements_src/drift_slice_cavity.h +0 -0
- {xtrack-0.90.1 → xtrack-0.92.0}/xtrack/beam_elements/elements_src/drift_slice_crab_cavity.h +0 -0
- {xtrack-0.90.1 → xtrack-0.92.0}/xtrack/beam_elements/elements_src/drift_slice_multipole.h +0 -0
- {xtrack-0.90.1 → xtrack-0.92.0}/xtrack/beam_elements/elements_src/drift_slice_octupole.h +0 -0
- {xtrack-0.90.1 → xtrack-0.92.0}/xtrack/beam_elements/elements_src/drift_slice_quadrupole.h +0 -0
- {xtrack-0.90.1 → xtrack-0.92.0}/xtrack/beam_elements/elements_src/drift_slice_rbend.h +0 -0
- {xtrack-0.90.1 → xtrack-0.92.0}/xtrack/beam_elements/elements_src/drift_slice_sextupole.h +0 -0
- {xtrack-0.90.1 → xtrack-0.92.0}/xtrack/beam_elements/elements_src/drift_slice_uniform_solenoid.h +0 -0
- {xtrack-0.90.1 → xtrack-0.92.0}/xtrack/beam_elements/elements_src/electroncooler.h +0 -0
- {xtrack-0.90.1 → xtrack-0.92.0}/xtrack/beam_elements/elements_src/elens.h +0 -0
- {xtrack-0.90.1 → xtrack-0.92.0}/xtrack/beam_elements/elements_src/exciter.h +0 -0
- {xtrack-0.90.1 → xtrack-0.92.0}/xtrack/beam_elements/elements_src/firstordertaylormap.h +0 -0
- {xtrack-0.90.1 → xtrack-0.92.0}/xtrack/beam_elements/elements_src/legacy_solenoid.h +0 -0
- {xtrack-0.90.1 → xtrack-0.92.0}/xtrack/beam_elements/elements_src/linesegmentmap.h +0 -0
- {xtrack-0.90.1 → xtrack-0.92.0}/xtrack/beam_elements/elements_src/magnet.h +0 -0
- {xtrack-0.90.1 → xtrack-0.92.0}/xtrack/beam_elements/elements_src/magnet_drift.h +0 -0
- {xtrack-0.90.1 → xtrack-0.92.0}/xtrack/beam_elements/elements_src/magnet_edge.h +0 -0
- {xtrack-0.90.1 → xtrack-0.92.0}/xtrack/beam_elements/elements_src/magnet_kick.h +0 -0
- {xtrack-0.90.1 → xtrack-0.92.0}/xtrack/beam_elements/elements_src/marker.h +0 -0
- {xtrack-0.90.1 → xtrack-0.92.0}/xtrack/beam_elements/elements_src/misalignment.h +0 -0
- {xtrack-0.90.1 → xtrack-0.92.0}/xtrack/beam_elements/elements_src/multipole.h +0 -0
- {xtrack-0.90.1 → xtrack-0.92.0}/xtrack/beam_elements/elements_src/multipoleedge.h +0 -0
- {xtrack-0.90.1 → xtrack-0.92.0}/xtrack/beam_elements/elements_src/nonlinearlens.h +0 -0
- {xtrack-0.90.1 → xtrack-0.92.0}/xtrack/beam_elements/elements_src/octupole.h +0 -0
- {xtrack-0.90.1 → xtrack-0.92.0}/xtrack/beam_elements/elements_src/quadrupole.h +0 -0
- {xtrack-0.90.1 → xtrack-0.92.0}/xtrack/beam_elements/elements_src/rbend.h +0 -0
- {xtrack-0.90.1 → xtrack-0.92.0}/xtrack/beam_elements/elements_src/referenceenergyincrease.h +0 -0
- {xtrack-0.90.1 → xtrack-0.92.0}/xtrack/beam_elements/elements_src/rfmultipole.h +0 -0
- {xtrack-0.90.1 → xtrack-0.92.0}/xtrack/beam_elements/elements_src/second_order_taylor_map.h +0 -0
- {xtrack-0.90.1 → xtrack-0.92.0}/xtrack/beam_elements/elements_src/sextupole.h +0 -0
- {xtrack-0.90.1 → xtrack-0.92.0}/xtrack/beam_elements/elements_src/simplethinbend.h +0 -0
- {xtrack-0.90.1 → xtrack-0.92.0}/xtrack/beam_elements/elements_src/simplethinquadrupole.h +0 -0
- {xtrack-0.90.1 → xtrack-0.92.0}/xtrack/beam_elements/elements_src/slnd.h +0 -0
- {xtrack-0.90.1 → xtrack-0.92.0}/xtrack/beam_elements/elements_src/srotation.h +0 -0
- {xtrack-0.90.1 → xtrack-0.92.0}/xtrack/beam_elements/elements_src/temprf.h +0 -0
- {xtrack-0.90.1 → xtrack-0.92.0}/xtrack/beam_elements/elements_src/thick_slice_bend.h +0 -0
- {xtrack-0.90.1 → xtrack-0.92.0}/xtrack/beam_elements/elements_src/thick_slice_cavity.h +0 -0
- {xtrack-0.90.1 → xtrack-0.92.0}/xtrack/beam_elements/elements_src/thick_slice_crab_cavity.h +0 -0
- {xtrack-0.90.1 → xtrack-0.92.0}/xtrack/beam_elements/elements_src/thick_slice_multipole.h +0 -0
- {xtrack-0.90.1 → xtrack-0.92.0}/xtrack/beam_elements/elements_src/thick_slice_octupole.h +0 -0
- {xtrack-0.90.1 → xtrack-0.92.0}/xtrack/beam_elements/elements_src/thick_slice_quadrupole.h +0 -0
- {xtrack-0.90.1 → xtrack-0.92.0}/xtrack/beam_elements/elements_src/thick_slice_rbend.h +0 -0
- {xtrack-0.90.1 → xtrack-0.92.0}/xtrack/beam_elements/elements_src/thick_slice_sextupole.h +0 -0
- {xtrack-0.90.1 → xtrack-0.92.0}/xtrack/beam_elements/elements_src/thick_slice_uniform_solenoid.h +0 -0
- {xtrack-0.90.1 → xtrack-0.92.0}/xtrack/beam_elements/elements_src/thin_slice_bend.h +0 -0
- {xtrack-0.90.1 → xtrack-0.92.0}/xtrack/beam_elements/elements_src/thin_slice_bend_entry.h +0 -0
- {xtrack-0.90.1 → xtrack-0.92.0}/xtrack/beam_elements/elements_src/thin_slice_bend_exit.h +0 -0
- {xtrack-0.90.1 → xtrack-0.92.0}/xtrack/beam_elements/elements_src/thin_slice_cavity.h +0 -0
- {xtrack-0.90.1 → xtrack-0.92.0}/xtrack/beam_elements/elements_src/thin_slice_crab_cavity.h +0 -0
- {xtrack-0.90.1 → xtrack-0.92.0}/xtrack/beam_elements/elements_src/thin_slice_multipole.h +0 -0
- {xtrack-0.90.1 → xtrack-0.92.0}/xtrack/beam_elements/elements_src/thin_slice_octupole.h +0 -0
- {xtrack-0.90.1 → xtrack-0.92.0}/xtrack/beam_elements/elements_src/thin_slice_octupole_entry.h +0 -0
- {xtrack-0.90.1 → xtrack-0.92.0}/xtrack/beam_elements/elements_src/thin_slice_octupole_exit.h +0 -0
- {xtrack-0.90.1 → xtrack-0.92.0}/xtrack/beam_elements/elements_src/thin_slice_quadrupole.h +0 -0
- {xtrack-0.90.1 → xtrack-0.92.0}/xtrack/beam_elements/elements_src/thin_slice_quadrupole_entry.h +0 -0
- {xtrack-0.90.1 → xtrack-0.92.0}/xtrack/beam_elements/elements_src/thin_slice_quadrupole_exit.h +0 -0
- {xtrack-0.90.1 → xtrack-0.92.0}/xtrack/beam_elements/elements_src/thin_slice_rbend.h +0 -0
- {xtrack-0.90.1 → xtrack-0.92.0}/xtrack/beam_elements/elements_src/thin_slice_rbend_entry.h +0 -0
- {xtrack-0.90.1 → xtrack-0.92.0}/xtrack/beam_elements/elements_src/thin_slice_rbend_exit.h +0 -0
- {xtrack-0.90.1 → xtrack-0.92.0}/xtrack/beam_elements/elements_src/thin_slice_sextupole.h +0 -0
- {xtrack-0.90.1 → xtrack-0.92.0}/xtrack/beam_elements/elements_src/thin_slice_sextupole_entry.h +0 -0
- {xtrack-0.90.1 → xtrack-0.92.0}/xtrack/beam_elements/elements_src/thin_slice_sextupole_exit.h +0 -0
- {xtrack-0.90.1 → xtrack-0.92.0}/xtrack/beam_elements/elements_src/thin_slice_uniform_solenoid_entry.h +0 -0
- {xtrack-0.90.1 → xtrack-0.92.0}/xtrack/beam_elements/elements_src/thin_slice_uniform_solenoid_exit.h +0 -0
- {xtrack-0.90.1 → xtrack-0.92.0}/xtrack/beam_elements/elements_src/track_dipole_edge_linear.h +0 -0
- {xtrack-0.90.1 → xtrack-0.92.0}/xtrack/beam_elements/elements_src/track_dipole_edge_nonlinear.h +0 -0
- {xtrack-0.90.1 → xtrack-0.92.0}/xtrack/beam_elements/elements_src/track_dipole_fringe.h +0 -0
- {xtrack-0.90.1 → xtrack-0.92.0}/xtrack/beam_elements/elements_src/track_drift.h +0 -0
- {xtrack-0.90.1 → xtrack-0.92.0}/xtrack/beam_elements/elements_src/track_legacy_solenoid.h +0 -0
- {xtrack-0.90.1 → xtrack-0.92.0}/xtrack/beam_elements/elements_src/track_legacy_solenoid_multipolar_components.h +0 -0
- {xtrack-0.90.1 → xtrack-0.92.0}/xtrack/beam_elements/elements_src/track_legacy_solenoid_radiation.h +0 -0
- {xtrack-0.90.1 → xtrack-0.92.0}/xtrack/beam_elements/elements_src/track_magnet.h +0 -0
- {xtrack-0.90.1 → xtrack-0.92.0}/xtrack/beam_elements/elements_src/track_magnet.template.h +0 -0
- {xtrack-0.90.1 → xtrack-0.92.0}/xtrack/beam_elements/elements_src/track_magnet_configure.h +0 -0
- {xtrack-0.90.1 → xtrack-0.92.0}/xtrack/beam_elements/elements_src/track_magnet_drift.h +0 -0
- {xtrack-0.90.1 → xtrack-0.92.0}/xtrack/beam_elements/elements_src/track_magnet_edge.h +0 -0
- {xtrack-0.90.1 → xtrack-0.92.0}/xtrack/beam_elements/elements_src/track_magnet_kick.h +0 -0
- {xtrack-0.90.1 → xtrack-0.92.0}/xtrack/beam_elements/elements_src/track_magnet_radiation.h +0 -0
- {xtrack-0.90.1 → xtrack-0.92.0}/xtrack/beam_elements/elements_src/track_misalignments.h +0 -0
- {xtrack-0.90.1 → xtrack-0.92.0}/xtrack/beam_elements/elements_src/track_mult_fringe.h +0 -0
- {xtrack-0.90.1 → xtrack-0.92.0}/xtrack/beam_elements/elements_src/track_rf.h +0 -0
- {xtrack-0.90.1 → xtrack-0.92.0}/xtrack/beam_elements/elements_src/track_rf.template.h +0 -0
- {xtrack-0.90.1 → xtrack-0.92.0}/xtrack/beam_elements/elements_src/track_srotation.h +0 -0
- {xtrack-0.90.1 → xtrack-0.92.0}/xtrack/beam_elements/elements_src/track_thick_bend.h +0 -0
- {xtrack-0.90.1 → xtrack-0.92.0}/xtrack/beam_elements/elements_src/track_thick_cfd.h +0 -0
- {xtrack-0.90.1 → xtrack-0.92.0}/xtrack/beam_elements/elements_src/track_wedge.h +0 -0
- {xtrack-0.90.1 → xtrack-0.92.0}/xtrack/beam_elements/elements_src/track_xrotation.h +0 -0
- {xtrack-0.90.1 → xtrack-0.92.0}/xtrack/beam_elements/elements_src/track_xyshift.h +0 -0
- {xtrack-0.90.1 → xtrack-0.92.0}/xtrack/beam_elements/elements_src/track_yrotation.h +0 -0
- {xtrack-0.90.1 → xtrack-0.92.0}/xtrack/beam_elements/elements_src/variable_solenoid.h +0 -0
- {xtrack-0.90.1 → xtrack-0.92.0}/xtrack/beam_elements/elements_src/wedge.h +0 -0
- {xtrack-0.90.1 → xtrack-0.92.0}/xtrack/beam_elements/elements_src/wire.h +0 -0
- {xtrack-0.90.1 → xtrack-0.92.0}/xtrack/beam_elements/elements_src/xrotation.h +0 -0
- {xtrack-0.90.1 → xtrack-0.92.0}/xtrack/beam_elements/elements_src/xyshift.h +0 -0
- {xtrack-0.90.1 → xtrack-0.92.0}/xtrack/beam_elements/elements_src/yrotation.h +0 -0
- {xtrack-0.90.1 → xtrack-0.92.0}/xtrack/beam_elements/elements_src/zetashift.h +0 -0
- {xtrack-0.90.1 → xtrack-0.92.0}/xtrack/beam_elements/exciter.py +0 -0
- {xtrack-0.90.1 → xtrack-0.92.0}/xtrack/beam_elements/rft_element.py +0 -0
- {xtrack-0.90.1 → xtrack-0.92.0}/xtrack/beam_elements/slice_base.py +0 -0
- {xtrack-0.90.1 → xtrack-0.92.0}/xtrack/beam_elements/slice_elements_drift.py +0 -0
- {xtrack-0.90.1 → xtrack-0.92.0}/xtrack/beam_elements/slice_elements_edge.py +0 -0
- {xtrack-0.90.1 → xtrack-0.92.0}/xtrack/beam_elements/slice_elements_thick.py +0 -0
- {xtrack-0.90.1 → xtrack-0.92.0}/xtrack/beam_elements/slice_elements_thin.py +0 -0
- {xtrack-0.90.1 → xtrack-0.92.0}/xtrack/footprint.py +0 -0
- {xtrack-0.90.1 → xtrack-0.92.0}/xtrack/functions.py +0 -0
- {xtrack-0.90.1 → xtrack-0.92.0}/xtrack/headers/atomicadd.h +0 -0
- {xtrack-0.90.1 → xtrack-0.92.0}/xtrack/headers/checks.h +0 -0
- {xtrack-0.90.1 → xtrack-0.92.0}/xtrack/headers/constants.h +0 -0
- {xtrack-0.90.1 → xtrack-0.92.0}/xtrack/headers/particle_states.h +0 -0
- {xtrack-0.90.1 → xtrack-0.92.0}/xtrack/headers/synrad_spectrum.h +0 -0
- {xtrack-0.90.1 → xtrack-0.92.0}/xtrack/headers/track.h +0 -0
- {xtrack-0.90.1 → xtrack-0.92.0}/xtrack/internal_record.py +0 -0
- {xtrack-0.90.1 → xtrack-0.92.0}/xtrack/linear_normal_form.py +0 -0
- {xtrack-0.90.1 → xtrack-0.92.0}/xtrack/loss_location_refinement/__init__.py +0 -0
- {xtrack-0.90.1 → xtrack-0.92.0}/xtrack/loss_location_refinement/loss_location_refinement.py +0 -0
- {xtrack-0.90.1 → xtrack-0.92.0}/xtrack/lumi.py +0 -0
- {xtrack-0.90.1 → xtrack-0.92.0}/xtrack/mad_loader.py +0 -0
- {xtrack-0.90.1 → xtrack-0.92.0}/xtrack/mad_parser/__init__.py +0 -0
- {xtrack-0.90.1 → xtrack-0.92.0}/xtrack/mad_parser/madx.lark +0 -0
- {xtrack-0.90.1 → xtrack-0.92.0}/xtrack/mad_parser/parse.py +0 -0
- {xtrack-0.90.1 → xtrack-0.92.0}/xtrack/madng_interface.py +0 -0
- {xtrack-0.90.1 → xtrack-0.92.0}/xtrack/match.py +0 -0
- {xtrack-0.90.1 → xtrack-0.92.0}/xtrack/monitors/__init__.py +0 -0
- {xtrack-0.90.1 → xtrack-0.92.0}/xtrack/monitors/beam_position_monitor.h +0 -0
- {xtrack-0.90.1 → xtrack-0.92.0}/xtrack/monitors/beam_position_monitor.py +0 -0
- {xtrack-0.90.1 → xtrack-0.92.0}/xtrack/monitors/beam_profile_monitor.h +0 -0
- {xtrack-0.90.1 → xtrack-0.92.0}/xtrack/monitors/beam_profile_monitor.py +0 -0
- {xtrack-0.90.1 → xtrack-0.92.0}/xtrack/monitors/beam_size_monitor.h +0 -0
- {xtrack-0.90.1 → xtrack-0.92.0}/xtrack/monitors/beam_size_monitor.py +0 -0
- {xtrack-0.90.1 → xtrack-0.92.0}/xtrack/monitors/last_turns_monitor.h +0 -0
- {xtrack-0.90.1 → xtrack-0.92.0}/xtrack/monitors/last_turns_monitor.py +0 -0
- {xtrack-0.90.1 → xtrack-0.92.0}/xtrack/monitors/particles_monitor.h +0 -0
- {xtrack-0.90.1 → xtrack-0.92.0}/xtrack/monitors/particles_monitor.py +0 -0
- {xtrack-0.90.1 → xtrack-0.92.0}/xtrack/multiline.py +0 -0
- {xtrack-0.90.1 → xtrack-0.92.0}/xtrack/multiline_legacy/__init__.py +0 -0
- {xtrack-0.90.1 → xtrack-0.92.0}/xtrack/multiline_legacy/multiline_legacy.py +0 -0
- {xtrack-0.90.1 → xtrack-0.92.0}/xtrack/multiline_legacy/shared_knobs.py +0 -0
- {xtrack-0.90.1 → xtrack-0.92.0}/xtrack/multisetter/__init__.py +0 -0
- {xtrack-0.90.1 → xtrack-0.92.0}/xtrack/multisetter/multisetter.py +0 -0
- {xtrack-0.90.1 → xtrack-0.92.0}/xtrack/particles/__init__.py +0 -0
- {xtrack-0.90.1 → xtrack-0.92.0}/xtrack/particles/constants.py +0 -0
- {xtrack-0.90.1 → xtrack-0.92.0}/xtrack/particles/masses.py +0 -0
- {xtrack-0.90.1 → xtrack-0.92.0}/xtrack/particles/particles.py +0 -0
- {xtrack-0.90.1 → xtrack-0.92.0}/xtrack/particles/pdg.py +0 -0
- {xtrack-0.90.1 → xtrack-0.92.0}/xtrack/particles/rng_src/base_rng.h +0 -0
- {xtrack-0.90.1 → xtrack-0.92.0}/xtrack/particles/rng_src/particles_rng.h +0 -0
- {xtrack-0.90.1 → xtrack-0.92.0}/xtrack/pipeline/__init__.py +0 -0
- {xtrack-0.90.1 → xtrack-0.92.0}/xtrack/pipeline/core.py +0 -0
- {xtrack-0.90.1 → xtrack-0.92.0}/xtrack/pipeline/manager.py +0 -0
- {xtrack-0.90.1 → xtrack-0.92.0}/xtrack/pipeline/multitracker.py +0 -0
- {xtrack-0.90.1 → xtrack-0.92.0}/xtrack/progress_indicator.py +0 -0
- {xtrack-0.90.1 → xtrack-0.92.0}/xtrack/random/__init__.py +0 -0
- {xtrack-0.90.1 → xtrack-0.92.0}/xtrack/random/random_generators.py +0 -0
- {xtrack-0.90.1 → xtrack-0.92.0}/xtrack/random/random_src/exponential.h +0 -0
- {xtrack-0.90.1 → xtrack-0.92.0}/xtrack/random/random_src/exponential_integral_Ei.h +0 -0
- {xtrack-0.90.1 → xtrack-0.92.0}/xtrack/random/random_src/normal.h +0 -0
- {xtrack-0.90.1 → xtrack-0.92.0}/xtrack/random/random_src/rutherford.h +0 -0
- {xtrack-0.90.1 → xtrack-0.92.0}/xtrack/random/random_src/uniform.h +0 -0
- {xtrack-0.90.1 → xtrack-0.92.0}/xtrack/random/random_src/uniform_accurate.h +0 -0
- {xtrack-0.90.1 → xtrack-0.92.0}/xtrack/slicing.py +0 -0
- {xtrack-0.90.1 → xtrack-0.92.0}/xtrack/svgutils/__init__.py +0 -0
- {xtrack-0.90.1 → xtrack-0.92.0}/xtrack/svgutils/parser.py +0 -0
- {xtrack-0.90.1 → xtrack-0.92.0}/xtrack/svgutils/path.py +0 -0
- {xtrack-0.90.1 → xtrack-0.92.0}/xtrack/svgutils/svgutils.py +0 -0
- {xtrack-0.90.1 → xtrack-0.92.0}/xtrack/synctime.py +0 -0
- {xtrack-0.90.1 → xtrack-0.92.0}/xtrack/tapering.py +0 -0
- {xtrack-0.90.1 → xtrack-0.92.0}/xtrack/targets.py +0 -0
- {xtrack-0.90.1 → xtrack-0.92.0}/xtrack/track_flags.py +0 -0
- {xtrack-0.90.1 → xtrack-0.92.0}/xtrack/tracker.py +0 -0
- {xtrack-0.90.1 → xtrack-0.92.0}/xtrack/tracker_data.py +0 -0
- {xtrack-0.90.1 → xtrack-0.92.0}/xtrack/tracker_src/tracker.h +0 -0
- {xtrack-0.90.1 → xtrack-0.92.0}/xtrack/trajectory_correction.py +0 -0
- {xtrack-0.90.1 → xtrack-0.92.0}/xtrack/twissplot.py +0 -0
- {xtrack-0.90.1 → xtrack-0.92.0}/xtrack.egg-info/dependency_links.txt +0 -0
- {xtrack-0.90.1 → xtrack-0.92.0}/xtrack.egg-info/top_level.txt +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: xtrack
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.92.0
|
|
4
4
|
Summary: Tracking library for particle accelerators
|
|
5
5
|
Home-page: https://xsuite.readthedocs.io/
|
|
6
6
|
Download-URL: https://pypi.python.org/pypi/xtrack
|
|
@@ -25,6 +25,7 @@ Requires-Dist: pytest; extra == "tests"
|
|
|
25
25
|
Requires-Dist: pytest-mock; extra == "tests"
|
|
26
26
|
Requires-Dist: pymadng; extra == "tests"
|
|
27
27
|
Requires-Dist: requests-mock; extra == "tests"
|
|
28
|
+
Requires-Dist: tfs-pandas; extra == "tests"
|
|
28
29
|
Provides-Extra: notebooks
|
|
29
30
|
Requires-Dist: jupyter; extra == "notebooks"
|
|
30
31
|
Requires-Dist: ipympl; extra == "notebooks"
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import io
|
|
2
|
+
|
|
3
|
+
import numpy as np
|
|
4
|
+
|
|
5
|
+
from xtrack import json as xjson
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
def test_complex_scalar_round_trip():
|
|
9
|
+
data = {"value": 1 + 2j}
|
|
10
|
+
|
|
11
|
+
buffer = io.StringIO()
|
|
12
|
+
xjson.dump(data, buffer)
|
|
13
|
+
raw = buffer.getvalue()
|
|
14
|
+
|
|
15
|
+
buffer.seek(0)
|
|
16
|
+
loaded_from_file = xjson.load(file=buffer)
|
|
17
|
+
assert loaded_from_file == data
|
|
18
|
+
assert isinstance(loaded_from_file["value"], complex)
|
|
19
|
+
|
|
20
|
+
loaded_from_string = xjson.load(string=raw)
|
|
21
|
+
assert loaded_from_string == data
|
|
22
|
+
assert isinstance(loaded_from_string["value"], complex)
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
def test_complex_array_round_trip_preserves_dtype_and_shape(tmp_path):
|
|
26
|
+
array = np.array([[1 + 2j, 3 + 4j], [5 + 6j, 7 + 8j]], dtype=np.complex64)
|
|
27
|
+
|
|
28
|
+
path = tmp_path / "complex.json"
|
|
29
|
+
xjson.dump({"array": array}, path)
|
|
30
|
+
|
|
31
|
+
loaded = xjson.load(path)
|
|
32
|
+
round_trip = loaded["array"]
|
|
33
|
+
|
|
34
|
+
assert isinstance(round_trip, np.ndarray)
|
|
35
|
+
assert round_trip.dtype == array.dtype
|
|
36
|
+
np.testing.assert_allclose(round_trip, array)
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
def test_complex_array_round_trip_with_gzip(tmp_path):
|
|
40
|
+
array = np.array([1 + 2j, 3 + 4j], dtype=np.complex128)
|
|
41
|
+
|
|
42
|
+
path = tmp_path / "complex.json.gz"
|
|
43
|
+
xjson.dump({"array": array}, path)
|
|
44
|
+
|
|
45
|
+
loaded = xjson.load(path)
|
|
46
|
+
round_trip = loaded["array"]
|
|
47
|
+
|
|
48
|
+
assert isinstance(round_trip, np.ndarray)
|
|
49
|
+
assert round_trip.dtype == array.dtype
|
|
50
|
+
np.testing.assert_allclose(round_trip, array)
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
def test_python_primitive_types_round_trip():
|
|
54
|
+
data = {
|
|
55
|
+
"int": 42,
|
|
56
|
+
"float": 3.14,
|
|
57
|
+
"bool": True,
|
|
58
|
+
"str": "xtrack",
|
|
59
|
+
"list": [1, 2, 3],
|
|
60
|
+
"dict": {"nested": "value"},
|
|
61
|
+
"none": None,
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
buffer = io.StringIO()
|
|
65
|
+
xjson.dump(data, buffer)
|
|
66
|
+
|
|
67
|
+
buffer.seek(0)
|
|
68
|
+
loaded = xjson.load(file=buffer)
|
|
69
|
+
assert loaded == data
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
def test_numpy_scalar_round_trip():
|
|
73
|
+
data = {"value": np.int64(5)}
|
|
74
|
+
|
|
75
|
+
buffer = io.StringIO()
|
|
76
|
+
xjson.dump(data, buffer)
|
|
77
|
+
|
|
78
|
+
buffer.seek(0)
|
|
79
|
+
loaded = xjson.load(file=buffer)
|
|
80
|
+
|
|
81
|
+
assert loaded["value"] == 5
|
|
82
|
+
assert isinstance(loaded["value"], int)
|
|
83
|
+
|
|
84
|
+
|
|
85
|
+
def test_numpy_real_array_round_trip():
|
|
86
|
+
array = np.array([[1.0, 2.0], [3.0, 4.0]], dtype=np.float32)
|
|
87
|
+
|
|
88
|
+
buffer = io.StringIO()
|
|
89
|
+
xjson.dump({"array": array}, buffer)
|
|
90
|
+
|
|
91
|
+
buffer.seek(0)
|
|
92
|
+
loaded = xjson.load(file=buffer)
|
|
93
|
+
|
|
94
|
+
assert loaded["array"] == array.tolist()
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import xtrack as xt
|
|
2
2
|
import numpy as np
|
|
3
3
|
import xobjects as xo
|
|
4
|
+
from cpymad.madx import Madx
|
|
4
5
|
from xobjects.test_helpers import for_all_test_contexts
|
|
5
6
|
|
|
6
7
|
import pathlib
|
|
@@ -1786,4 +1787,61 @@ def test_rbend_straight_body_v_shift():
|
|
|
1786
1787
|
xo.assert_allclose(sv_test.Z, sv_curved.Z, atol=5e-14)
|
|
1787
1788
|
xo.assert_allclose(sv_test.phi, sv_curved.phi, atol=5e-14)
|
|
1788
1789
|
xo.assert_allclose(sv_test.psi, sv_curved.psi, atol=5e-14)
|
|
1789
|
-
xo.assert_allclose(sv_test.theta, sv_curved.theta, atol=5e-14)
|
|
1790
|
+
xo.assert_allclose(sv_test.theta, sv_curved.theta, atol=5e-14)
|
|
1791
|
+
|
|
1792
|
+
def test_rbend_loading_writing_in_interfaces():
|
|
1793
|
+
|
|
1794
|
+
madx = Madx()
|
|
1795
|
+
|
|
1796
|
+
l_straight = 1.0
|
|
1797
|
+
angle = 0.5
|
|
1798
|
+
l_arc = l_straight / np.sinc(angle / np.pi / 2) # np.sinc is sin(pi*x)/(pi*x)
|
|
1799
|
+
|
|
1800
|
+
madx.input('''
|
|
1801
|
+
b: rbend, l=1.0, angle=0.5;
|
|
1802
|
+
|
|
1803
|
+
ss: sequence, l=5.0, refer=centre;
|
|
1804
|
+
b, at=2.5;
|
|
1805
|
+
endsequence;
|
|
1806
|
+
beam;
|
|
1807
|
+
use, sequence=ss;
|
|
1808
|
+
twiss, betx=1, bety=1;
|
|
1809
|
+
survey;
|
|
1810
|
+
''')
|
|
1811
|
+
sv_madx = xt.Table(madx.table.survey, _copy_cols=True)
|
|
1812
|
+
xo.assert_allclose(madx.elements['b'].l, l_straight, rtol=1e-12)
|
|
1813
|
+
xo.assert_allclose(sv_madx['s', 'b:1'], 2.5 + l_arc / 2, rtol=1e-12) # b si at exit
|
|
1814
|
+
|
|
1815
|
+
# Check cpymad loader
|
|
1816
|
+
line = xt.Line.from_madx_sequence(madx.sequence.ss)
|
|
1817
|
+
line.remove('ss$start')
|
|
1818
|
+
line.remove('ss$end')
|
|
1819
|
+
line.particle_ref = xt.Particles(p0c=1e9)
|
|
1820
|
+
sv_xs = line.survey()
|
|
1821
|
+
xo.assert_allclose(line['b'].length_straight, l_straight, rtol=1e-12)
|
|
1822
|
+
xo.assert_allclose(line['b'].length, l_arc, rtol=1e-12)
|
|
1823
|
+
xo.assert_allclose(sv_xs['s', 'b'], 2.5 - l_arc / 2, rtol=1e-12) # b si at entrance
|
|
1824
|
+
|
|
1825
|
+
# Check to madx
|
|
1826
|
+
mad_str = line.to_madx_sequence(sequence_name='ggg')
|
|
1827
|
+
madx2 = Madx()
|
|
1828
|
+
madx2.input(mad_str)
|
|
1829
|
+
madx2.input('''
|
|
1830
|
+
beam;
|
|
1831
|
+
use, sequence=ggg;
|
|
1832
|
+
twiss, betx=1, bety=1;
|
|
1833
|
+
survey;
|
|
1834
|
+
''')
|
|
1835
|
+
sv_madx2 = xt.Table(madx2.table.survey, _copy_cols=True)
|
|
1836
|
+
xo.assert_allclose(madx2.elements['b'].l, l_straight, rtol=1e-12)
|
|
1837
|
+
|
|
1838
|
+
# Check native madx loader
|
|
1839
|
+
env2 = xt.load(string=mad_str, format='madx')
|
|
1840
|
+
sv_xs2 = env2.ggg.survey()
|
|
1841
|
+
xo.assert_allclose(env2['b'].length_straight, l_straight, rtol=1e-12)
|
|
1842
|
+
xo.assert_allclose(env2['b'].length, l_arc, rtol=1e-12)
|
|
1843
|
+
xo.assert_allclose(sv_xs2['s', 'b'], 2.5 - l_arc / 2, rtol=1e-12) # b si at entrance
|
|
1844
|
+
|
|
1845
|
+
# Check madng
|
|
1846
|
+
sv_ng = line.madng_survey()
|
|
1847
|
+
xo.assert_allclose(sv_ng['s', 'b'], 2.5 - l_arc / 2, rtol=1e-12) # b si at entrance
|
|
@@ -2058,4 +2058,4 @@ def test_twiss_disable_apertures():
|
|
|
2058
2058
|
tw = line.twiss(betx=1, bety=1, x=0.2, y=0)
|
|
2059
2059
|
xo.assert_allclose(tw.x[-1], 0.2)
|
|
2060
2060
|
with pytest.raises(AssertionError):
|
|
2061
|
-
line.twiss(betx=1, bety=1, x=0.2, y=0, disable_apertures=False)
|
|
2061
|
+
line.twiss(betx=1, bety=1, x=0.2, y=0, disable_apertures=False)
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import xtrack as xt
|
|
2
|
+
import xobjects as xo
|
|
3
|
+
import numpy as np
|
|
4
|
+
import pytest
|
|
5
|
+
import pathlib
|
|
6
|
+
|
|
7
|
+
test_data_folder = pathlib.Path(
|
|
8
|
+
__file__).parent.joinpath('../test_data').absolute()
|
|
9
|
+
|
|
10
|
+
@pytest.mark.parametrize("check_type", ['csv', 'hdf5', 'tfs', 'json'])
|
|
11
|
+
def test_twiss_table_file(check_type, tmp_path):
|
|
12
|
+
|
|
13
|
+
env = xt.load(test_data_folder / 'sps_thick/sps.seq')
|
|
14
|
+
env.vars.load(test_data_folder / 'sps_thick/lhc_q20.str')
|
|
15
|
+
line = env.sps
|
|
16
|
+
line.set_particle_ref('p', energy0=26e9)
|
|
17
|
+
tw = line.twiss4d()
|
|
18
|
+
|
|
19
|
+
if check_type == 'csv':
|
|
20
|
+
tw.to_csv(tmp_path / 'twiss_test.csv')
|
|
21
|
+
tw_test = xt.load(tmp_path / 'twiss_test.csv')
|
|
22
|
+
elif check_type == 'hdf5':
|
|
23
|
+
tw.to_hdf5(tmp_path / 'twiss_test.h5')
|
|
24
|
+
tw_test = xt.load(tmp_path / 'twiss_test.h5')
|
|
25
|
+
elif check_type == 'tfs':
|
|
26
|
+
tw.to_tfs(tmp_path / 'twiss_test.tfs')
|
|
27
|
+
tw_test = xt.load(tmp_path / 'twiss_test.tfs')
|
|
28
|
+
elif check_type == 'json':
|
|
29
|
+
tw.to_json(tmp_path / 'twiss_test.json')
|
|
30
|
+
tw_test = xt.load(tmp_path / 'twiss_test.json')
|
|
31
|
+
else:
|
|
32
|
+
raise ValueError(f'check_type {check_type} not supported')
|
|
33
|
+
|
|
34
|
+
assert isinstance(tw_test, xt.TwissTable)
|
|
35
|
+
|
|
36
|
+
assert np.all(np.array(tw_test._col_names) == np.array(tw._col_names))
|
|
37
|
+
if check_type == 'tfs':
|
|
38
|
+
assert set(tw_test.keys()) - set(tw.keys()) == {
|
|
39
|
+
'__class__', 'attrs_serialization', 'column_serialization', 'xtrack_version'
|
|
40
|
+
}
|
|
41
|
+
elif check_type == 'json':
|
|
42
|
+
assert set(tw_test.keys()) - set(tw.keys()) == {'xtrack_version'}
|
|
43
|
+
else:
|
|
44
|
+
assert set(tw_test.keys()) - set(tw.keys()) == {'__class__', 'xtrack_version'}
|
|
45
|
+
assert set(tw.keys()) - set(tw_test.keys()) == {'_action'}
|
|
46
|
+
|
|
47
|
+
for kk in tw._data:
|
|
48
|
+
if kk == '_action':
|
|
49
|
+
continue
|
|
50
|
+
if kk in ['particle_on_co', 'steps_r_matrix', 'line_config']:
|
|
51
|
+
continue # To be checked separately
|
|
52
|
+
if tw[kk] is None:
|
|
53
|
+
assert tw_test[kk] is None
|
|
54
|
+
continue
|
|
55
|
+
if isinstance(tw[kk], np.ndarray) and isinstance(tw[kk][0], str):
|
|
56
|
+
assert np.all(tw[kk] == tw_test[kk])
|
|
57
|
+
continue
|
|
58
|
+
elif isinstance(tw[kk], str):
|
|
59
|
+
assert tw[kk] == tw_test[kk]
|
|
60
|
+
continue
|
|
61
|
+
xo.assert_allclose(tw[kk], tw_test[kk], rtol=1e-7, atol=1e-15)
|
|
62
|
+
|
|
63
|
+
# Check particle_on_co
|
|
64
|
+
assert isinstance(tw.particle_on_co, xt.Particles)
|
|
65
|
+
assert isinstance(tw_test.particle_on_co, xt.Particles)
|
|
66
|
+
dct_ref = line.particle_ref.to_dict()
|
|
67
|
+
dct_test = tw_test.particle_on_co.to_dict()
|
|
68
|
+
for kk in dct_ref:
|
|
69
|
+
if isinstance(dct_ref[kk], np.ndarray):
|
|
70
|
+
xo.assert_allclose(dct_ref[kk], dct_test[kk], rtol=1e-10, atol=1e-15)
|
|
71
|
+
else:
|
|
72
|
+
assert dct_ref[kk] == dct_test[kk]
|
|
73
|
+
|
|
74
|
+
# Check steps_r_matrix
|
|
75
|
+
assert isinstance(tw.steps_r_matrix, dict)
|
|
76
|
+
assert isinstance(tw_test.steps_r_matrix, dict)
|
|
77
|
+
assert set(tw.steps_r_matrix.keys()) == set(tw_test.steps_r_matrix.keys())
|
|
78
|
+
for kk in tw.steps_r_matrix:
|
|
79
|
+
rmat_ref = tw.steps_r_matrix[kk]
|
|
80
|
+
rmat_test = tw_test.steps_r_matrix[kk]
|
|
81
|
+
xo.assert_allclose(rmat_ref, rmat_test, rtol=1e-10, atol=1e-15)
|
|
82
|
+
|
|
83
|
+
# Check line_config
|
|
84
|
+
assert isinstance(tw.line_config, dict)
|
|
85
|
+
assert isinstance(tw_test.line_config, dict)
|
|
86
|
+
assert set(tw.line_config.keys()) == set(tw_test.line_config.keys())
|
|
87
|
+
for kk in tw.line_config:
|
|
88
|
+
assert tw.line_config[kk] == tw_test.line_config[kk]
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
__version__ = '0.92.0'
|
|
@@ -1447,11 +1447,9 @@ class Bend(_BendCommon, BeamElement):
|
|
|
1447
1447
|
length : float, optional
|
|
1448
1448
|
Length of the element in meters along the reference trajectory.
|
|
1449
1449
|
knl : array, optional
|
|
1450
|
-
Integrated strength of the high-order normal multipolar components
|
|
1451
|
-
(knl[0] and knl[1] should not be used).
|
|
1450
|
+
Integrated strength of the high-order normal multipolar components.
|
|
1452
1451
|
ksl : array, optional
|
|
1453
|
-
Integrated strength of the high-order skew multipolar components
|
|
1454
|
-
(ksl[0] and ksl[1] should not be used).
|
|
1452
|
+
Integrated strength of the high-order skew multipolar components.
|
|
1455
1453
|
order : int, optional
|
|
1456
1454
|
Maximum order of multipole expansion for this magnet. Defaults to 5.
|
|
1457
1455
|
model : str, optional
|
|
@@ -1697,11 +1695,9 @@ class RBend(_BendCommon, BeamElement):
|
|
|
1697
1695
|
Length of the element in units of m along a straight line. Changes to
|
|
1698
1696
|
`length_straight` will update `length` and `h`.
|
|
1699
1697
|
knl : array, optional
|
|
1700
|
-
Integrated strength of the high-order normal multipolar components
|
|
1701
|
-
(`knl[0]` and `knl[1]` should not be used).
|
|
1698
|
+
Integrated strength of the high-order normal multipolar components.
|
|
1702
1699
|
ksl : array, optional
|
|
1703
|
-
Integrated strength of the high-order skew multipolar components
|
|
1704
|
-
(`ksl[0]` and `ksl[1]` should not be used).
|
|
1700
|
+
Integrated strength of the high-order skew multipolar components.
|
|
1705
1701
|
model : str, optional
|
|
1706
1702
|
Drift model to be used in kick-splitting. See `Bend` for details.
|
|
1707
1703
|
integrator : str, optional
|
|
@@ -658,11 +658,10 @@ class Environment:
|
|
|
658
658
|
|
|
659
659
|
def _get_a_drift_name(self):
|
|
660
660
|
self._drift_counter += 1
|
|
661
|
-
nn
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
return self._get_a_drift_name()
|
|
661
|
+
while nn := f'drift_{self._drift_counter}':
|
|
662
|
+
if nn not in self.element_dict:
|
|
663
|
+
return nn
|
|
664
|
+
self._drift_counter += 1
|
|
666
665
|
|
|
667
666
|
def __setitem__(self, key, value):
|
|
668
667
|
|
|
@@ -679,6 +678,7 @@ class Environment:
|
|
|
679
678
|
def to_dict(self, include_var_management=True, include_version=True):
|
|
680
679
|
|
|
681
680
|
out = {}
|
|
681
|
+
out['__class__'] = self.__class__.__name__
|
|
682
682
|
|
|
683
683
|
if include_version:
|
|
684
684
|
out["xtrack_version"] = xt.__version__
|
|
@@ -23,7 +23,7 @@ class _LOC:
|
|
|
23
23
|
START = _LOC('START')
|
|
24
24
|
END = _LOC('END')
|
|
25
25
|
|
|
26
|
-
def read_url(url, timeout=0.1):
|
|
26
|
+
def read_url(url, timeout=0.1, binary=False):
|
|
27
27
|
"""
|
|
28
28
|
Read content from a URL.
|
|
29
29
|
"""
|
|
@@ -31,9 +31,16 @@ def read_url(url, timeout=0.1):
|
|
|
31
31
|
response = requests.get(url, timeout=timeout)
|
|
32
32
|
response.raise_for_status() # Raise an error for bad responses
|
|
33
33
|
if url.endswith('.gz'):
|
|
34
|
-
|
|
34
|
+
out = gzip.decompress(response.content)
|
|
35
|
+
if binary:
|
|
36
|
+
return out
|
|
37
|
+
else:
|
|
38
|
+
return out.decode("utf-8")
|
|
35
39
|
else:
|
|
36
|
-
|
|
40
|
+
if binary:
|
|
41
|
+
return response.content
|
|
42
|
+
else:
|
|
43
|
+
return response.text
|
|
37
44
|
except requests.exceptions.RequestException as e:
|
|
38
45
|
raise RuntimeError(f"Failed to read from URL {url}: {e}")
|
|
39
46
|
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import json
|
|
2
|
+
import io
|
|
3
|
+
from pathlib import Path
|
|
4
|
+
import gzip
|
|
5
|
+
|
|
6
|
+
import numpy as np
|
|
7
|
+
|
|
8
|
+
from xobjects import JEncoder
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
_COMPLEX_SCALAR_TAG = "__complex__"
|
|
12
|
+
_COMPLEX_ARRAY_TAG = "__complex_ndarray__"
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
class _XtrackJSONEncoder(JEncoder):
|
|
16
|
+
def default(self, obj):
|
|
17
|
+
if isinstance(obj, complex):
|
|
18
|
+
return {_COMPLEX_SCALAR_TAG: [obj.real, obj.imag]}
|
|
19
|
+
|
|
20
|
+
if isinstance(obj, np.ndarray) and np.issubdtype(
|
|
21
|
+
obj.dtype, np.complexfloating
|
|
22
|
+
):
|
|
23
|
+
return {
|
|
24
|
+
_COMPLEX_ARRAY_TAG: {
|
|
25
|
+
"dtype": str(obj.dtype),
|
|
26
|
+
"shape": obj.shape,
|
|
27
|
+
"real": obj.real.tolist(),
|
|
28
|
+
"imag": obj.imag.tolist(),
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
return super().default(obj)
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
def _complex_object_hook(obj):
|
|
36
|
+
if _COMPLEX_SCALAR_TAG in obj:
|
|
37
|
+
real, imag = obj[_COMPLEX_SCALAR_TAG]
|
|
38
|
+
return complex(real, imag)
|
|
39
|
+
|
|
40
|
+
if _COMPLEX_ARRAY_TAG in obj:
|
|
41
|
+
metadata = obj[_COMPLEX_ARRAY_TAG]
|
|
42
|
+
real = np.array(metadata["real"], dtype=float)
|
|
43
|
+
imag = np.array(metadata["imag"], dtype=float)
|
|
44
|
+
data = real + 1j * imag
|
|
45
|
+
dtype = metadata.get("dtype")
|
|
46
|
+
if dtype is not None:
|
|
47
|
+
data = data.astype(np.dtype(dtype))
|
|
48
|
+
shape = metadata.get("shape")
|
|
49
|
+
if shape is not None:
|
|
50
|
+
data = np.array(data).reshape(tuple(shape))
|
|
51
|
+
return data
|
|
52
|
+
|
|
53
|
+
return obj
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
def dump(data, file, indent=1):
|
|
57
|
+
if isinstance(file, io.IOBase):
|
|
58
|
+
fh, close = file, False
|
|
59
|
+
elif (isinstance(file, str) and file.endswith(".gz")) or (
|
|
60
|
+
isinstance(file, Path) and file.suffix == ".gz"
|
|
61
|
+
):
|
|
62
|
+
fh, close = gzip.open(file, "wt"), True
|
|
63
|
+
else:
|
|
64
|
+
fh, close = open(file, "w"), True
|
|
65
|
+
|
|
66
|
+
json.dump(data, fh, indent=indent, cls=_XtrackJSONEncoder)
|
|
67
|
+
|
|
68
|
+
if close:
|
|
69
|
+
fh.close()
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
def load(file=None, string=None):
|
|
73
|
+
|
|
74
|
+
if string is not None:
|
|
75
|
+
assert file is None, "Cannot specify both file and string"
|
|
76
|
+
data = json.loads(string, object_hook=_complex_object_hook)
|
|
77
|
+
return data
|
|
78
|
+
|
|
79
|
+
if file is None:
|
|
80
|
+
raise ValueError("Must specify either file or string")
|
|
81
|
+
|
|
82
|
+
if isinstance(file, io.IOBase):
|
|
83
|
+
fh, close = file, False
|
|
84
|
+
elif (isinstance(file, str) and file.endswith(".gz")) or (
|
|
85
|
+
isinstance(file, Path) and file.suffix == ".gz"
|
|
86
|
+
):
|
|
87
|
+
fh, close = gzip.open(file, "rt"), True
|
|
88
|
+
else:
|
|
89
|
+
fh, close = open(file, "r"), True
|
|
90
|
+
|
|
91
|
+
data = json.load(fh, object_hook=_complex_object_hook)
|
|
92
|
+
|
|
93
|
+
if close:
|
|
94
|
+
fh.close()
|
|
95
|
+
|
|
96
|
+
return data
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
# copyright ############################### #
|
|
2
|
+
# This file is part of the Xtrack Package. #
|
|
3
|
+
# Copyright (c) CERN, 2025. #
|
|
4
|
+
# ######################################### #
|
|
5
|
+
|
|
6
|
+
from __future__ import annotations
|
|
7
|
+
|
|
8
|
+
import io
|
|
9
|
+
from pathlib import Path
|
|
10
|
+
from typing import Literal, Optional
|
|
11
|
+
|
|
12
|
+
import xtrack as xt
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
_SUPPORTED_FORMATS = {'json', 'madx', 'python', 'csv', 'hdf5', 'tfs'}
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
def _resolve_table_instance(table: xt.Table):
|
|
19
|
+
table_class = getattr(table, '_data', {}).get('__class__')
|
|
20
|
+
if not isinstance(table_class, str):
|
|
21
|
+
return table
|
|
22
|
+
|
|
23
|
+
cls = getattr(xt, table_class, None)
|
|
24
|
+
if cls is None or cls is xt.Table:
|
|
25
|
+
return table
|
|
26
|
+
|
|
27
|
+
out = cls(data=table._data, col_names=table._col_names)
|
|
28
|
+
|
|
29
|
+
return out
|
|
30
|
+
|
|
31
|
+
def _guess_format_from_path(path: str) -> Optional[str]:
|
|
32
|
+
lower = path.lower()
|
|
33
|
+
if lower.endswith(('.json', '.json.gz')):
|
|
34
|
+
return 'json'
|
|
35
|
+
if lower.endswith(('.seq', '.madx')):
|
|
36
|
+
return 'madx'
|
|
37
|
+
if lower.endswith('.py'):
|
|
38
|
+
return 'python'
|
|
39
|
+
if lower.endswith(('.h5', '.hdf5')):
|
|
40
|
+
return 'hdf5'
|
|
41
|
+
if lower.endswith('.csv'):
|
|
42
|
+
return 'csv'
|
|
43
|
+
if lower.endswith('.tfs'):
|
|
44
|
+
return 'tfs'
|
|
45
|
+
return None
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
def load(
|
|
49
|
+
file=None,
|
|
50
|
+
string=None,
|
|
51
|
+
format: Literal['json', 'madx', 'python', 'csv', 'hdf5', 'tfs'] = None,
|
|
52
|
+
timeout=5.0,
|
|
53
|
+
reverse_lines=None,
|
|
54
|
+
):
|
|
55
|
+
if isinstance(file, Path):
|
|
56
|
+
file = str(file)
|
|
57
|
+
|
|
58
|
+
if (file is None) == (string is None):
|
|
59
|
+
raise ValueError('Must specify either file or string, but not both')
|
|
60
|
+
|
|
61
|
+
if string is not None and format not in _SUPPORTED_FORMATS:
|
|
62
|
+
raise ValueError(
|
|
63
|
+
f'Format must be specified to be one of {_SUPPORTED_FORMATS} when using string input'
|
|
64
|
+
)
|
|
65
|
+
|
|
66
|
+
if format is None and file is not None and isinstance(file, str):
|
|
67
|
+
format = _guess_format_from_path(file)
|
|
68
|
+
|
|
69
|
+
if format is None:
|
|
70
|
+
raise ValueError('format could not be determined, please specify it explicitly')
|
|
71
|
+
|
|
72
|
+
if reverse_lines and format != 'madx':
|
|
73
|
+
raise ValueError('`reverse_lines` is only supported for madx input.')
|
|
74
|
+
|
|
75
|
+
if file and isinstance(file, str) and (file.startswith('http://') or file.startswith('https://')):
|
|
76
|
+
binary = format == 'hdf5'
|
|
77
|
+
string = xt.general.read_url(file, timeout=timeout, binary=binary)
|
|
78
|
+
file = None
|
|
79
|
+
|
|
80
|
+
if format == 'json':
|
|
81
|
+
payload = xt.json.load(file=file, string=string)
|
|
82
|
+
cls_name = payload.pop('__class__', None)
|
|
83
|
+
if cls_name is not None:
|
|
84
|
+
cls = getattr(xt, cls_name, None)
|
|
85
|
+
if cls is None:
|
|
86
|
+
raise ValueError(f'Unknown class {cls_name!r} in json data')
|
|
87
|
+
return cls.from_dict(payload)
|
|
88
|
+
if 'lines' in payload:
|
|
89
|
+
return xt.Environment.from_dict(payload)
|
|
90
|
+
if 'element_names' in payload or 'line' in payload:
|
|
91
|
+
if 'line' in payload:
|
|
92
|
+
payload = payload['line']
|
|
93
|
+
return xt.Line.from_dict(payload)
|
|
94
|
+
raise ValueError('Cannot determine class from json data')
|
|
95
|
+
|
|
96
|
+
if format == 'madx':
|
|
97
|
+
return xt.load_madx_lattice(file=file, string=string, reverse_lines=reverse_lines)
|
|
98
|
+
|
|
99
|
+
if format == 'python':
|
|
100
|
+
if string is not None:
|
|
101
|
+
raise NotImplementedError('Loading from string not implemented for python format')
|
|
102
|
+
env = xt.Environment()
|
|
103
|
+
env.call(file)
|
|
104
|
+
return env
|
|
105
|
+
|
|
106
|
+
if format == 'csv':
|
|
107
|
+
if string is not None:
|
|
108
|
+
text = string.decode() if isinstance(string, bytes) else string
|
|
109
|
+
buffer = io.StringIO(text)
|
|
110
|
+
base_table = xt.Table.from_csv(buffer)
|
|
111
|
+
else:
|
|
112
|
+
if hasattr(file, 'seek'):
|
|
113
|
+
file.seek(0)
|
|
114
|
+
base_table = xt.Table.from_csv(file)
|
|
115
|
+
return _resolve_table_instance(base_table)
|
|
116
|
+
|
|
117
|
+
if format == 'hdf5':
|
|
118
|
+
if string is not None:
|
|
119
|
+
if not isinstance(string, (bytes, bytearray)):
|
|
120
|
+
raise TypeError('HDF5 string input must be bytes-like')
|
|
121
|
+
buffer = io.BytesIO(string)
|
|
122
|
+
base_table = xt.Table.from_hdf5(buffer)
|
|
123
|
+
else:
|
|
124
|
+
if hasattr(file, 'seek'):
|
|
125
|
+
file.seek(0)
|
|
126
|
+
base_table = xt.Table.from_hdf5(file)
|
|
127
|
+
return _resolve_table_instance(base_table)
|
|
128
|
+
|
|
129
|
+
if format == 'tfs':
|
|
130
|
+
if string is not None:
|
|
131
|
+
text = string.decode() if isinstance(string, bytes) else string
|
|
132
|
+
buffer = io.StringIO(text)
|
|
133
|
+
base_table = xt.Table.from_tfs(buffer)
|
|
134
|
+
else:
|
|
135
|
+
if hasattr(file, 'seek'):
|
|
136
|
+
file.seek(0)
|
|
137
|
+
base_table = xt.Table.from_tfs(file)
|
|
138
|
+
return _resolve_table_instance(base_table)
|
|
139
|
+
|
|
140
|
+
raise ValueError(f'Unsupported format {format!r}')
|
|
@@ -203,6 +203,8 @@ class MadxLoader:
|
|
|
203
203
|
if build:
|
|
204
204
|
builder.build()
|
|
205
205
|
|
|
206
|
+
self.env._last_loaded_builders = builders
|
|
207
|
+
|
|
206
208
|
return builders
|
|
207
209
|
|
|
208
210
|
def _parse_parameters(self, parameters: Dict[str, Dict[str, str]]):
|
|
@@ -624,7 +626,7 @@ class MadxLoader:
|
|
|
624
626
|
return self._mad_base_type(element_name) in _APERTURE_TYPES
|
|
625
627
|
|
|
626
628
|
|
|
627
|
-
def load_madx_lattice(file=None, string=None, reverse_lines=None):
|
|
629
|
+
def load_madx_lattice(file=None, string=None, reverse_lines=None, build=True):
|
|
628
630
|
|
|
629
631
|
if file is not None and string is not None:
|
|
630
632
|
raise ValueError('Only one of `file` or `string` can be provided!')
|
|
@@ -635,9 +637,9 @@ def load_madx_lattice(file=None, string=None, reverse_lines=None):
|
|
|
635
637
|
loader = MadxLoader()
|
|
636
638
|
|
|
637
639
|
if file is not None:
|
|
638
|
-
loader.load_file(file)
|
|
640
|
+
loader.load_file(file, build=build)
|
|
639
641
|
elif string is not None:
|
|
640
|
-
loader.load_string(string)
|
|
642
|
+
loader.load_string(string, build=build)
|
|
641
643
|
else:
|
|
642
644
|
raise ValueError('Something went wrong!')
|
|
643
645
|
|
|
@@ -415,7 +415,12 @@ def bend_to_mad_str(name, line, bend_type='sbend', mad_type=MadType.MADX, substi
|
|
|
415
415
|
tokens.append(bend_type)
|
|
416
416
|
if mad_type == MadType.MADNG:
|
|
417
417
|
tokens.append(f"'{name.replace(':', '__')}'") # replace ':' with '__' for MADNG
|
|
418
|
-
|
|
418
|
+
if bend_type == 'sbend' or mad_type == MadType.MADNG: # in MAD-NG all bends use the arc length
|
|
419
|
+
tokens.append(mad_assignment('l', _ge(bend.length), mad_type, substituted_vars=substituted_vars))
|
|
420
|
+
elif bend_type == 'rbend':
|
|
421
|
+
tokens.append(mad_assignment('l', _ge(bend.length_straight), mad_type, substituted_vars=substituted_vars))
|
|
422
|
+
else:
|
|
423
|
+
raise ValueError(f"bend_type {bend_type} not recognized")
|
|
419
424
|
tokens.append(mad_assignment('angle', _ge(bend.h) * _ge(bend.length), mad_type, substituted_vars=substituted_vars))
|
|
420
425
|
tokens.append(mad_assignment('k0', _ge(bend.k0), mad_type, substituted_vars=substituted_vars))
|
|
421
426
|
tokens.append(mad_assignment('e1', _ge(bend.edge_entry_angle), mad_type, substituted_vars=substituted_vars))
|