Skip to content

Commit

Permalink
Implement Spectrum2DCollection z_data; test slicing with ref data
Browse files Browse the repository at this point in the history
  • Loading branch information
ajjackson committed Sep 17, 2024
1 parent d8680c2 commit 62756cd
Show file tree
Hide file tree
Showing 6 changed files with 1,570 additions and 0 deletions.
11 changes: 11 additions & 0 deletions euphonic/spectra.py
Original file line number Diff line number Diff line change
Expand Up @@ -1866,6 +1866,17 @@ def _split_by_indices(self, indices: Sequence[int] | np.ndarray
metadata=self.metadata)
for x0, x1 in ranges]

@property
def z_data(self) -> Quantity:
return ureg.Quantity(
self._z_data, self._internal_z_data_unit
).to(self.z_data_unit, "reciprocal_spectroscopy")

@z_data.setter
def z_data(self, value: Quantity) -> None:
self.z_data_unit = str(value.units)
self._z_data = value.to(self._internal_z_data_unit).magnitude

@classmethod
def from_spectra(cls, spectra: Sequence[Spectrum2D]) -> Self:

Check notice on line 1881 in euphonic/spectra.py

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

euphonic/spectra.py#L1881

Too many local variables (18/15)
if len(spectra) < 1:
Expand Down
267 changes: 267 additions & 0 deletions tests_and_analysis/test/data/spectrum2d/quartz_fuzzy_map_0.json
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"
}
Loading

0 comments on commit 62756cd

Please sign in to comment.