Commit 6df03c07 authored by payno's avatar payno
Browse files

[Process] fix map_to (again)

parent badec053
......@@ -135,15 +135,36 @@ class Process(object):
_data = {}
for key in data_keys:
relative_to = None
if key in ("chir_re", "chir_im", "chir_mag", "r"):
use = "map_to"
if key in (
"flat",
"fpp",
"f2",
"dmude",
"norm",
"norm_area",
"post_edge",
"bkg",
"energy",
"mback_mu",
"norm_mback",
"Energy",
"Mu",
"NormalizedEnergy",
"NormalizedMu",
"NormalizedSignal",
"EXAFSKValues",
"EXAFSSignal",
"noise_savgol",
):
relative_to = "energy"
use = "map_to"
elif key in ("chir_re", "chir_im", "chir_mag", "r"):
relative_to = "r"
use = "map_to"
elif key in ("ft.radius", "ft.intensity", "ft.imaginary"):
relative_to = "radius"
use = "_list_res_ft"
else:
relative_to = "energy"
use = "map_to"
if use == "map_to":
# if we can display the result as a numpy.array 3d
......
......@@ -160,13 +160,14 @@ class Spectra:
if len(self.data.flat) == 0:
return None
else:
if relative_to:
assert get_relative_to_value(relative_to) is not None
array = numpy.zeros(
(len(get_relative_to_value(relative_to)), len(self.data.flat))
)
else:
array = numpy.zeros(len(self.data.flat))
def allocate_array(relative_to_len):
if relative_to_len is not None:
return numpy.zeros((relative_to_len, len(self.data.flat)))
else:
return numpy.zeros(len(self.data.flat))
array = None
for i_spectrum, spectrum in enumerate(self.data.flat):
try:
if "." in key:
......@@ -187,13 +188,27 @@ class Spectra:
if _has_larch and isinstance(value, larch.symboltable.Group):
_logger.info("pass larch details, not managed for now")
continue
# create array if necessary
if array is None:
if relative_to is None:
array = allocate_array(relative_to_len=None)
elif value is None:
array = allocate_array(relative_to_len=None)
else:
array = allocate_array(relative_to_len=len(value))
print("key is", key, "relative to", relative_to)
print("value is", value)
print("array shape is", array.shape)
if relative_to is not None:
array[:, i_spectrum] = value
else:
array[i_spectrum] = value
shape = list(self.data.shape)
shape.insert(0, -1)
return array.reshape(shape)
if array is None:
return array
else:
return array.reshape(shape)
def keys(self) -> tuple:
"""
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment