e-champenois / CPBASEX

pBASEX Abel Transform Inversion without Polar Rebinning
MIT License
7 stars 7 forks source link

MATLAB version: one transpose too little/many #4

Closed gasfas closed 6 years ago

gasfas commented 7 years ago

Hey, Thanks a lot for sharing your code, and even a nice description! I am in the process of making it work on my data, from electrons measured by a VMI spectrometer.

While I was trying to run for the first time (your example files (e.g. basicAnalysis) are very useful for that), I noticed that the matrix gData.frk (created by saveGData.m) has the dimension (64x512). But, for the code in pbasex.m to work, it needs to be transposed (512x64). So it was easy to fix, but I wasn't sure where to do it.

Either on line 134 in pbasex.m: IEB = 1/(2alpha)diag(gData.x)(gData.frk'reshape(permute(reshape(c,nk,nl,nims),[1,3,2]),nk,nl*nims));

Or on line 24 in SaveGData: x=x';Up=Up';S=S';V=V';Ginv=Ginv';

I decided to do the former, and things worked after that. So, it is not really an issue, rather a suggestion of what could be improved.

Thanks again for sharing! Bart

e-champenois commented 6 years ago

Hi Bart, First off sorry for the delayed response, didn't have time to look at this code for a while and it seemed like you had found a working solution. I think the issue stems from the difference in MATLAB's "save" and Python's "h5py.write" save matrices. Saving an 'm x n' matrix in each of them and loading gives different results. I wanted to have the two versions of the code able to save the gData for each other so there are extra transposes everywhere in the loadG.m file. Thanks for the info.