Skip to content

[Jupyter] add example how to read chi.dat and sum paths with ff2chi() #612

@maurov

Description

@maurov

As discussed on the Ifeffit mailing-list on March 6th 2026. Related to #611.

from larch.io import read_ascii
from larch.xafs import xftf
from larch.plot.wxmplot_xafsplots import plot_chik, plot_chir

from pathlib import Path

fchi = read_ascii(Path('Feff8example', 'chi.dat'))
xftf(fchi, kmin=2, kmax=18, dk=4, kweight=2, window='hanning')

plot_chik(fchi, kweight=2, show_window=True, win=1)
plot_chir(fchi, show_mag=True, show_real=True, win=2)

I'm also willing to admit that one way of looking at Feffit (as a standalone program, part of Ifeffit, or function in Larch) is that it basically a replacement for Feff's FF2CHI module, to sum of Feff paths to make chi(k).

So, there is also an ff2chi() function in Larch. Which is to say, that you might also be able to also do:

from larch.xafs import feffpath, ff2chi
# sum paths
pathlist = []
for i in range(1, 101):
    fpath = Path('Feff8example', f'feff{i:04}.dat')
    if fpath.exists():
        this_path = feffpath(fpath, s02=0.9, e0=1.0)
        pathlist.append(this_path)

sum = ff2chi(pathlist)
xftf(sum, kmin=2, kmax=18, dk=4, kweight=2, window='hanning')

plot_chik(sum, kweight=2, show_window=True, title='Sum of Paths', win=3)
plot_chir(sum, show_mag=True, show_real=True, title='Sum of Paths', win=4)

That should probably be put into a Jupyter notebook for the documentation ;).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions