-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Spectrum refactoring, Spectrum2DCollection (#305)
A Spectrum2DCollection class is introduced, with a similar interface to Spectrum1DCollection. - Common features of the two classes are broken out into a multiple-inheritance "mixin" class, so that Spectrum remains the common base of all spectra: Spectrum1D, Spectrum2D, Spectrum1DCollection and Spectrum2DCollection are all "children" on the same level and will not `isinstance` with each other. - Some of the metadata handling has been refactored for legibility and robustness: select(), group_by() and internal methods - Some of this work uses toolz, which becomes a dependency for the main package. We don't anticipate that causing a lot of problems; it is a small, stable, pure-python library also available on conda-forge. Mantid core team were warned of this intention a month or two ago and seem happy enough. - `iter_metadata` method is provided to allow iteration over spectrum indices (using enumerate) without the relatively slow overhead of creating new spectra (encounted when iterating over the collection object). - i.e. `list(collection.iter_metadata())` is much faster than `[spectrum.metadata for spectrum in collection]` because it avoids unnecessarily copying data and twiddling units. Co-authored-by: Jacob Wilkins <[email protected]>
- Loading branch information
Showing
9 changed files
with
2,332 additions
and
298 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,3 +7,4 @@ matplotlib==3.8 | |
h5py==3.6 | ||
PyYAML==6.0 | ||
threadpoolctl==3.0.0 | ||
toolz==0.12.1 |
267 changes: 267 additions & 0 deletions
267
tests_and_analysis/test/data/spectrum2d/quartz_fuzzy_map_0.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,267 @@ | ||
{ | ||
"__euphonic_class__": "Spectrum2D", | ||
"__euphonic_version__": "1.3.2+33.gd8680c2.dirty", | ||
"metadata": { | ||
"common": "yes", | ||
"direction": 0 | ||
}, | ||
"x_data": [ | ||
0.0, | ||
0.1111111111111111, | ||
0.2222222222222222, | ||
0.3333333333333333, | ||
0.4444444444444444, | ||
0.5555555555555556, | ||
0.6666666666666666, | ||
0.7777777777777777, | ||
0.8888888888888888, | ||
1.0 | ||
], | ||
"x_data_unit": "1 / angstrom", | ||
"x_tick_labels": [ | ||
[ | ||
0, | ||
"$\\Gamma$" | ||
], | ||
[ | ||
9, | ||
"" | ||
] | ||
], | ||
"y_data": [ | ||
0.0, | ||
5.2631578947368425, | ||
10.526315789473685, | ||
15.789473684210527, | ||
21.05263157894737, | ||
26.315789473684212, | ||
31.578947368421055, | ||
36.8421052631579, | ||
42.10526315789474, | ||
47.36842105263158, | ||
52.631578947368425, | ||
57.89473684210527, | ||
63.15789473684211, | ||
68.42105263157896, | ||
73.6842105263158, | ||
78.94736842105263, | ||
84.21052631578948, | ||
89.47368421052633, | ||
94.73684210526316, | ||
100.0 | ||
], | ||
"y_data_unit": "millielectron_volt", | ||
"z_data": [ | ||
[ | ||
0.0, | ||
0.0, | ||
0.0, | ||
0.042222222222222223, | ||
0.0, | ||
0.021111111111111094, | ||
0.04222222222222224, | ||
0.0, | ||
0.06333333333333335, | ||
0.021111111111111094, | ||
0.04222222222222224, | ||
0.04222222222222215, | ||
0.0, | ||
0.0, | ||
0.0, | ||
0.0, | ||
0.04222222222222215, | ||
0.0, | ||
0.04222222222222224 | ||
], | ||
[ | ||
0.06333333333333331, | ||
0.0, | ||
0.0, | ||
0.042222222222222223, | ||
0.0, | ||
0.021111111111111094, | ||
0.04222222222222224, | ||
0.021111111111111094, | ||
0.04222222222222224, | ||
0.021111111111111094, | ||
0.04222222222222224, | ||
0.04222222222222215, | ||
0.0, | ||
0.0, | ||
0.0, | ||
0.0, | ||
0.04222222222222215, | ||
0.0, | ||
0.04222222222222224 | ||
], | ||
[ | ||
0.0211111111111111, | ||
0.0422222222222222, | ||
0.0, | ||
0.042222222222222223, | ||
0.0, | ||
0.021111111111111094, | ||
0.04222222222222224, | ||
0.04222222222222219, | ||
0.0, | ||
0.04222222222222219, | ||
0.04222222222222224, | ||
0.04222222222222215, | ||
0.0, | ||
0.0, | ||
0.0, | ||
0.021111111111111074, | ||
0.021111111111111074, | ||
0.0, | ||
0.04222222222222224 | ||
], | ||
[ | ||
0.0, | ||
0.06333333333333331, | ||
0.0, | ||
0.042222222222222223, | ||
0.0, | ||
0.04222222222222219, | ||
0.02111111111111112, | ||
0.04222222222222219, | ||
0.0, | ||
0.04222222222222219, | ||
0.04222222222222224, | ||
0.04222222222222215, | ||
0.0, | ||
0.0, | ||
0.0, | ||
0.021111111111111074, | ||
0.021111111111111074, | ||
0.0, | ||
0.02111111111111112 | ||
], | ||
[ | ||
0.0, | ||
0.0211111111111111, | ||
0.0422222222222222, | ||
0.021111111111111112, | ||
0.021111111111111112, | ||
0.04222222222222219, | ||
0.0, | ||
0.06333333333333328, | ||
0.0, | ||
0.06333333333333328, | ||
0.02111111111111112, | ||
0.021111111111111074, | ||
0.02111111111111112, | ||
0.0, | ||
0.0, | ||
0.021111111111111074, | ||
0.0, | ||
0.021111111111111164, | ||
0.02111111111111112 | ||
], | ||
[ | ||
0.0, | ||
0.0211111111111111, | ||
0.0211111111111111, | ||
0.042222222222222223, | ||
0.021111111111111112, | ||
0.04222222222222219, | ||
0.02111111111111112, | ||
0.04222222222222219, | ||
0.0, | ||
0.06333333333333328, | ||
0.02111111111111112, | ||
0.021111111111111074, | ||
0.02111111111111112, | ||
0.0, | ||
0.02111111111111112, | ||
0.0, | ||
0.0, | ||
0.021111111111111164, | ||
0.02111111111111112 | ||
], | ||
[ | ||
0.0, | ||
0.0211111111111111, | ||
0.0211111111111111, | ||
0.042222222222222223, | ||
0.021111111111111112, | ||
0.04222222222222219, | ||
0.02111111111111112, | ||
0.021111111111111094, | ||
0.02111111111111112, | ||
0.06333333333333328, | ||
0.04222222222222224, | ||
0.0, | ||
0.02111111111111112, | ||
0.0, | ||
0.02111111111111112, | ||
0.0, | ||
0.0, | ||
0.021111111111111164, | ||
0.02111111111111112 | ||
], | ||
[ | ||
0.0, | ||
0.0, | ||
0.0422222222222222, | ||
0.021111111111111112, | ||
0.042222222222222223, | ||
0.04222222222222219, | ||
0.04222222222222224, | ||
0.0, | ||
0.04222222222222224, | ||
0.04222222222222219, | ||
0.04222222222222224, | ||
0.0, | ||
0.0, | ||
0.04222222222222224, | ||
0.0, | ||
0.0, | ||
0.0, | ||
0.021111111111111164, | ||
0.04222222222222224 | ||
], | ||
[ | ||
0.0, | ||
0.0, | ||
0.0422222222222222, | ||
0.021111111111111112, | ||
0.042222222222222223, | ||
0.04222222222222219, | ||
0.04222222222222224, | ||
0.0, | ||
0.08444444444444447, | ||
0.0, | ||
0.04222222222222224, | ||
0.0, | ||
0.0, | ||
0.04222222222222224, | ||
0.0, | ||
0.0, | ||
0.0, | ||
0.021111111111111164, | ||
0.06333333333333335 | ||
], | ||
[ | ||
0.0, | ||
0.0211111111111111, | ||
0.0211111111111111, | ||
0.021111111111111112, | ||
0.042222222222222223, | ||
0.04222222222222219, | ||
0.04222222222222224, | ||
0.0, | ||
0.04222222222222224, | ||
0.04222222222222219, | ||
0.04222222222222224, | ||
0.0, | ||
0.02111111111111112, | ||
0.0, | ||
0.02111111111111112, | ||
0.0, | ||
0.0, | ||
0.021111111111111164, | ||
0.04222222222222224 | ||
] | ||
], | ||
"z_data_unit": "1 / millielectron_volt" | ||
} |
Oops, something went wrong.