MNeuEventLib 0.2.1__tar.gz → 0.4.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.
- mneueventlib-0.4.0/.github/workflows/push.yml +111 -0
- {mneueventlib-0.2.1 → mneueventlib-0.4.0}/.github/workflows/release.yml +0 -15
- {mneueventlib-0.2.1 → mneueventlib-0.4.0}/Cargo.lock +48 -40
- {mneueventlib-0.2.1 → mneueventlib-0.4.0}/Cargo.toml +3 -1
- mneueventlib-0.4.0/MNeuEventLib/make_default.py +163 -0
- mneueventlib-0.4.0/MNeuEventLib/test_helpers.py +40 -0
- {mneueventlib-0.2.1 → mneueventlib-0.4.0}/PKG-INFO +1 -1
- {mneueventlib-0.2.1 → mneueventlib-0.4.0}/README.md +8 -0
- {mneueventlib-0.2.1 → mneueventlib-0.4.0}/docs/source/how-to/filtering.ipynb +3 -3
- {mneueventlib-0.2.1 → mneueventlib-0.4.0}/docs/source/index.rst +2 -2
- {mneueventlib-0.2.1 → mneueventlib-0.4.0}/docs/source/install.rst +8 -1
- {mneueventlib-0.2.1 → mneueventlib-0.4.0}/docs/source/tutorials/batch_processing.ipynb +148 -9
- {mneueventlib-0.2.1 → mneueventlib-0.4.0}/docs/source/tutorials/getting_started.ipynb +3 -1
- mneueventlib-0.4.0/files/README.md +1 -0
- mneueventlib-0.4.0/files/muon_ref.nxs +0 -0
- {mneueventlib-0.2.1 → mneueventlib-0.4.0}/pyproject.toml +1 -0
- mneueventlib-0.4.0/src/batch/functions.rs +292 -0
- mneueventlib-0.4.0/src/batch/interface.rs +1468 -0
- mneueventlib-0.4.0/src/batch/mod.rs +7 -0
- mneueventlib-0.4.0/src/consts.rs +25 -0
- {mneueventlib-0.2.1 → mneueventlib-0.4.0}/src/data/frame_data.rs +2 -2
- {mneueventlib-0.2.1 → mneueventlib-0.4.0}/src/data/mod.rs +1 -1
- {mneueventlib-0.2.1 → mneueventlib-0.4.0}/src/data/nexus_data.rs +13 -8
- {mneueventlib-0.2.1 → mneueventlib-0.4.0}/src/data/sample_logs.rs +27 -37
- {mneueventlib-0.2.1 → mneueventlib-0.4.0}/src/data/save/instrument.rs +16 -10
- {mneueventlib-0.2.1 → mneueventlib-0.4.0}/src/data/save/mod.rs +1 -0
- {mneueventlib-0.2.1 → mneueventlib-0.4.0}/src/data/save/periods.rs +1 -0
- {mneueventlib-0.2.1 → mneueventlib-0.4.0}/src/data/save/sample_logs.rs +12 -6
- mneueventlib-0.4.0/src/data/save/sanitise/mod.rs +8 -0
- mneueventlib-0.4.0/src/data/save/sanitise/nexus_data.rs +775 -0
- mneueventlib-0.4.0/src/data/save/sanitise/utils.rs +426 -0
- {mneueventlib-0.2.1 → mneueventlib-0.4.0}/src/data/save/utils.rs +13 -12
- {mneueventlib-0.2.1 → mneueventlib-0.4.0}/src/data/save/wimda.rs +19 -12
- {mneueventlib-0.2.1 → mneueventlib-0.4.0}/src/filters/api.rs +605 -277
- {mneueventlib-0.2.1 → mneueventlib-0.4.0}/src/filters/filtering.rs +11 -11
- {mneueventlib-0.2.1 → mneueventlib-0.4.0}/src/interface.rs +57 -9
- {mneueventlib-0.2.1 → mneueventlib-0.4.0}/src/lib.rs +9 -2
- {mneueventlib-0.2.1 → mneueventlib-0.4.0}/src/stats.rs +195 -132
- {mneueventlib-0.2.1 → mneueventlib-0.4.0}/src/test_utils.rs +10 -0
- {mneueventlib-0.2.1 → mneueventlib-0.4.0}/src/utils.rs +5 -2
- mneueventlib-0.4.0/tests/integration/test_mantid.py +352 -0
- {mneueventlib-0.2.1 → mneueventlib-0.4.0}/tests/test_data/HIFI00195790.nxs +0 -0
- mneueventlib-0.2.1/.github/workflows/push.yml +0 -41
- mneueventlib-0.2.1/src/batch_interface.rs +0 -777
- mneueventlib-0.2.1/src/consts.rs +0 -3
- {mneueventlib-0.2.1 → mneueventlib-0.4.0}/.github/workflows/label_merge_conflicts.yml +0 -0
- {mneueventlib-0.2.1 → mneueventlib-0.4.0}/.gitignore +0 -0
- {mneueventlib-0.2.1 → mneueventlib-0.4.0}/.readthedocs.yaml +0 -0
- {mneueventlib-0.2.1 → mneueventlib-0.4.0}/LICENSE +0 -0
- {mneueventlib-0.2.1 → mneueventlib-0.4.0}/MNeuEventLib/__init__.py +0 -0
- {mneueventlib-0.2.1 → mneueventlib-0.4.0}/MNeuEventLib/plotting.py +0 -0
- {mneueventlib-0.2.1 → mneueventlib-0.4.0}/bench.py +0 -0
- {mneueventlib-0.2.1 → mneueventlib-0.4.0}/docs/Makefile +0 -0
- {mneueventlib-0.2.1 → mneueventlib-0.4.0}/docs/make.bat +0 -0
- {mneueventlib-0.2.1 → mneueventlib-0.4.0}/docs/source/_static/HIFI00195790.nxs +0 -0
- {mneueventlib-0.2.1 → mneueventlib-0.4.0}/docs/source/_static/api/README.md +0 -0
- {mneueventlib-0.2.1 → mneueventlib-0.4.0}/docs/source/api.rst +0 -0
- {mneueventlib-0.2.1 → mneueventlib-0.4.0}/docs/source/conf.py +0 -0
- {mneueventlib-0.2.1 → mneueventlib-0.4.0}/docs/source/how-to/create_plots.ipynb +0 -0
- {mneueventlib-0.2.1 → mneueventlib-0.4.0}/docs/source/how-to/index.rst +0 -0
- {mneueventlib-0.2.1 → mneueventlib-0.4.0}/docs/source/tutorials/index.rst +0 -0
- {mneueventlib-0.2.1 → mneueventlib-0.4.0}/src/filters/mod.rs +0 -0
- {mneueventlib-0.2.1 → mneueventlib-0.4.0}/src/filters/weights.rs +0 -0
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
name:
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
|
|
6
|
+
env:
|
|
7
|
+
CARGO_TERM_COLOR: always
|
|
8
|
+
|
|
9
|
+
jobs:
|
|
10
|
+
format:
|
|
11
|
+
name: Check formatting
|
|
12
|
+
runs-on: ubuntu-slim
|
|
13
|
+
steps:
|
|
14
|
+
- uses: actions/checkout@v7
|
|
15
|
+
- uses: dtolnay/rust-toolchain@stable
|
|
16
|
+
with:
|
|
17
|
+
components: rustfmt
|
|
18
|
+
- run: cargo fmt --check
|
|
19
|
+
|
|
20
|
+
lint:
|
|
21
|
+
name: Lint
|
|
22
|
+
runs-on: ubuntu-latest
|
|
23
|
+
steps:
|
|
24
|
+
- uses: actions/checkout@v7
|
|
25
|
+
- uses: dtolnay/rust-toolchain@stable
|
|
26
|
+
with:
|
|
27
|
+
components: clippy
|
|
28
|
+
- run: cargo clippy --all-targets --all-features -- -D warnings
|
|
29
|
+
|
|
30
|
+
linux:
|
|
31
|
+
name: Run unit tests
|
|
32
|
+
needs: [lint, format]
|
|
33
|
+
strategy:
|
|
34
|
+
matrix:
|
|
35
|
+
os: [windows-latest, ubuntu-latest, macOS-latest]
|
|
36
|
+
runs-on: ${{ matrix.os }}
|
|
37
|
+
steps:
|
|
38
|
+
- uses: actions/checkout@v7
|
|
39
|
+
- uses: dtolnay/rust-toolchain@stable
|
|
40
|
+
- run: cargo test --verbose
|
|
41
|
+
|
|
42
|
+
run_integration_tests:
|
|
43
|
+
name: Integration tests
|
|
44
|
+
needs: [lint, format]
|
|
45
|
+
strategy:
|
|
46
|
+
fail-fast: false
|
|
47
|
+
matrix:
|
|
48
|
+
os: [windows-latest, ubuntu-latest, macos-latest]
|
|
49
|
+
build: [stable, nightly]
|
|
50
|
+
include:
|
|
51
|
+
- build: stable
|
|
52
|
+
mantid_channel: 'mantid'
|
|
53
|
+
- build: nightly
|
|
54
|
+
mantid_channel: 'mantid/label/nightly'
|
|
55
|
+
runs-on: ${{ matrix.os }}
|
|
56
|
+
steps:
|
|
57
|
+
- uses: actions/checkout@v7
|
|
58
|
+
with:
|
|
59
|
+
fetch-depth: "0"
|
|
60
|
+
|
|
61
|
+
- name: Setup Conda
|
|
62
|
+
uses: conda-incubator/setup-miniconda@v4
|
|
63
|
+
with:
|
|
64
|
+
miniconda-version: "latest"
|
|
65
|
+
mamba-version: "*"
|
|
66
|
+
channels: ${{ matrix.mantid_channel }},conda-forge
|
|
67
|
+
channel-priority: flexible
|
|
68
|
+
conda-remove-defaults: true
|
|
69
|
+
activate-environment: mantid-env
|
|
70
|
+
auto-activate-base: false
|
|
71
|
+
|
|
72
|
+
- name: Install Mantid and test deps
|
|
73
|
+
shell: bash -el {0}
|
|
74
|
+
env:
|
|
75
|
+
MSYS_NO_PATHCONV: 1
|
|
76
|
+
run: mamba install -y -n mantid-env mantid pytest pip
|
|
77
|
+
|
|
78
|
+
- name: Show resolved python version
|
|
79
|
+
shell: bash -el {0}
|
|
80
|
+
run: |
|
|
81
|
+
conda activate mantid-env
|
|
82
|
+
python --version
|
|
83
|
+
|
|
84
|
+
- name: Install maturin into mantid-env
|
|
85
|
+
shell: bash -el {0}
|
|
86
|
+
run: |
|
|
87
|
+
conda activate mantid-env
|
|
88
|
+
python -m pip install maturin
|
|
89
|
+
|
|
90
|
+
- name: Verify test deps installed
|
|
91
|
+
shell: bash -el {0}
|
|
92
|
+
run: |
|
|
93
|
+
mamba list -n mantid-env pytest
|
|
94
|
+
conda activate mantid-env
|
|
95
|
+
python -c "import pytest; print(pytest.__version__)"
|
|
96
|
+
|
|
97
|
+
- name: Install Rust toolchain
|
|
98
|
+
uses: dtolnay/rust-toolchain@stable
|
|
99
|
+
|
|
100
|
+
- name: Build and install Rust extension into conda env
|
|
101
|
+
shell: bash -el {0}
|
|
102
|
+
run: |
|
|
103
|
+
conda activate mantid-env
|
|
104
|
+
python -m maturin develop --release
|
|
105
|
+
|
|
106
|
+
- name: Run integration tests
|
|
107
|
+
shell: bash -el {0}
|
|
108
|
+
run: |
|
|
109
|
+
conda activate mantid-env
|
|
110
|
+
python -m pytest tests/integration/
|
|
111
|
+
|
|
@@ -22,16 +22,8 @@ jobs:
|
|
|
22
22
|
platform:
|
|
23
23
|
- runner: ubuntu-latest
|
|
24
24
|
target: x86_64
|
|
25
|
-
- runner: ubuntu-latest
|
|
26
|
-
target: x86
|
|
27
25
|
- runner: ubuntu-latest
|
|
28
26
|
target: aarch64
|
|
29
|
-
- runner: ubuntu-latest
|
|
30
|
-
target: armv7
|
|
31
|
-
- runner: ubuntu-latest
|
|
32
|
-
target: s390x
|
|
33
|
-
- runner: ubuntu-latest
|
|
34
|
-
target: ppc64le
|
|
35
27
|
steps:
|
|
36
28
|
- uses: actions/checkout@v6
|
|
37
29
|
- uses: actions/setup-python@v6
|
|
@@ -59,12 +51,8 @@ jobs:
|
|
|
59
51
|
platform:
|
|
60
52
|
- runner: ubuntu-latest
|
|
61
53
|
target: x86_64
|
|
62
|
-
- runner: ubuntu-latest
|
|
63
|
-
target: x86
|
|
64
54
|
- runner: ubuntu-latest
|
|
65
55
|
target: aarch64
|
|
66
|
-
- runner: ubuntu-latest
|
|
67
|
-
target: armv7
|
|
68
56
|
steps:
|
|
69
57
|
- uses: actions/checkout@v6
|
|
70
58
|
- uses: actions/setup-python@v6
|
|
@@ -93,9 +81,6 @@ jobs:
|
|
|
93
81
|
- runner: windows-latest
|
|
94
82
|
target: x64
|
|
95
83
|
python_arch: x64
|
|
96
|
-
- runner: windows-latest
|
|
97
|
-
target: x86
|
|
98
|
-
python_arch: x86
|
|
99
84
|
- runner: windows-11-arm
|
|
100
85
|
target: aarch64
|
|
101
86
|
python_arch: arm64
|
|
@@ -4,15 +4,17 @@ version = 4
|
|
|
4
4
|
|
|
5
5
|
[[package]]
|
|
6
6
|
name = "MNeuEventLib"
|
|
7
|
-
version = "0.
|
|
7
|
+
version = "0.4.0"
|
|
8
8
|
dependencies = [
|
|
9
9
|
"anyhow",
|
|
10
10
|
"chrono",
|
|
11
11
|
"hdf5-metno",
|
|
12
|
+
"hdf5-metno-sys",
|
|
12
13
|
"ndarray",
|
|
13
14
|
"numpy",
|
|
14
15
|
"pyo3",
|
|
15
16
|
"rayon",
|
|
17
|
+
"seq-macro",
|
|
16
18
|
"serde",
|
|
17
19
|
"serde_json",
|
|
18
20
|
"tabled",
|
|
@@ -75,9 +77,9 @@ checksum = "175812e0be2bccb6abe50bb8d566126198344f707e304f45c648fd8f2cc0365e"
|
|
|
75
77
|
|
|
76
78
|
[[package]]
|
|
77
79
|
name = "cc"
|
|
78
|
-
version = "1.
|
|
80
|
+
version = "1.6.0"
|
|
79
81
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
80
|
-
checksum = "
|
|
82
|
+
checksum = "f74872d07caf508b30a21f6836e7d7016a2eaf7d9ff4f48deaa58cd8a0407630"
|
|
81
83
|
dependencies = [
|
|
82
84
|
"find-msvc-tools",
|
|
83
85
|
"shlex",
|
|
@@ -85,9 +87,9 @@ dependencies = [
|
|
|
85
87
|
|
|
86
88
|
[[package]]
|
|
87
89
|
name = "cfg-if"
|
|
88
|
-
version = "1.0.
|
|
90
|
+
version = "1.0.5"
|
|
89
91
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
90
|
-
checksum = "
|
|
92
|
+
checksum = "4e7648175b45a9a48536d676f68d918270699102aa8dab5496df06904c914600"
|
|
91
93
|
|
|
92
94
|
[[package]]
|
|
93
95
|
name = "chrono"
|
|
@@ -144,9 +146,9 @@ checksum = "a31eee39dddec8330830986fcd7625edb5a24ec90ea038215273bbc3adb08ac6"
|
|
|
144
146
|
|
|
145
147
|
[[package]]
|
|
146
148
|
name = "either"
|
|
147
|
-
version = "1.
|
|
149
|
+
version = "1.19.0"
|
|
148
150
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
149
|
-
checksum = "
|
|
151
|
+
checksum = "0e9c71c2167ca323c882b99918929403426e2373ea17242ff5653e0d5e1058be"
|
|
150
152
|
|
|
151
153
|
[[package]]
|
|
152
154
|
name = "equivalent"
|
|
@@ -172,9 +174,9 @@ checksum = "da7c62ceae207dd37ea5b845da6a0696c799f85e97da1ab5b7910be3c1c80223"
|
|
|
172
174
|
|
|
173
175
|
[[package]]
|
|
174
176
|
name = "find-msvc-tools"
|
|
175
|
-
version = "0.1.
|
|
177
|
+
version = "0.1.14"
|
|
176
178
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
177
|
-
checksum = "
|
|
179
|
+
checksum = "aedcfb3409746eddb02b9e19ebda1c3394f759a152e48ee875a0844d1b955484"
|
|
178
180
|
|
|
179
181
|
[[package]]
|
|
180
182
|
name = "fnv"
|
|
@@ -248,7 +250,7 @@ dependencies = [
|
|
|
248
250
|
"proc-macro-crate",
|
|
249
251
|
"proc-macro2",
|
|
250
252
|
"quote",
|
|
251
|
-
"syn 3.0.
|
|
253
|
+
"syn 3.0.6",
|
|
252
254
|
]
|
|
253
255
|
|
|
254
256
|
[[package]]
|
|
@@ -262,9 +264,9 @@ dependencies = [
|
|
|
262
264
|
|
|
263
265
|
[[package]]
|
|
264
266
|
name = "hdf5-metno-sys"
|
|
265
|
-
version = "0.12.
|
|
267
|
+
version = "0.12.4"
|
|
266
268
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
267
|
-
checksum = "
|
|
269
|
+
checksum = "567a57ee34c38263f551f2cf02b95675def6b91d0e321c5e70f8c6d5ef9cee87"
|
|
268
270
|
dependencies = [
|
|
269
271
|
"hdf5-metno-src",
|
|
270
272
|
"libc",
|
|
@@ -337,9 +339,9 @@ checksum = "8f42a60cbdf9a97f5d2305f08a87dc4e09308d1276d28c869c684d7777685682"
|
|
|
337
339
|
|
|
338
340
|
[[package]]
|
|
339
341
|
name = "js-sys"
|
|
340
|
-
version = "0.3.
|
|
342
|
+
version = "0.3.106"
|
|
341
343
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
342
|
-
checksum = "
|
|
344
|
+
checksum = "7883d941dae510fb2d978fc3fe018c71c9e2892fd38854de3e8b92c2e5ad9cc5"
|
|
343
345
|
dependencies = [
|
|
344
346
|
"cfg-if",
|
|
345
347
|
"futures-util",
|
|
@@ -348,9 +350,9 @@ dependencies = [
|
|
|
348
350
|
|
|
349
351
|
[[package]]
|
|
350
352
|
name = "libc"
|
|
351
|
-
version = "0.2.
|
|
353
|
+
version = "0.2.190"
|
|
352
354
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
353
|
-
checksum = "
|
|
355
|
+
checksum = "ce5d3ddc6d3fa000eb1536d85e147bfe31aacaba692ed6a876f95cb7c855be78"
|
|
354
356
|
|
|
355
357
|
[[package]]
|
|
356
358
|
name = "libloading"
|
|
@@ -716,9 +718,9 @@ checksum = "6b1e7f9a428571be2dc5bc0505c13fb6bf936822b894ec87abf8a08a4e51742d"
|
|
|
716
718
|
|
|
717
719
|
[[package]]
|
|
718
720
|
name = "rustix"
|
|
719
|
-
version = "1.1.
|
|
721
|
+
version = "1.1.5"
|
|
720
722
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
721
|
-
checksum = "
|
|
723
|
+
checksum = "891efababe418670775f199f0d233d84843c227a0949a883ce15b37c78d6629d"
|
|
722
724
|
dependencies = [
|
|
723
725
|
"bitflags",
|
|
724
726
|
"errno",
|
|
@@ -739,6 +741,12 @@ version = "1.2.0"
|
|
|
739
741
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
740
742
|
checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49"
|
|
741
743
|
|
|
744
|
+
[[package]]
|
|
745
|
+
name = "seq-macro"
|
|
746
|
+
version = "0.3.6"
|
|
747
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
748
|
+
checksum = "1bc711410fbe7399f390ca1c3b60ad0f53f80e95c5eb935e52268a0e2cd49acc"
|
|
749
|
+
|
|
742
750
|
[[package]]
|
|
743
751
|
name = "serde"
|
|
744
752
|
version = "1.0.229"
|
|
@@ -766,7 +774,7 @@ checksum = "e7a5d71263a5a7d47b41f6b3f06ba276f10cc18b0931f1799f710578e2309348"
|
|
|
766
774
|
dependencies = [
|
|
767
775
|
"proc-macro2",
|
|
768
776
|
"quote",
|
|
769
|
-
"syn 3.0.
|
|
777
|
+
"syn 3.0.6",
|
|
770
778
|
]
|
|
771
779
|
|
|
772
780
|
[[package]]
|
|
@@ -796,9 +804,9 @@ checksum = "0c790de23124f9ab44544d7ac05d60440adc586479ce501c1d6d7da3cd8c9cf5"
|
|
|
796
804
|
|
|
797
805
|
[[package]]
|
|
798
806
|
name = "smallvec"
|
|
799
|
-
version = "1.16.
|
|
807
|
+
version = "1.16.2"
|
|
800
808
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
801
|
-
checksum = "
|
|
809
|
+
checksum = "f9395f0f0eee849a9b707b2f06bb92a6a422090e2123bb2ef8e87a0e61892a8e"
|
|
802
810
|
|
|
803
811
|
[[package]]
|
|
804
812
|
name = "syn"
|
|
@@ -813,9 +821,9 @@ dependencies = [
|
|
|
813
821
|
|
|
814
822
|
[[package]]
|
|
815
823
|
name = "syn"
|
|
816
|
-
version = "3.0.
|
|
824
|
+
version = "3.0.6"
|
|
817
825
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
818
|
-
checksum = "
|
|
826
|
+
checksum = "8593e8e72159ed2257d083c7a454a85cbf854f37a0966d8d483aff8c8a3ebcee"
|
|
819
827
|
dependencies = [
|
|
820
828
|
"proc-macro2",
|
|
821
829
|
"quote",
|
|
@@ -876,18 +884,18 @@ dependencies = [
|
|
|
876
884
|
|
|
877
885
|
[[package]]
|
|
878
886
|
name = "toml_datetime"
|
|
879
|
-
version = "1.1.
|
|
887
|
+
version = "1.1.2+spec-1.1.0"
|
|
880
888
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
881
|
-
checksum = "
|
|
889
|
+
checksum = "2b86d767906c6c42421dcba507eb9d203e779497710a47782a224bb871653053"
|
|
882
890
|
dependencies = [
|
|
883
891
|
"serde_core",
|
|
884
892
|
]
|
|
885
893
|
|
|
886
894
|
[[package]]
|
|
887
895
|
name = "toml_edit"
|
|
888
|
-
version = "0.25.
|
|
896
|
+
version = "0.25.16+spec-1.1.0"
|
|
889
897
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
890
|
-
checksum = "
|
|
898
|
+
checksum = "88f38f3af8bf71841c67a990f4e2b52143b2d0a1a994c72513ff4c14977fc722"
|
|
891
899
|
dependencies = [
|
|
892
900
|
"indexmap",
|
|
893
901
|
"toml_datetime",
|
|
@@ -897,18 +905,18 @@ dependencies = [
|
|
|
897
905
|
|
|
898
906
|
[[package]]
|
|
899
907
|
name = "toml_parser"
|
|
900
|
-
version = "1.1.
|
|
908
|
+
version = "1.1.4+spec-1.1.0"
|
|
901
909
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
902
|
-
checksum = "
|
|
910
|
+
checksum = "bed810ee007d8e7f9cf20b4774e7198142fa27186e0f805871da7f3c39eaf333"
|
|
903
911
|
dependencies = [
|
|
904
912
|
"winnow",
|
|
905
913
|
]
|
|
906
914
|
|
|
907
915
|
[[package]]
|
|
908
916
|
name = "unicode-ident"
|
|
909
|
-
version = "1.0.
|
|
917
|
+
version = "1.0.26"
|
|
910
918
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
911
|
-
checksum = "
|
|
919
|
+
checksum = "d245f478577f809a851594d02313b640fb437e0bb33866753cff937863096954"
|
|
912
920
|
|
|
913
921
|
[[package]]
|
|
914
922
|
name = "unicode-width"
|
|
@@ -918,9 +926,9 @@ checksum = "b4ac048d71ede7ee76d585517add45da530660ef4390e49b098733c6e897f254"
|
|
|
918
926
|
|
|
919
927
|
[[package]]
|
|
920
928
|
name = "wasm-bindgen"
|
|
921
|
-
version = "0.2.
|
|
929
|
+
version = "0.2.129"
|
|
922
930
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
923
|
-
checksum = "
|
|
931
|
+
checksum = "9bb54f33acc68fd454578d9820b0bde1a1a3d17aa17bb7b6595806d02886d409"
|
|
924
932
|
dependencies = [
|
|
925
933
|
"cfg-if",
|
|
926
934
|
"once_cell",
|
|
@@ -931,9 +939,9 @@ dependencies = [
|
|
|
931
939
|
|
|
932
940
|
[[package]]
|
|
933
941
|
name = "wasm-bindgen-macro"
|
|
934
|
-
version = "0.2.
|
|
942
|
+
version = "0.2.129"
|
|
935
943
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
936
|
-
checksum = "
|
|
944
|
+
checksum = "2e29d0c35b16e224a7eeb5cd2d25e3e1968fbd65604117b44d3b789d00ee8535"
|
|
937
945
|
dependencies = [
|
|
938
946
|
"quote",
|
|
939
947
|
"wasm-bindgen-macro-support",
|
|
@@ -941,22 +949,22 @@ dependencies = [
|
|
|
941
949
|
|
|
942
950
|
[[package]]
|
|
943
951
|
name = "wasm-bindgen-macro-support"
|
|
944
|
-
version = "0.2.
|
|
952
|
+
version = "0.2.129"
|
|
945
953
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
946
|
-
checksum = "
|
|
954
|
+
checksum = "6f501a8bc3719dba86ef8ae4728879c08001bea749eb1333ac5b91e040e2a6b7"
|
|
947
955
|
dependencies = [
|
|
948
956
|
"bumpalo",
|
|
949
957
|
"proc-macro2",
|
|
950
958
|
"quote",
|
|
951
|
-
"syn 3.0.
|
|
959
|
+
"syn 3.0.6",
|
|
952
960
|
"wasm-bindgen-shared",
|
|
953
961
|
]
|
|
954
962
|
|
|
955
963
|
[[package]]
|
|
956
964
|
name = "wasm-bindgen-shared"
|
|
957
|
-
version = "0.2.
|
|
965
|
+
version = "0.2.129"
|
|
958
966
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
959
|
-
checksum = "
|
|
967
|
+
checksum = "23f0c9c52aa7cd7d77769a4cfe2a9adb1b331f489a41d912ce14513d5ab995c6"
|
|
960
968
|
dependencies = [
|
|
961
969
|
"unicode-ident",
|
|
962
970
|
]
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
[package]
|
|
2
2
|
name = "MNeuEventLib"
|
|
3
|
-
version = "0.
|
|
3
|
+
version = "0.4.0"
|
|
4
4
|
edition = "2021"
|
|
5
5
|
license = "BSD-3-Clause"
|
|
6
6
|
readme = "README.md"
|
|
@@ -12,6 +12,7 @@ crate-type = ["cdylib"]
|
|
|
12
12
|
|
|
13
13
|
[dependencies]
|
|
14
14
|
hdf5 = { package = "hdf5-metno", version = "0.14.1", features = ["static"] }
|
|
15
|
+
hdf5-metno-sys = "0.12.3"
|
|
15
16
|
ndarray = "0.17.2"
|
|
16
17
|
rayon = "1.12.0"
|
|
17
18
|
anyhow = "1.0.102"
|
|
@@ -21,6 +22,7 @@ serde = { version = "1.0.228", features = ["derive"] }
|
|
|
21
22
|
serde_json = "1.0.150"
|
|
22
23
|
chrono = { version = "0.4.45", features = ["std"] }
|
|
23
24
|
tabled = "0.21.0"
|
|
25
|
+
seq-macro = "0.3"
|
|
24
26
|
|
|
25
27
|
[dev-dependencies]
|
|
26
28
|
tempfile = "3.27.0"
|
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
"""
|
|
2
|
+
This script can be used to generate a reference file.
|
|
3
|
+
The reference file is then used for filling out an
|
|
4
|
+
incomplete event file so it can be loaded into Mantid.
|
|
5
|
+
To use this you need an example histogram file with
|
|
6
|
+
the correct format.
|
|
7
|
+
|
|
8
|
+
If the reference file is saved as <ref> (assume
|
|
9
|
+
this includes the file path), then when saving
|
|
10
|
+
event data to histograms, the command would be
|
|
11
|
+
|
|
12
|
+
data.save(<output>, autofill=True, ref_file=<ref>)
|
|
13
|
+
|
|
14
|
+
where <output> is the name of the file you want
|
|
15
|
+
to save to, and data is the event data
|
|
16
|
+
object which would have been loaded from a
|
|
17
|
+
events data file.
|
|
18
|
+
"""
|
|
19
|
+
|
|
20
|
+
import sys
|
|
21
|
+
import h5py
|
|
22
|
+
|
|
23
|
+
"""
|
|
24
|
+
This data needs to be provided from the event
|
|
25
|
+
file. These datasets are calculated as part
|
|
26
|
+
of the histogramming process.
|
|
27
|
+
"""
|
|
28
|
+
skip = ['collection_time',
|
|
29
|
+
'corrected_time',
|
|
30
|
+
'counts',
|
|
31
|
+
'period_index',
|
|
32
|
+
'raw_time',
|
|
33
|
+
'spectrum_index',
|
|
34
|
+
'duration',
|
|
35
|
+
'end_time',
|
|
36
|
+
'good_frames',
|
|
37
|
+
'resolution',
|
|
38
|
+
'frames_requested',
|
|
39
|
+
'good_frames',
|
|
40
|
+
'good_frames_daq',
|
|
41
|
+
'raw_frames',
|
|
42
|
+
'start_time',
|
|
43
|
+
]
|
|
44
|
+
|
|
45
|
+
"""
|
|
46
|
+
This is the period information for the example
|
|
47
|
+
histogram file. It is recommended that it includes
|
|
48
|
+
multiple periods and Dwell.
|
|
49
|
+
N: number of detectors
|
|
50
|
+
P: number of periods
|
|
51
|
+
PD: number of periods + Dwell
|
|
52
|
+
NP: number of detectors times number of periods
|
|
53
|
+
NPD: number of detectors times the number of periods and Dwell
|
|
54
|
+
"""
|
|
55
|
+
N = 64
|
|
56
|
+
P = 2
|
|
57
|
+
PD = 3
|
|
58
|
+
NP = N*P
|
|
59
|
+
NPD = N*PD
|
|
60
|
+
|
|
61
|
+
"""
|
|
62
|
+
These strings are copied from the
|
|
63
|
+
histogram file to the default file
|
|
64
|
+
"""
|
|
65
|
+
keep_strings = ['definition',
|
|
66
|
+
'probe',
|
|
67
|
+
'type',
|
|
68
|
+
]
|
|
69
|
+
|
|
70
|
+
def set_attributes(obj, dest):
|
|
71
|
+
"""
|
|
72
|
+
Copy attributes from one object to another.
|
|
73
|
+
:param obj: the example file's open object
|
|
74
|
+
:param dest: the ref file's open object
|
|
75
|
+
"""
|
|
76
|
+
for attr in obj.attrs:
|
|
77
|
+
dest.attrs.create(attr, obj.attrs[attr])
|
|
78
|
+
|
|
79
|
+
def read(obj, new_obj, key):
|
|
80
|
+
"""
|
|
81
|
+
Recursive copy of data, replacing any dataset
|
|
82
|
+
with a "default dataset" if the length
|
|
83
|
+
depends on the number of detectors, periods,
|
|
84
|
+
or Dwell. Otherwise it records the dataset values
|
|
85
|
+
as 0.
|
|
86
|
+
:param obj: the example file's open object
|
|
87
|
+
:param new_obj: the ref file's open object
|
|
88
|
+
:param key: the name of the dataset
|
|
89
|
+
"""
|
|
90
|
+
if isinstance(obj, h5py.Group):
|
|
91
|
+
print('group', key)
|
|
92
|
+
tmp = new_obj.require_group(key)
|
|
93
|
+
set_attributes(obj, tmp)
|
|
94
|
+
for new_key in obj.keys():
|
|
95
|
+
read(obj[new_key], tmp, new_key)
|
|
96
|
+
print('exit group')
|
|
97
|
+
print()
|
|
98
|
+
|
|
99
|
+
elif isinstance(obj, h5py.Dataset):
|
|
100
|
+
name = obj.name.split('/')[-1]
|
|
101
|
+
dtype = str(obj.dtype)
|
|
102
|
+
shape = obj.shape
|
|
103
|
+
val = obj[()]
|
|
104
|
+
if 'float' in dtype or 'int' in dtype:
|
|
105
|
+
if len(val) in [N, P, NP, PD, NPD]:
|
|
106
|
+
length = 'N'
|
|
107
|
+
if len(val) == P:
|
|
108
|
+
length = 'P'
|
|
109
|
+
elif len(val) == NP:
|
|
110
|
+
length = 'NP'
|
|
111
|
+
elif len(val) == PD:
|
|
112
|
+
length = 'PD'
|
|
113
|
+
elif len(val) == NPD:
|
|
114
|
+
length = 'NPD'
|
|
115
|
+
group = new_obj.require_group('dataset_' + name)
|
|
116
|
+
set_attributes(obj, group)
|
|
117
|
+
group.create_dataset('default', data=0)
|
|
118
|
+
group.create_dataset('dtype', data=dtype)
|
|
119
|
+
group.create_dataset('shape', data=length)
|
|
120
|
+
|
|
121
|
+
else:
|
|
122
|
+
tmp = new_obj.create_dataset(name,
|
|
123
|
+
shape=shape,
|
|
124
|
+
dtype=dtype,
|
|
125
|
+
fillvalue=0)
|
|
126
|
+
|
|
127
|
+
set_attributes(obj, tmp)
|
|
128
|
+
else: # assume a string
|
|
129
|
+
val = obj[()]
|
|
130
|
+
tmp = None
|
|
131
|
+
if name in keep_strings or (isinstance(val, str) and val=='ISIS'):
|
|
132
|
+
tmp = new_obj.create_dataset(name, data=val, dtype=dtype)
|
|
133
|
+
elif '.dat' in name:
|
|
134
|
+
tmp = new_obj.create_dataset(name, data=val, dtype=dtype)
|
|
135
|
+
elif obj.shape == [1]:
|
|
136
|
+
tmp = new_obj.create_dataset(name, data=[' '], dtype='S1')
|
|
137
|
+
else:
|
|
138
|
+
tmp = new_obj.create_dataset(name, data=val, dtype=dtype)
|
|
139
|
+
set_attributes(obj, tmp)
|
|
140
|
+
|
|
141
|
+
|
|
142
|
+
def make_default(example_filename='HIFI00207745.nxs', ref_filename='REF_file.nxs'):
|
|
143
|
+
"""Generate a reference NeXus file from an example histogram NeXus file."""
|
|
144
|
+
with h5py.File(example_filename, 'r') as file:
|
|
145
|
+
with h5py.File(ref_filename, 'w') as new_file:
|
|
146
|
+
# do top level manually
|
|
147
|
+
for key in file.keys():
|
|
148
|
+
new_obj = new_file.require_group(key)
|
|
149
|
+
set_attributes(file[key], new_obj)
|
|
150
|
+
for tmp in file[key].keys():
|
|
151
|
+
if tmp in ['selog']:
|
|
152
|
+
print('skip')
|
|
153
|
+
else:
|
|
154
|
+
read(file[key][tmp], new_obj, tmp)
|
|
155
|
+
if tmp == 'detector_1':
|
|
156
|
+
new_obj[tmp].attrs['NX_class'] = 'NXdata'
|
|
157
|
+
print('done')
|
|
158
|
+
|
|
159
|
+
|
|
160
|
+
if __name__ == '__main__':
|
|
161
|
+
example = sys.argv[1] if len(sys.argv) > 1 else 'HIFI00207745.nxs'
|
|
162
|
+
ref = sys.argv[2] if len(sys.argv) > 2 else 'REF_file.nxs'
|
|
163
|
+
make_default(example, ref)
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import h5py
|
|
2
|
+
import numpy as np
|
|
3
|
+
import shutil
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
def replace(f, key, values, dtype):
|
|
7
|
+
"""
|
|
8
|
+
A simple helper method to replace
|
|
9
|
+
a dataset (without attributes)
|
|
10
|
+
"""
|
|
11
|
+
del f[key]
|
|
12
|
+
f.create_dataset(key, data=values, dtype=dtype)
|
|
13
|
+
|
|
14
|
+
def make_single_period_data(multi_period,
|
|
15
|
+
single_period):
|
|
16
|
+
"""
|
|
17
|
+
This is a simple method to convert
|
|
18
|
+
multi-period data into single
|
|
19
|
+
period.
|
|
20
|
+
:param multi_period: the file path
|
|
21
|
+
to the multi-period data.
|
|
22
|
+
:param single_period: the file path
|
|
23
|
+
to write the single period data to
|
|
24
|
+
"""
|
|
25
|
+
shutil.copy(multi_period,
|
|
26
|
+
single_period)
|
|
27
|
+
f = h5py.File(single_period, 'a')
|
|
28
|
+
data = f['raw_data_1']
|
|
29
|
+
tmp = data['detector_1_events']
|
|
30
|
+
N = tmp['period_number'].len()
|
|
31
|
+
zeros = np.zeros(N)
|
|
32
|
+
replace(tmp, 'period_number', zeros, 'int64')
|
|
33
|
+
|
|
34
|
+
tmp = data['periods']
|
|
35
|
+
replace(tmp, 'labels', 'period_1', 'S8')
|
|
36
|
+
|
|
37
|
+
replace(tmp, 'number', 1, 'int32')
|
|
38
|
+
replace(tmp, 'type', [1], 'int32')
|
|
39
|
+
f.close()
|
|
40
|
+
return
|
|
@@ -1,4 +1,12 @@
|
|
|
1
1
|
# MNeuEventLib
|
|
2
|
+
MNeuEventLib is an event data filtering library for ISIS Neutron and Muon Source.
|
|
3
|
+
|
|
4
|
+
## Install from PyPI
|
|
5
|
+
MNeuEventLib can be installed as a pre-compiled binary [from PyPI](https://pypi.org/project/MNeuEventLib/) using
|
|
6
|
+
```
|
|
7
|
+
pip install MNeuEventLib
|
|
8
|
+
```
|
|
9
|
+
|
|
2
10
|
|
|
3
11
|
## Build from source
|
|
4
12
|
MNeuEventLib is built with [`maturin`](https://www.maturin.rs/). Compilation also requires the [`rustup` toolchain](https://rustup.rs/).
|
|
@@ -88,7 +88,7 @@
|
|
|
88
88
|
"id": "0ca97a00-642c-47c1-b0fd-e2929d3a56a6",
|
|
89
89
|
"metadata": {},
|
|
90
90
|
"source": [
|
|
91
|
-
"Now, if we calculate our data, we will see in the histogram section of our data that some events have been removed. The full dataset contains
|
|
91
|
+
"Now, if we calculate our data, we will see in the histogram section of our data that some events have been removed. The full dataset contains 64147 events."
|
|
92
92
|
]
|
|
93
93
|
},
|
|
94
94
|
{
|
|
@@ -106,7 +106,7 @@
|
|
|
106
106
|
"id": "f76da006-458a-424c-a202-c063407ff1e0",
|
|
107
107
|
"metadata": {},
|
|
108
108
|
"source": [
|
|
109
|
-
"Now if we change the time filter type to `include` and calculate again, we will exclude all data _except_ that between 0.5 and 1.5 seconds. We'd expect our output histogram to have `
|
|
109
|
+
"Now if we change the time filter type to `include` and calculate again, we will exclude all data _except_ that between 0.5 and 1.5 seconds. We'd expect our output histogram to have `64147 - 49048 =` 15099 events, which it does:"
|
|
110
110
|
]
|
|
111
111
|
},
|
|
112
112
|
{
|
|
@@ -181,7 +181,7 @@
|
|
|
181
181
|
"id": "2a2ab3f5-0e76-4cba-a9d5-8949334914d3",
|
|
182
182
|
"metadata": {},
|
|
183
183
|
"source": [
|
|
184
|
-
"We can see from the output here that this filtered data has
|
|
184
|
+
"We can see from the output here that this filtered data has 50804 events, as opposed to the full data which had 64147.\n",
|
|
185
185
|
"\n",
|
|
186
186
|
"Note that there are also log filter functions for when you want an unbounded range on one side: \n",
|
|
187
187
|
"- `add_log_filter_above(name, log, lower)` for above;\n",
|