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 (
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"
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( == 0:
return None
if relative_to:
assert get_relative_to_value(relative_to) is not None
array = numpy.zeros(
(len(get_relative_to_value(relative_to)), len(
array = numpy.zeros(len(
def allocate_array(relative_to_len):
if relative_to_len is not None:
return numpy.zeros((relative_to_len, len(
return numpy.zeros(len(
array = None
for i_spectrum, spectrum in enumerate(
if "." in key:
......@@ -187,13 +188,27 @@ class Spectra:
if _has_larch and isinstance(value, larch.symboltable.Group):"pass larch details, not managed for now")
# 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)
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
array[i_spectrum] = value
shape = list(
shape.insert(0, -1)
return array.reshape(shape)
if array is None:
return array
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