Skip to main content

Read and write turn-by-turn measurement files from different particle accelerator formats.

Project description

Turn-By-Turn

Cron Testing Code Climate coverage Code Climate maintainability (percentage)

PyPI Version GitHub release Conda-forge Version DOI

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

turn_by_turn-0.4.2.tar.gz (17.1 kB view details)

Uploaded Source

Built Distribution

turn_by_turn-0.4.2-py3-none-any.whl (22.2 kB view details)

Uploaded Python 3

File details

Details for the file turn_by_turn-0.4.2.tar.gz.

File metadata

  • Download URL: turn_by_turn-0.4.2.tar.gz
  • Upload date:
  • Size: 17.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.7.13

File hashes

Hashes for turn_by_turn-0.4.2.tar.gz
Algorithm Hash digest
SHA256 e1f16d4569e2afc05409c0c6c48191e53279125ddaf2f0b6e7fa70ea7895ea2e
MD5 0c6764b01a86d9ee4e1fee5632af1704
BLAKE2b-256 c1911a3775eec4da474ccf6eb6b0b8761007a85f372ad43fcde696d44bca9832

See more details on using hashes here.

File details

Details for the file turn_by_turn-0.4.2-py3-none-any.whl.

File metadata

  • Download URL: turn_by_turn-0.4.2-py3-none-any.whl
  • Upload date:
  • Size: 22.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.7.13

File hashes

Hashes for turn_by_turn-0.4.2-py3-none-any.whl
Algorithm Hash digest
SHA256 5e1106ed6a58126fe23c854558f3f13d68c3c96cd5eace8c280f1d71485acf3a
MD5 6dd603d5c26c6fa97f327ff5b75732ed
BLAKE2b-256 4a7f6e88f1a1563d2a22798c7a1e38125aa1042013f58f6f3f8ea6ef9269d1ef

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page