Source code for pyhdtoolkit.cpymadtools.parameters
""".. _cpymadtools-parameters:Beam Parameters---------------Module with functions to fetch or compute different beam andmachine parameters through a `~cpymad.madx.Madx` object."""from__future__importannotationsfromtypingimportTYPE_CHECKINGfromloguruimportloggerfrompyhdtoolkit.models.madximportMADXBeamifTYPE_CHECKING:fromcpymad.madximportMadx# ----- Utilities ----- #
[docs]defquery_beam_attributes(madx:Madx,/)->MADXBeam:""" .. versionadded:: 0.12.0 Returns all ``BEAM`` attributes from the ``MAD-X`` process based on the currently defined beam. If no beam has been defined at function call, then ``MAD-X`` will return all the default values. See the `MAD-X manual <http://madx.web.cern.ch/madx/releases/last-rel/madxuguide.pdf>`_ for details. Parameters ---------- madx : cpymad.madx.Madx An instanciated `~cpymad.madx.Madx` object. Positional only. Returns ------- MADXBeam A validated `~.models.madx.MADXBeam` object. Example ------- .. code-block:: python beam_parameters = query_beam_attributes(madx) """logger.debug("Retrieving BEAM attributes from the MAD-X process")returnMADXBeam(**dict(madx.beam))