fusion-flap / flap

Fusion Library of Analysis Programs
MIT License
11 stars 5 forks source link

Multi-dimensional spatial cross-correlation is not working #78

Closed thelampire closed 3 years ago

thelampire commented 4 years ago

I tried to do flap.ccf(..., coordinates=['Image x', 'Image y'], ...), but it fails do to a not broadcastable error. I have no idea what the code is doing at spectral_analysis.py line 1615:

np.add.at(corr_binned,tuple(ind_bin),corr_sliced)

The code fails here. For one dimension the variables in the parentheses have the following shapes in the case ['Image x', 'Image y'] (it doesn't change if I change the order to yx) (81, 81) (2, 81) (81, 81)

For 1D, along x coordinate: (80, 81, 80) (3,) (80, 81, 80) For 1D along y coordinate: (64, 81, 64) (3,) (64, 81, 64)

The exact error message is the following: ValueError: array is not broadcastable to correct shape

I have no idea what this part of the code is doing due to lack of commenting. Could you please let me know how to solve this problem and what is the code doing at that line?

thelampire commented 4 years ago

I really don't understand this. If I do cross-correlation between one image and the subsequent image in 'Image x' direction, I get a result of [64,81,64] matrix. I don't want to do cross-correlation between every x coordinate in one image and all the other x coordinates in the subsequent image. All I would like to do is to have 80 spatial CCF functions of two 64 x 80 images in the x direction and 64 pc in the y direction as a function of the corresponding coordinate lag.

For the 2D CCF, the resulting cross-correlation function should be a 2D result, not a 5D. I understand that in some cases this is necessary, but if it is the same datasource and the coordinates are the same, then it is unnecessary to do this.

thelampire commented 3 years ago

Technically I finished this today for general coordinates. It needs to be merged with master.

thelampire commented 3 years ago

I am closing this as this has been resolved in the new version in the development.