Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Precision in tracking methods #58

Merged
merged 3 commits into from
Sep 27, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docker/environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ dependencies:
- pyarrow==5.0.0
- pydantic==1.8.2
- pygments==2.10.0
- pyhdtoolkit==0.14.0
- pyhdtoolkit==0.14.1
- pynaff==1.1.4
- pyparsing==2.4.7
- python-dateutil==2.8.2
Expand Down
144 changes: 73 additions & 71 deletions poetry.lock

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion pyhdtoolkit/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
__title__ = "pyhdtoolkit"
__description__ = "An all-in-one toolkit package to easy my Python work in my PhD."
__url__ = "https://github.com/fsoubelet/PyhDToolkit"
__version__ = "0.14.0"
__version__ = "0.14.1"
__author__ = "Felix Soubelet"
__author_email__ = "felix.soubelet@cern.ch"
__license__ = "MIT"
14 changes: 13 additions & 1 deletion pyhdtoolkit/cpymadtools/ptc.py
Original file line number Diff line number Diff line change
Expand Up @@ -240,13 +240,21 @@ def ptc_track_particle(
The `PTC_TRACK` command is explicitely given `ELEMENT_BY_ELEMENT=True` to force element by element
tracking mode.

Warnings:
If the `sequence` argument is given a string value, the `USE` command will be ran on the provided
sequence name. This means the caveats of `USE` apply, for instance the erasing of previously
defined errors, orbits corrections etc. In this case a warning will be logged but the function will
proceed. If `None` is given (by default) then the sequence already in used will be the one tracking
is performed on.

Args:
madx (Madx): an instantiated cpymad.madx.Madx object.
initial_coordinates (Tuple[float, float, float, float, float, float]): a tuple with the X, PX, Y, PY,
T, PT starting coordinates the particle to track. Defaults to all 0 if none given.
nturns (int): the number of turns to track for.
sequence (str): the sequence to use for tracking. If no value is provided, it is assumed that a
sequence is already defined and in use, and this one will be picked up by MAD-X.
sequence is already defined and in use, and this one will be picked up by MAD-X. BEWARE of the
dangers of giving a sequence that will be `use`d by `MAD-X`, see function warning docstring.
observation_points (Sequence[str]): sequence of all element names at which to OBSERVE during the
tracking.
onetable (bool): flag to combine all observation points data into a single table. Defaults to `False`.
Expand All @@ -266,10 +274,14 @@ def ptc_track_particle(
If the user has set `onetable` to `True`, only one entry is in the dictionary under the key
'trackone' and it has the combined table as a pandas DataFrame for value.
"""
logger.info("Performing single particle PTC (thick) tracking")
start = initial_coordinates if initial_coordinates else [0, 0, 0, 0, 0, 0]
observation_points = observation_points if observation_points else []

if isinstance(sequence, str):
logger.warning(
f"Sequence '{sequence}' was provided and will be used, beware that this will erase errors etc."
)
logger.debug(f"Using sequence '{sequence}' for tracking")
madx.use(sequence=sequence)

Expand Down
14 changes: 13 additions & 1 deletion pyhdtoolkit/cpymadtools/track.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,21 @@ def track_single_particle(
"""
Tracks a single particle for nturns, based on its initial coordinates.

Warnings:
If the `sequence` argument is given a string value, the `USE` command will be ran on the provided
sequence name. This means the caveats of `USE` apply, for instance the erasing of previously
defined errors, orbits corrections etc. In this case a warning will be logged but the function will
proceed. If `None` is given (by default) then the sequence already in used will be the one tracking
is performed on.

Args:
madx (Madx): an instantiated cpymad.madx.Madx object.
initial_coordinates (Tuple[float, float, float, float, float, float]): a tuple with the X, PX, Y, PY,
T, PT starting coordinates the particle to track. Defaults to all 0 if none given.
nturns (int): the number of turns to track for.
sequence (str): the sequence to use for tracking. If no value is provided, it is assumed that a
sequence is already defined and in use, and this one will be picked up by MAD-X.
sequence is already defined and in use, and this one will be picked up by MAD-X. BEWARE of the
dangers of giving a sequence that will be `use`d by `MAD-X`, see function warning docstring.
observation_points (Sequence[str]): sequence of all element names at which to OBSERVE during the
tracking.

Expand All @@ -52,11 +60,15 @@ def track_single_particle(
If the user has set `onetable` to `True`, only one entry is in the dictionary under the key
'trackone' and it has the combined table as a pandas DataFrame for value.
"""
logger.info("Performing single particle MAD-X (thin) tracking")
onetable = kwargs.get("onetable", False) if "onetable" in kwargs else kwargs.get("ONETABLE", False)
start = initial_coordinates if initial_coordinates else [0, 0, 0, 0, 0, 0]
observation_points = observation_points if observation_points else []

if isinstance(sequence, str):
logger.warning(
f"Sequence '{sequence}' was provided and will be used, beware that this will erase errors etc."
)
logger.debug(f"Using sequence '{sequence}' for tracking")
madx.use(sequence=sequence)

Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "pyhdtoolkit"
version = "0.14.0"
version = "0.14.1"
description = "An all-in-one toolkit package to easy my Python work in my PhD."
authors = ["Felix Soubelet <felix.soubelet@cern.ch>"]
license = "MIT"
Expand Down