xraypy / xraylarch

Larch: Applications and Python Library for Data Analysis of X-ray Absorption Spectroscopy (XAS, XANES, XAFS, EXAFS), X-ray Fluorescence (XRF) Spectroscopy and Imaging, and more.
https://xraypy.github.io/xraylarch
Other
127 stars 62 forks source link

Problem with export to csv #503

Closed AnnaDragonfly closed 3 months ago

AnnaDragonfly commented 3 months ago

Dear Matt, I'm using the latest version of Larix (larch version 0.9.74). I noticed that I cannot export some processed data to csv files - especially from EXAFS. For the same file I can export normalized, flattened data but not in kspace or Rspace.

I got such error:

Could not export CSV File C:\Users\Sample1_Ni3B_Rspace.csv Traceback (most recent calls last): File "C:\Users\anna.wach\xraylarch\Lib\site-packages\larch\wxxas\xasgui.py", line 686, in onExportCSV groups2csv(savegroups, outfile, x=res.xarray, y=res.yarray, File "C:\Users\anna.wach\xraylarch\Lib\site-packages\larch\io\csvfiles.py", line 94, in groups2csv buff.append(delim.join([gformat(s[i]) for s in columns])) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\anna.wach\xraylarch\Lib\site-packages\larch\io\csvfiles.py", line 94, in buff.append(delim.join([gformat(s[i]) for s in columns])) ~^^^ IndexError: index 392 is out of bounds for axis 0 with size 392

Any ideas why? I guess this may be a problem only on my computer.

Best, Anna

Ameyanagi commented 3 months ago

Hi @AnnaDragonfly,

The error shows that the length of the x axis and y axis of the data is not matching. Is there any chance that you are using "energy" as a x axis? If so, you can specify "k" for the "X Array" when you save it. (same for R) length of 392 corresponds to k = 19.6, which is relatively large for k space.

AnnaDragonfly commented 3 months ago

Hi @Ameyanagi You're right. I was so used to Athena, that I didn't notice this. Thanks for your prompt answer. Best, Anna

newville commented 3 months ago

@AnnaDragonfly @Ameyanagi Thanks -- I was just looking at this too. I will try to fix it so that selecting "chi(k)" will change the default X-axis to "k" (and also for chi(R)). And I'll try to give a better warning.

Ameyanagi commented 3 months ago

@newville I think it would be better to automatically select k when we choose "chi(k)" and r or q when we select the r or q space. Thank you.

newville commented 3 months ago

@Ameyanagi done - well, at least the easy part ;)