Skip to content

Commit 95c1a44

Browse files
committed
numpy style
1 parent 60b9e0e commit 95c1a44

File tree

1 file changed

+51
-36
lines changed

1 file changed

+51
-36
lines changed

pyhdtoolkit/plotting/envelope.py

Lines changed: 51 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -35,43 +35,55 @@ def plot_beam_envelope(
3535
"""
3636
.. versionadded:: 1.2.0
3737
38-
Draws the beam enveloppe around the beam orbit on the given *axis*.
39-
The enveloppe is determined from the active sequence's beam's parameters.
40-
41-
One can find an example use of this function in the
42-
:ref:`beam enveloppe <demo-beam-enveloppe>` example gallery.
43-
44-
Args:
45-
madx (cpymad.madx.Madx): an instanciated `~cpymad.madx.Madx` object.
46-
Positional only.
47-
sequence (str): the name of the sequence to plot the beam enveloppe
48-
for, should be the active sequence. Case-insensitive.
49-
plane (str): the physical plane to plot for, should be either `x`,
50-
`horizontal`, `y` or `vertical`, and is case-insensitive.
51-
nsigma (float): the standard deviation to use for the beam enveloppe
52-
calculation. A value of 3 will draw the 3 sigma beam enveloppe.
53-
Defaults to 1.
54-
scale (float): a scaling factor to apply to the beam orbit and beam
55-
enveloppe, for the user to adjust to their wanted scale. Defaults
56-
to 1 (values in [m]).
57-
xoffset (float): An offset applied to the ``S`` coordinate before
58-
plotting. This is useful if you want to center a plot around a
59-
specific point or element, which would then become located
60-
at :math:`s = 0`. Beware this offset is applied before applying
61-
the *xlimits*. Defaults to 0.
62-
xlimits (tuple[float, float]): will implement xlim (for the ``s``
63-
coordinate) if this is not ``None``, using the tuple passed.
64-
Defaults to ``None``.
65-
**kwargs: any keyword argument that can be given to the ``MAD-X``
66-
``TWISS`` command. If either `ax` or `axis` is found in the
67-
kwargs, the corresponding value is used as the axis object to
68-
plot on.
69-
70-
Raises:
71-
ValueError: if the *plane* argument is not one of `x`, `horizontal`,
38+
Draws the beam enveloppe around the beam orbit on the given
39+
*axis*. The enveloppe is determined from the active sequence's
40+
beam's parameters.
41+
42+
One can find an example use of this function in the :ref:`beam
43+
enveloppe <demo-beam-enveloppe>` example gallery.
44+
45+
Parameters
46+
----------
47+
madx : cpymad.madx.Madx
48+
An instanciated `~cpymad.madx.Madx` object. Positional only.
49+
sequence : str
50+
The name of the sequence to plot the beam enveloppe for, which
51+
should be the active sequence. Case insensitive.
52+
plane : str
53+
The physical plane to plot for, which should be either `x`,
54+
`horizontal`, `y` or `vertical`. Case insensitive.
55+
nsigma : float
56+
The standard deviation to use for the beam enveloppe calculation.
57+
For instance, providing a value of 3 will draw the 3 sigma beam
58+
enveloppe. Defaults to 1.
59+
scale : float
60+
A scaling factor to apply to the beam orbit and beam enveloppe,
61+
for the user to adjust to their wanted scale. Defaults to 1
62+
(meaning values are assumed in [m]).
63+
xoffset : float
64+
An offset applied to the ``S`` coordinate before plotting. This
65+
is useful if you want to center a plot around a specific point
66+
or element, which would then become located at :math:`s = 0`.
67+
Beware this offset is applied before applying the *xlimits*.
68+
Defaults to 0.
69+
xlimits : tuple[float, float], optional
70+
If given, will be used for the xlim (for the ``s`` coordinate),
71+
using the tuple passed.
72+
**kwargs
73+
Any keyword argument that can be given to the ``MAD-X``
74+
``TWISS`` command. If either `ax` or `axis` is found in the
75+
kwargs, the corresponding value is used as the axis object to
76+
plot on.
77+
78+
Raises
79+
------
80+
ValueError
81+
If the *plane* argument is not one of `x`, `horizontal`,
7282
`y` or `vertical`.
7383
74-
Examples:
84+
Examples
85+
--------
86+
7587
.. code-block:: python
7688
7789
fig, ax = plt.subplots(figsize=(10, 9))
@@ -133,7 +145,10 @@ def plot_beam_envelope(
133145

134146

135147
def _interpolate_madx(madx: Madx, /) -> None:
136-
"""Run interpolation on the provided MAD-X instance with default slice values."""
148+
"""
149+
Run interpolation on the provided MAD-X
150+
instance with default slice values.
151+
"""
137152
logger.debug("Running interpolation in MAD-X")
138153
madx.command.select(flag="interpolate", class_="drift", slice_=4, range_="#s/#e")
139154
madx.command.select(flag="interpolate", class_="quadrupole", slice_=8, range_="#s/#e")

0 commit comments

Comments
 (0)