Read and write turn-by-turn measurement files from different particle accelerator formats.
Project description
Turn-By-Turn
This package provides reading functionality for turn-by-turn BPM measurements data from different particle accelerators.
It also provides writing functionality in the LHC
's own SDDS format, through our sdds
package.
Files are read into a custom-made TbtData
dataclass encompassing the relevant information.
See the API documentation for details.
Installing
Installation is easily done via pip
:
python -m pip install turn_by_turn
One can also install in a conda
environment via the conda-forge
channel with:
conda install -c conda-forge turn_by_turn
Example Usage
The package is imported as turn_by_turn
, and exports top-level functions for reading and writing:
import turn_by_turn as tbt
# Loading a file is simple and returns a custom dataclass named TbtData
data: tbt.TbtData = tbt.read("Beam2@BunchTurn@2018_12_02@20_08_49_739.sdds", datatype="lhc")
# Easily access relevant information from the loaded data: transverse data, measurement date,
# number of turns, bunches and IDs of the recorded bunches
first_bunch_transverse_positions: tbt.TransverseData = data.matrices[0]
measurement_date = data.date # a datetime.datetime object
# Transverse positions are recorded as pandas DataFrames
first_bunch_x = first_bunch_transverse_positions.X.copy()
first_bunch_y = first_bunch_transverse_positions.Y.copy()
# Do any operations with these as you usually do with pandas
first_bunch_mean_x = first_bunch_x.mean()
# Average over all bunches/particles at all used BPMs from the measurement
averaged_tbt: tbt.TbtData = tbt.utils.generate_average_tbtdata(data)
# Writing out to disk (in the LHC's SDDS format) is simple too, potentially with added noise
tbt.write("path_to_output.sdds", averaged_tbt, noise=1e-5)
License
This project is licensed under the MIT License
- see the LICENSE file for details.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file turn_by_turn-0.7.2.tar.gz
.
File metadata
- Download URL: turn_by_turn-0.7.2.tar.gz
- Upload date:
- Size: 20.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 60dc8e1c2d933176a0fed0ab4d6bf032289b5877985d2bcd5669063a2c8e2df7 |
|
MD5 | 8b7c07788d14d4a36bfe571c282b7d62 |
|
BLAKE2b-256 | df0db32449a94222e2fa1c5954c05e2a79332db895016e2be728d08888bef882 |
File details
Details for the file turn_by_turn-0.7.2-py3-none-any.whl
.
File metadata
- Download URL: turn_by_turn-0.7.2-py3-none-any.whl
- Upload date:
- Size: 26.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8e18228c4b7cf43e20e1de7e79f33b5a9ac0b717c860fd1db2d98cbda2eef15b |
|
MD5 | 49aa45f8d47502367a7ab03a744cf665 |
|
BLAKE2b-256 | 4c1a3339542d13ea2daf12f0611a218907ebd5bbe32482a2aae47894cd13a9cb |