CODE:
def run_attributes(input_cube, attributes: List[Tuple[str, Callable, Dict[str, str]]]):
datas = [attr_func(input_cube, **attr_kwargs).flatten() for _, attr_func, attr_kwargs in attributes]
datas = da.stack(datas, axis=1)
return ddf.from_dask_array(datas, columns=[attr_name for attr_name, _, _ in attributes])
sys.path.append('./d2geo/attributes')
from d2geo.attributes.CompleTrace import ComplexAttributes
from d2geo.attributes.SignalProcess import SignalProcess
complex_att = ComplexAttributes()
signal_process = SignalProcess()
def amplitude_arr(input_cube):
return da.from_array(input_cube)
funcs = [
('Amplitude', amplitude_arr, {}),
('Envelope', complex_att.envelope, {}),
('Instantaneous Phase', complex_att.instantaneous_phase, {}),
('Instantaneous Frequency', complex_att.instantaneous_frequency, {}),
('Instantaneous Bandwidth', complex_att.instantaneous_bandwidth, {}),
('Dominant Frequency', complex_att.dominant_frequency, {}),
('Cosine Instantaneous Phase', complex_att.cosine_instantaneous_phase, {}),
('Second Derivative', signal_process.second_derivative, {}),
('Reflection Intensity', signal_process.reflection_intensity, {})
]
dataframe = run_attributes(cube, funcs).compute()
dataframe.tail()
ERROR:
ValueError Traceback (most recent call last)
~\AppData\Local\Temp\ipykernel_2132\1033475186.py in
24 ]
25
---> 26 dataframe = run_attributes(cube, funcs).compute()
27 dataframe.tail()
~\AppData\Local\Temp\ipykernel_2132\4269748235.py in run_attributes(input_cube, attributes)
1 def run_attributes(input_cube, attributes: List[Tuple[str, Callable, Dict[str, str]]]):
2 datas = [attr_func(input_cube, **attr_kwargs).flatten() for _, attr_func, attr_kwargs in attributes]
----> 3 datas = da.stack(datas, axis=1)
4 return ddf.from_dask_array(datas, columns=[attr_name for attr_name, _, _ in attributes])
C:\anaconda\lib\site-packages\dask\array\core.py in stack(seq, axis, allow_unknown_chunksizes)
5058 if not allow_unknown_chunksizes and not all(x.shape == seq[0].shape for x in seq):
5059 idx = first(i for i in enumerate(seq) if i[1].shape != seq[0].shape)
-> 5060 raise ValueError(
5061 "Stacked arrays must have the same shape. The first array had shape "
5062 f"{seq[0].shape}, while array {idx[0] + 1} has shape {idx[1].shape}."
ValueError: Stacked arrays must have the same shape. The first array had shape (207572625,), while array 2 has shape (219576825,).