turn_by_turn 0.9.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- turn_by_turn-0.9.0/.gitignore +252 -0
- turn_by_turn-0.9.0/.zenodo.json +49 -0
- turn_by_turn-0.9.0/LICENSE +21 -0
- turn_by_turn-0.9.0/PKG-INFO +115 -0
- turn_by_turn-0.9.0/README.md +60 -0
- turn_by_turn-0.9.0/pyproject.toml +86 -0
- turn_by_turn-0.9.0/turn_by_turn/__init__.py +20 -0
- turn_by_turn-0.9.0/turn_by_turn/ascii.py +196 -0
- turn_by_turn-0.9.0/turn_by_turn/constants.py +17 -0
- turn_by_turn-0.9.0/turn_by_turn/doros.py +206 -0
- turn_by_turn-0.9.0/turn_by_turn/errors.py +28 -0
- turn_by_turn-0.9.0/turn_by_turn/esrf.py +84 -0
- turn_by_turn-0.9.0/turn_by_turn/io.py +239 -0
- turn_by_turn-0.9.0/turn_by_turn/iota.py +145 -0
- turn_by_turn-0.9.0/turn_by_turn/lhc.py +114 -0
- turn_by_turn-0.9.0/turn_by_turn/madng.py +245 -0
- turn_by_turn-0.9.0/turn_by_turn/ptc.py +211 -0
- turn_by_turn-0.9.0/turn_by_turn/sps.py +125 -0
- turn_by_turn-0.9.0/turn_by_turn/structures.py +89 -0
- turn_by_turn-0.9.0/turn_by_turn/trackone.py +122 -0
- turn_by_turn-0.9.0/turn_by_turn/utils.py +197 -0
- turn_by_turn-0.9.0/turn_by_turn/xtrack_line.py +168 -0
|
@@ -0,0 +1,252 @@
|
|
|
1
|
+
# Created by .ignore support plugin (hsz.mobi)
|
|
2
|
+
### Python template
|
|
3
|
+
# Byte-compiled / optimized / DLL files
|
|
4
|
+
__pycache__/
|
|
5
|
+
*.py[cod]
|
|
6
|
+
*$py.class
|
|
7
|
+
|
|
8
|
+
# C extensions
|
|
9
|
+
*.so
|
|
10
|
+
|
|
11
|
+
# Distribution / packaging
|
|
12
|
+
.Python
|
|
13
|
+
build/
|
|
14
|
+
develop-eggs/
|
|
15
|
+
dist/
|
|
16
|
+
downloads/
|
|
17
|
+
eggs/
|
|
18
|
+
.eggs/
|
|
19
|
+
lib/
|
|
20
|
+
lib64/
|
|
21
|
+
parts/
|
|
22
|
+
sdist/
|
|
23
|
+
var/
|
|
24
|
+
wheels/
|
|
25
|
+
pip-wheel-metadata/
|
|
26
|
+
share/python-wheels/
|
|
27
|
+
*.egg-info/
|
|
28
|
+
.installed.cfg
|
|
29
|
+
*.egg
|
|
30
|
+
MANIFEST
|
|
31
|
+
|
|
32
|
+
# PyInstaller
|
|
33
|
+
# Usually these files are written by a python script from a template
|
|
34
|
+
# before PyInstaller builds the exe, so as to inject date/other infos into it.
|
|
35
|
+
*.manifest
|
|
36
|
+
*.spec
|
|
37
|
+
|
|
38
|
+
# Installer logs
|
|
39
|
+
pip-log.txt
|
|
40
|
+
pip-delete-this-directory.txt
|
|
41
|
+
|
|
42
|
+
# Unit test / coverage reports
|
|
43
|
+
htmlcov/
|
|
44
|
+
.tox/
|
|
45
|
+
.nox/
|
|
46
|
+
.coverage
|
|
47
|
+
.coverage.*
|
|
48
|
+
.cache
|
|
49
|
+
nosetests.xml
|
|
50
|
+
coverage.xml
|
|
51
|
+
*.cover
|
|
52
|
+
.hypothesis/
|
|
53
|
+
.pytest_cache/
|
|
54
|
+
|
|
55
|
+
# Translations
|
|
56
|
+
*.mo
|
|
57
|
+
*.pot
|
|
58
|
+
|
|
59
|
+
# Django stuff:
|
|
60
|
+
*.log
|
|
61
|
+
local_settings.py
|
|
62
|
+
db.sqlite3
|
|
63
|
+
db.sqlite3-journal
|
|
64
|
+
|
|
65
|
+
# Flask stuff:
|
|
66
|
+
instance/
|
|
67
|
+
.webassets-cache
|
|
68
|
+
|
|
69
|
+
# Scrapy stuff:
|
|
70
|
+
.scrapy
|
|
71
|
+
|
|
72
|
+
# Sphinx documentation
|
|
73
|
+
docs/_build/
|
|
74
|
+
doc/_build/
|
|
75
|
+
doc_build/
|
|
76
|
+
|
|
77
|
+
# PyBuilder
|
|
78
|
+
target/
|
|
79
|
+
|
|
80
|
+
# Jupyter Notebook
|
|
81
|
+
.ipynb_checkpoints/
|
|
82
|
+
|
|
83
|
+
# IPython
|
|
84
|
+
profile_default/
|
|
85
|
+
ipython_config.py
|
|
86
|
+
|
|
87
|
+
# pyenv
|
|
88
|
+
.python-version
|
|
89
|
+
|
|
90
|
+
# pipenv
|
|
91
|
+
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
|
|
92
|
+
# However, in case of collaboration, if having platform-specific dependencies or dependencies
|
|
93
|
+
# having no cross-platform support, pipenv may install dependencies that don't work, or not
|
|
94
|
+
# install all needed dependencies.
|
|
95
|
+
#Pipfile.lock
|
|
96
|
+
|
|
97
|
+
# celery beat schedule file
|
|
98
|
+
celerybeat-schedule
|
|
99
|
+
|
|
100
|
+
# SageMath parsed files
|
|
101
|
+
*.sage.py
|
|
102
|
+
|
|
103
|
+
# Environments
|
|
104
|
+
.env
|
|
105
|
+
.venv
|
|
106
|
+
env/
|
|
107
|
+
venv/
|
|
108
|
+
ENV/
|
|
109
|
+
env.bak/
|
|
110
|
+
venv.bak/
|
|
111
|
+
|
|
112
|
+
# Spyder project settings
|
|
113
|
+
.spyderproject
|
|
114
|
+
.spyproject
|
|
115
|
+
|
|
116
|
+
# Rope project settings
|
|
117
|
+
.ropeproject
|
|
118
|
+
|
|
119
|
+
# mkdocs documentation
|
|
120
|
+
/site
|
|
121
|
+
|
|
122
|
+
# mypy
|
|
123
|
+
.mypy_cache/
|
|
124
|
+
.dmypy.json
|
|
125
|
+
dmypy.json
|
|
126
|
+
|
|
127
|
+
# Pyre type checker
|
|
128
|
+
.pyre/
|
|
129
|
+
|
|
130
|
+
### JetBrains template
|
|
131
|
+
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and WebStorm
|
|
132
|
+
# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839
|
|
133
|
+
|
|
134
|
+
# User-specific stuff
|
|
135
|
+
.idea/*
|
|
136
|
+
.idea/**/workspace.xml
|
|
137
|
+
.idea/**/tasks.xml
|
|
138
|
+
.idea/**/usage.statistics.xml
|
|
139
|
+
.idea/**/dictionaries
|
|
140
|
+
.idea/**/shelf
|
|
141
|
+
|
|
142
|
+
# Generated files
|
|
143
|
+
.idea/**/contentModel.xml
|
|
144
|
+
|
|
145
|
+
# Sensitive or high-churn files
|
|
146
|
+
.idea/**/dataSources/
|
|
147
|
+
.idea/**/dataSources.ids
|
|
148
|
+
.idea/**/dataSources.local.xml
|
|
149
|
+
.idea/**/sqlDataSources.xml
|
|
150
|
+
.idea/**/dynamic.xml
|
|
151
|
+
.idea/**/uiDesigner.xml
|
|
152
|
+
.idea/**/dbnavigator.xml
|
|
153
|
+
|
|
154
|
+
# Gradle
|
|
155
|
+
.idea/**/gradle.xml
|
|
156
|
+
.idea/**/libraries
|
|
157
|
+
|
|
158
|
+
# Gradle and Maven with auto-import
|
|
159
|
+
# When using Gradle or Maven with auto-import, you should exclude module files,
|
|
160
|
+
# since they will be recreated, and may cause churn. Uncomment if using
|
|
161
|
+
# auto-import.
|
|
162
|
+
# .idea/modules.xml
|
|
163
|
+
# .idea/*.iml
|
|
164
|
+
# .idea/modules
|
|
165
|
+
# *.iml
|
|
166
|
+
# *.ipr
|
|
167
|
+
|
|
168
|
+
# CMake
|
|
169
|
+
cmake-build-*/
|
|
170
|
+
|
|
171
|
+
# Mongo Explorer plugin
|
|
172
|
+
.idea/**/mongoSettings.xml
|
|
173
|
+
|
|
174
|
+
# File-based project format
|
|
175
|
+
*.iws
|
|
176
|
+
|
|
177
|
+
# IntelliJ
|
|
178
|
+
out/
|
|
179
|
+
|
|
180
|
+
# mpeltonen/sbt-idea plugin
|
|
181
|
+
.idea_modules/
|
|
182
|
+
|
|
183
|
+
# JIRA plugin
|
|
184
|
+
atlassian-ide-plugin.xml
|
|
185
|
+
|
|
186
|
+
# Cursive Clojure plugin
|
|
187
|
+
.idea/replstate.xml
|
|
188
|
+
|
|
189
|
+
# Crashlytics plugin (for Android Studio and IntelliJ)
|
|
190
|
+
com_crashlytics_export_strings.xml
|
|
191
|
+
crashlytics.properties
|
|
192
|
+
crashlytics-build.properties
|
|
193
|
+
fabric.properties
|
|
194
|
+
|
|
195
|
+
# Editor-based Rest Client
|
|
196
|
+
.idea/httpRequests
|
|
197
|
+
|
|
198
|
+
# Android studio 3.1+ serialized cache file
|
|
199
|
+
.idea/caches/build_file_checksums.ser
|
|
200
|
+
|
|
201
|
+
### macOS template
|
|
202
|
+
# General
|
|
203
|
+
.DS_Store
|
|
204
|
+
.AppleDouble
|
|
205
|
+
.LSOverride
|
|
206
|
+
|
|
207
|
+
# Icon must end with two \r
|
|
208
|
+
Icon
|
|
209
|
+
|
|
210
|
+
# Thumbnails
|
|
211
|
+
._*
|
|
212
|
+
|
|
213
|
+
# Files that might appear in the root of a volume
|
|
214
|
+
.DocumentRevisions-V100
|
|
215
|
+
.fseventsd
|
|
216
|
+
.Spotlight-V100
|
|
217
|
+
.TemporaryItems
|
|
218
|
+
.Trashes
|
|
219
|
+
.VolumeIcon.icns
|
|
220
|
+
.com.apple.timemachine.donotpresent
|
|
221
|
+
|
|
222
|
+
# Directories potentially created on remote AFP share
|
|
223
|
+
.AppleDB
|
|
224
|
+
.AppleDesktop
|
|
225
|
+
Network Trash Folder
|
|
226
|
+
Temporary Items
|
|
227
|
+
.apdisk
|
|
228
|
+
|
|
229
|
+
### JupyterNotebooks template
|
|
230
|
+
# gitignore template for Jupyter Notebooks
|
|
231
|
+
# website: http://jupyter.org/
|
|
232
|
+
|
|
233
|
+
.ipynb_checkpoints
|
|
234
|
+
*/.ipynb_checkpoints/*
|
|
235
|
+
|
|
236
|
+
# Remove previous ipynb_checkpoints
|
|
237
|
+
# git rm -r .ipynb_checkpoints/
|
|
238
|
+
#
|
|
239
|
+
|
|
240
|
+
# VSCode
|
|
241
|
+
.vscode
|
|
242
|
+
.vscode/
|
|
243
|
+
|
|
244
|
+
# Neovim
|
|
245
|
+
.nvimlog
|
|
246
|
+
|
|
247
|
+
/.idea/codeStyles/codeStyleConfig.xml
|
|
248
|
+
/.idea/misc.xml
|
|
249
|
+
/.idea/modules.xml
|
|
250
|
+
/.idea/inspectionProfiles/profiles_settings.xml
|
|
251
|
+
/.idea/vcs.xml
|
|
252
|
+
/.idea/PyhDToolkit.iml
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
{
|
|
2
|
+
"creators": [
|
|
3
|
+
{
|
|
4
|
+
"name": "OMC-Team",
|
|
5
|
+
"affiliation": "CERN"
|
|
6
|
+
},
|
|
7
|
+
{
|
|
8
|
+
"name": "Michael Hofer",
|
|
9
|
+
"affiliation": "CERN",
|
|
10
|
+
"orcid": "0000-0001-6173-0232"
|
|
11
|
+
},
|
|
12
|
+
{
|
|
13
|
+
"name": "Joschua Dilly",
|
|
14
|
+
"affiliation": "CERN",
|
|
15
|
+
"orcid": "0000-0001-7864-5448"
|
|
16
|
+
},
|
|
17
|
+
{
|
|
18
|
+
"name": "Felix Soubelet",
|
|
19
|
+
"affiliation": "University of Liverpool & CERN",
|
|
20
|
+
"orcid": "0000-0001-8012-1440"
|
|
21
|
+
},
|
|
22
|
+
{
|
|
23
|
+
"name": "Lukáš Malina",
|
|
24
|
+
"affiliation": "CERN",
|
|
25
|
+
"orcid": "0000-0002-4673-6035"
|
|
26
|
+
},
|
|
27
|
+
{
|
|
28
|
+
"name": "Maël Le Garrec",
|
|
29
|
+
"affiliation": "CERN",
|
|
30
|
+
"orcid": "0000-0002-8146-2340"
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
"name": "Jaime Maria Coello De Portugal - Martinez Vazquez",
|
|
34
|
+
"affiliation": "CERN",
|
|
35
|
+
"orcid": "0000-0002-6899-3809"
|
|
36
|
+
},
|
|
37
|
+
{
|
|
38
|
+
"name": "Rogelio Tomas Garcia",
|
|
39
|
+
"affiliation": "CERN",
|
|
40
|
+
"orcid": "0000-0002-9857-1703"
|
|
41
|
+
},
|
|
42
|
+
{
|
|
43
|
+
"name": "Tobias Persson",
|
|
44
|
+
"affiliation": "CERN"
|
|
45
|
+
}
|
|
46
|
+
],
|
|
47
|
+
"title": "Turn-by-Turn",
|
|
48
|
+
"description": "Python 3 package I/O of turn-by-turn BPM measurements data from different particle accelerators."
|
|
49
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2021 pylhc/OMC-Team
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: turn_by_turn
|
|
3
|
+
Version: 0.9.0
|
|
4
|
+
Summary: Read and write turn-by-turn measurement files from different particle accelerator formats.
|
|
5
|
+
Project-URL: homepage, https://github.com/pylhc/turn_by_turn
|
|
6
|
+
Project-URL: repository, https://github.com/pylhc/turn_by_turn
|
|
7
|
+
Project-URL: documentation, https://pylhc.github.io/turn_by_turn/
|
|
8
|
+
Author-email: OMC Team <pylhc@github.com>
|
|
9
|
+
License-Expression: MIT
|
|
10
|
+
License-File: LICENSE
|
|
11
|
+
Classifier: Development Status :: 5 - Production/Stable
|
|
12
|
+
Classifier: Intended Audience :: Science/Research
|
|
13
|
+
Classifier: Natural Language :: English
|
|
14
|
+
Classifier: Operating System :: OS Independent
|
|
15
|
+
Classifier: Programming Language :: Python :: 3 :: Only
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
19
|
+
Classifier: Programming Language :: Python :: Implementation :: CPython
|
|
20
|
+
Classifier: Topic :: Scientific/Engineering
|
|
21
|
+
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
22
|
+
Classifier: Typing :: Typed
|
|
23
|
+
Requires-Python: >=3.10
|
|
24
|
+
Requires-Dist: h5py>=2.9
|
|
25
|
+
Requires-Dist: numpy>=1.24
|
|
26
|
+
Requires-Dist: pandas>=2.1
|
|
27
|
+
Requires-Dist: scipy>=1.5
|
|
28
|
+
Requires-Dist: sdds>=0.4
|
|
29
|
+
Provides-Extra: all
|
|
30
|
+
Requires-Dist: pytest-cov>=2.9; extra == 'all'
|
|
31
|
+
Requires-Dist: pytest>=7.0; extra == 'all'
|
|
32
|
+
Requires-Dist: setuptools>=65; extra == 'all'
|
|
33
|
+
Requires-Dist: sphinx-rtd-theme>=2.0; extra == 'all'
|
|
34
|
+
Requires-Dist: sphinx>=7.0; extra == 'all'
|
|
35
|
+
Requires-Dist: tfs-pandas>=4.0.0; extra == 'all'
|
|
36
|
+
Requires-Dist: xpart>=0.23.0; extra == 'all'
|
|
37
|
+
Requires-Dist: xtrack>=0.84.7; extra == 'all'
|
|
38
|
+
Provides-Extra: doc
|
|
39
|
+
Requires-Dist: sphinx-rtd-theme>=2.0; extra == 'doc'
|
|
40
|
+
Requires-Dist: sphinx>=7.0; extra == 'doc'
|
|
41
|
+
Provides-Extra: madng
|
|
42
|
+
Requires-Dist: tfs-pandas>=4.0.0; extra == 'madng'
|
|
43
|
+
Provides-Extra: test
|
|
44
|
+
Requires-Dist: pytest-cov>=2.9; extra == 'test'
|
|
45
|
+
Requires-Dist: pytest>=7.0; extra == 'test'
|
|
46
|
+
Requires-Dist: setuptools>=65; extra == 'test'
|
|
47
|
+
Requires-Dist: tfs-pandas>=4.0.0; extra == 'test'
|
|
48
|
+
Requires-Dist: xpart>=0.23.0; extra == 'test'
|
|
49
|
+
Requires-Dist: xtrack>=0.84.7; extra == 'test'
|
|
50
|
+
Provides-Extra: xtrack
|
|
51
|
+
Requires-Dist: setuptools>=65; extra == 'xtrack'
|
|
52
|
+
Requires-Dist: xpart>=0.23.0; extra == 'xtrack'
|
|
53
|
+
Requires-Dist: xtrack>=0.84.7; extra == 'xtrack'
|
|
54
|
+
Description-Content-Type: text/markdown
|
|
55
|
+
|
|
56
|
+
# Turn-By-Turn
|
|
57
|
+
|
|
58
|
+
[](https://github.com/pylhc/turn_by_turn/actions?query=workflow%3A%22Cron+Testing%22)
|
|
59
|
+
[](https://codeclimate.com/github/pylhc/turn_by_turn)
|
|
60
|
+
[](https://codeclimate.com/github/pylhc/turn_by_turn)
|
|
61
|
+
<!-- [](https://github.com/pylhc/turn_by_turn/) -->
|
|
62
|
+
[](https://pypi.org/project/turn_by_turn/)
|
|
63
|
+
[](https://github.com/pylhc/turn_by_turn/)
|
|
64
|
+
[](https://anaconda.org/conda-forge/turn_by_turn)
|
|
65
|
+
[](https://doi.org/10.5281/zenodo.5554916)
|
|
66
|
+
|
|
67
|
+
This package provides reading functionality for turn-by-turn BPM measurements data from different particle accelerators.
|
|
68
|
+
It also provides writing functionality in the `LHC`'s own SDDS format, through our `sdds` package.
|
|
69
|
+
Files are read into a custom-made `TbtData` dataclass encompassing the relevant information.
|
|
70
|
+
|
|
71
|
+
See the [API documentation](https://pylhc.github.io/turn_by_turn/) for details.
|
|
72
|
+
|
|
73
|
+
## Installing
|
|
74
|
+
|
|
75
|
+
Installation is easily done via `pip`:
|
|
76
|
+
```bash
|
|
77
|
+
python -m pip install turn_by_turn
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
One can also install in a `conda` environment via the `conda-forge` channel with:
|
|
81
|
+
```bash
|
|
82
|
+
conda install -c conda-forge turn_by_turn
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
## Example Usage
|
|
86
|
+
|
|
87
|
+
The package is imported as `turn_by_turn`, and exports top-level functions for reading and writing:
|
|
88
|
+
```python
|
|
89
|
+
import turn_by_turn as tbt
|
|
90
|
+
|
|
91
|
+
# Loading a file is simple and returns a custom dataclass named TbtData
|
|
92
|
+
data: tbt.TbtData = tbt.read("Beam2@BunchTurn@2018_12_02@20_08_49_739.sdds", datatype="lhc")
|
|
93
|
+
|
|
94
|
+
# Easily access relevant information from the loaded data: transverse data, measurement date,
|
|
95
|
+
# number of turns, bunches and IDs of the recorded bunches
|
|
96
|
+
first_bunch_transverse_positions: tbt.TransverseData = data.matrices[0]
|
|
97
|
+
measurement_date = data.date # a datetime.datetime object
|
|
98
|
+
|
|
99
|
+
# Transverse positions are recorded as pandas DataFrames
|
|
100
|
+
first_bunch_x = first_bunch_transverse_positions.X.copy()
|
|
101
|
+
first_bunch_y = first_bunch_transverse_positions.Y.copy()
|
|
102
|
+
|
|
103
|
+
# Do any operations with these as you usually do with pandas
|
|
104
|
+
first_bunch_mean_x = first_bunch_x.mean()
|
|
105
|
+
|
|
106
|
+
# Average over all bunches/particles at all used BPMs from the measurement
|
|
107
|
+
averaged_tbt: tbt.TbtData = tbt.utils.generate_average_tbtdata(data)
|
|
108
|
+
|
|
109
|
+
# Writing out to disk (in the LHC's SDDS format) is simple too, potentially with added noise
|
|
110
|
+
tbt.write("path_to_output.sdds", averaged_tbt, noise=1e-5)
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
## License
|
|
114
|
+
|
|
115
|
+
This project is licensed under the `MIT License` - see the [LICENSE](LICENSE) file for details.
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
# Turn-By-Turn
|
|
2
|
+
|
|
3
|
+
[](https://github.com/pylhc/turn_by_turn/actions?query=workflow%3A%22Cron+Testing%22)
|
|
4
|
+
[](https://codeclimate.com/github/pylhc/turn_by_turn)
|
|
5
|
+
[](https://codeclimate.com/github/pylhc/turn_by_turn)
|
|
6
|
+
<!-- [](https://github.com/pylhc/turn_by_turn/) -->
|
|
7
|
+
[](https://pypi.org/project/turn_by_turn/)
|
|
8
|
+
[](https://github.com/pylhc/turn_by_turn/)
|
|
9
|
+
[](https://anaconda.org/conda-forge/turn_by_turn)
|
|
10
|
+
[](https://doi.org/10.5281/zenodo.5554916)
|
|
11
|
+
|
|
12
|
+
This package provides reading functionality for turn-by-turn BPM measurements data from different particle accelerators.
|
|
13
|
+
It also provides writing functionality in the `LHC`'s own SDDS format, through our `sdds` package.
|
|
14
|
+
Files are read into a custom-made `TbtData` dataclass encompassing the relevant information.
|
|
15
|
+
|
|
16
|
+
See the [API documentation](https://pylhc.github.io/turn_by_turn/) for details.
|
|
17
|
+
|
|
18
|
+
## Installing
|
|
19
|
+
|
|
20
|
+
Installation is easily done via `pip`:
|
|
21
|
+
```bash
|
|
22
|
+
python -m pip install turn_by_turn
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
One can also install in a `conda` environment via the `conda-forge` channel with:
|
|
26
|
+
```bash
|
|
27
|
+
conda install -c conda-forge turn_by_turn
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
## Example Usage
|
|
31
|
+
|
|
32
|
+
The package is imported as `turn_by_turn`, and exports top-level functions for reading and writing:
|
|
33
|
+
```python
|
|
34
|
+
import turn_by_turn as tbt
|
|
35
|
+
|
|
36
|
+
# Loading a file is simple and returns a custom dataclass named TbtData
|
|
37
|
+
data: tbt.TbtData = tbt.read("Beam2@BunchTurn@2018_12_02@20_08_49_739.sdds", datatype="lhc")
|
|
38
|
+
|
|
39
|
+
# Easily access relevant information from the loaded data: transverse data, measurement date,
|
|
40
|
+
# number of turns, bunches and IDs of the recorded bunches
|
|
41
|
+
first_bunch_transverse_positions: tbt.TransverseData = data.matrices[0]
|
|
42
|
+
measurement_date = data.date # a datetime.datetime object
|
|
43
|
+
|
|
44
|
+
# Transverse positions are recorded as pandas DataFrames
|
|
45
|
+
first_bunch_x = first_bunch_transverse_positions.X.copy()
|
|
46
|
+
first_bunch_y = first_bunch_transverse_positions.Y.copy()
|
|
47
|
+
|
|
48
|
+
# Do any operations with these as you usually do with pandas
|
|
49
|
+
first_bunch_mean_x = first_bunch_x.mean()
|
|
50
|
+
|
|
51
|
+
# Average over all bunches/particles at all used BPMs from the measurement
|
|
52
|
+
averaged_tbt: tbt.TbtData = tbt.utils.generate_average_tbtdata(data)
|
|
53
|
+
|
|
54
|
+
# Writing out to disk (in the LHC's SDDS format) is simple too, potentially with added noise
|
|
55
|
+
tbt.write("path_to_output.sdds", averaged_tbt, noise=1e-5)
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
## License
|
|
59
|
+
|
|
60
|
+
This project is licensed under the `MIT License` - see the [LICENSE](LICENSE) file for details.
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["hatchling"]
|
|
3
|
+
build-backend = "hatchling.build"
|
|
4
|
+
|
|
5
|
+
[tool.hatch.version]
|
|
6
|
+
path = "turn_by_turn/__init__.py"
|
|
7
|
+
|
|
8
|
+
[tool.hatch.build.targets.sdist]
|
|
9
|
+
exclude = [
|
|
10
|
+
"/.github",
|
|
11
|
+
"/doc",
|
|
12
|
+
"/tests",
|
|
13
|
+
]
|
|
14
|
+
|
|
15
|
+
[tool.hatch.build.targets.wheel]
|
|
16
|
+
packages = ["turn_by_turn"]
|
|
17
|
+
|
|
18
|
+
[project]
|
|
19
|
+
name = "turn_by_turn"
|
|
20
|
+
readme = "README.md"
|
|
21
|
+
description = "Read and write turn-by-turn measurement files from different particle accelerator formats."
|
|
22
|
+
authors = [
|
|
23
|
+
{name = "OMC Team", email = "pylhc@github.com"}, # see zenodo file / commits for details
|
|
24
|
+
]
|
|
25
|
+
license = "MIT"
|
|
26
|
+
dynamic = ["version"]
|
|
27
|
+
requires-python = ">=3.10"
|
|
28
|
+
|
|
29
|
+
classifiers = [
|
|
30
|
+
"Development Status :: 5 - Production/Stable",
|
|
31
|
+
"Intended Audience :: Science/Research",
|
|
32
|
+
"Natural Language :: English",
|
|
33
|
+
"Operating System :: OS Independent",
|
|
34
|
+
"Programming Language :: Python :: 3 :: Only",
|
|
35
|
+
"Programming Language :: Python :: 3.10",
|
|
36
|
+
"Programming Language :: Python :: 3.11",
|
|
37
|
+
"Programming Language :: Python :: 3.12",
|
|
38
|
+
"Programming Language :: Python :: Implementation :: CPython",
|
|
39
|
+
"Topic :: Scientific/Engineering",
|
|
40
|
+
"Topic :: Software Development :: Libraries :: Python Modules",
|
|
41
|
+
"Typing :: Typed",
|
|
42
|
+
]
|
|
43
|
+
|
|
44
|
+
dependencies = [
|
|
45
|
+
"numpy >= 1.24",
|
|
46
|
+
"scipy >= 1.5",
|
|
47
|
+
"pandas >= 2.1",
|
|
48
|
+
"sdds >= 0.4",
|
|
49
|
+
"h5py >= 2.9",
|
|
50
|
+
]
|
|
51
|
+
|
|
52
|
+
[project.optional-dependencies]
|
|
53
|
+
madng = [
|
|
54
|
+
"tfs-pandas >= 4.0.0", # for reading MAD-NG files (Could do everything in memory with just pandas)
|
|
55
|
+
]
|
|
56
|
+
|
|
57
|
+
xtrack = [
|
|
58
|
+
"xtrack >= 0.84.7", # for xtrack
|
|
59
|
+
"setuptools >= 65", # for xtrack
|
|
60
|
+
"xpart >= 0.23.0", # for xtrack
|
|
61
|
+
]
|
|
62
|
+
|
|
63
|
+
test = [
|
|
64
|
+
"pytest>=7.0",
|
|
65
|
+
"pytest-cov>=2.9",
|
|
66
|
+
"turn_by_turn[madng]",
|
|
67
|
+
"turn_by_turn[xtrack]",
|
|
68
|
+
]
|
|
69
|
+
|
|
70
|
+
doc = [
|
|
71
|
+
"sphinx >= 7.0",
|
|
72
|
+
"sphinx_rtd_theme >= 2.0",
|
|
73
|
+
]
|
|
74
|
+
|
|
75
|
+
all = [
|
|
76
|
+
"turn_by_turn[test]",
|
|
77
|
+
"turn_by_turn[doc]",
|
|
78
|
+
"turn_by_turn[madng]",
|
|
79
|
+
"turn_by_turn[xtrack]",
|
|
80
|
+
]
|
|
81
|
+
|
|
82
|
+
[project.urls]
|
|
83
|
+
homepage = "https://github.com/pylhc/turn_by_turn"
|
|
84
|
+
repository = "https://github.com/pylhc/turn_by_turn"
|
|
85
|
+
documentation = "https://pylhc.github.io/turn_by_turn/"
|
|
86
|
+
# changelog = "https://github.com/pylhc/turn_by_turn/blob/master/CHANGELOG.md"
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"""Exposes TbtData, read_tbt and write_tbt directly in the package's namespace."""
|
|
2
|
+
|
|
3
|
+
from .io import convert_to_tbt, read_tbt, write_tbt
|
|
4
|
+
from .structures import TbtData, TransverseData # noqa: F401
|
|
5
|
+
|
|
6
|
+
__title__ = "turn_by_turn"
|
|
7
|
+
__description__ = "Read and write turn-by-turn measurement files from different particle accelerator formats."
|
|
8
|
+
__url__ = "https://github.com/pylhc/turn_by_turn"
|
|
9
|
+
__version__ = "0.9.0"
|
|
10
|
+
__author__ = "pylhc"
|
|
11
|
+
__author_email__ = "pylhc@github.com"
|
|
12
|
+
__license__ = "MIT"
|
|
13
|
+
|
|
14
|
+
# aliases
|
|
15
|
+
write = write_tbt
|
|
16
|
+
read = read_tbt
|
|
17
|
+
convert = convert_to_tbt
|
|
18
|
+
|
|
19
|
+
# Importing * is a bad practice and you should be punished for using it
|
|
20
|
+
__all__ = []
|