Skip to content

Commit

Permalink
Merge branch 'master' of github.com:xraypy/xraylarch
Browse files Browse the repository at this point in the history
  • Loading branch information
newville committed Dec 11, 2023
2 parents 89766a9 + 2fbd0f9 commit d3bcfb6
Show file tree
Hide file tree
Showing 6 changed files with 74 additions and 88 deletions.
2 changes: 1 addition & 1 deletion examples/feffit/doc_feffit1.out
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
Bayesian info crit = 41.4428977

[[Dataset]]
dataset unique_id = 'dgpiqpwi'
unique_id = 'dc5vezx7'
fit space = 'r'
r-range = 1.400, 3.000
k-range = 3.000, 17.000
Expand Down
2 changes: 1 addition & 1 deletion examples/feffit/doc_feffit2.out
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
Bayesian info crit = 12.5185008

[[Dataset]]
dataset unique_id = 'do2js2h5'
unique_id = 'ds3qtgjs'
fit space = 'r'
r-range = 1.400, 3.500
k-range = 3.000, 17.000
Expand Down
6 changes: 3 additions & 3 deletions examples/feffit/doc_feffit3.out
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
Bayesian info crit = 243.985673

[[Datasets (3)]]
dataset unique_id = 'd3hdjp7v'
unique_id = 'd3hdjp7v'
fit space = 'r'
r-range = 1.400, 3.400
k-range = 3.000, 17.000
Expand All @@ -21,7 +21,7 @@
epsilon_k = Array(mean=0.0011450, std=9.5319e-4)
epsilon_r = 0.0384855
n_independent = 18.825
dataset unique_id = 'd3s3lmwo'
unique_id = 'd3s3lmwo'
fit space = 'r'
r-range = 1.400, 3.400
k-range = 3.000, 17.000
Expand All @@ -31,7 +31,7 @@
epsilon_k = Array(mean=0.0010796, std=0.0010404)
epsilon_r = 0.0362874
n_independent = 18.825
dataset unique_id = 'dcultf7u'
unique_id = 'dcultf7u'
fit space = 'r'
r-range = 1.400, 3.400
k-range = 3.000, 17.000
Expand Down
1 change: 1 addition & 0 deletions installers/conda_constructor/construct.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ specs:
- pyyaml
- toml
- sphinx
- notebook<7
- dill
- psycopg2
- patchelf # [linux]
Expand Down
6 changes: 4 additions & 2 deletions larch/io/athena_project.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ def make_athena_args(group, hashkey=None, **kws):
('bkg_rbkg', '1.0'), ('bkg_slope', '0'),
('bkg_pre1', '-150'), ('bkg_pre2', '-30'),
('bkg_nor1', '150'), ('bkg_nor2', '800'),
('bkg_nnorm', '1'),
('bkg_nnorm', '1'), ('bkg_nvict', '0'),
('prjrecord', 'athena.prj, 1'), ('chi_column', ''),
('chi_string', ''), ('collided', '0'), ('columns', ''),
('daq', ''), ('denominator', '1'), ('display', '0'),
Expand Down Expand Up @@ -166,7 +166,7 @@ def make_athena_args(group, hashkey=None, **kws):
args[aname] = val

bkg_map = dict(nnorm='nnorm', nor1='norm1', nor2='norm2', pre1='pre1',
pre2='pre2')
pre2='pre2', nvict='nvict')

if hasattr(group, 'pre_edge_details'):
for aname, lname in bkg_map.items():
Expand Down Expand Up @@ -231,6 +231,7 @@ def format_array(arr):

def clean_bkg_params(grp):
grp.nnorm = getattr(grp, 'nnorm', 2)
grp.nvict = getattr(grp, 'nvict', 0)
grp.e0 = getattr(grp, 'e0', -1)
grp.rbkg = getattr(grp, 'rbkg', 1)
grp.pre1 = getattr(grp, 'pre1', -150)
Expand Down Expand Up @@ -834,6 +835,7 @@ def read(self, filename=None, match=None, do_preedge=True, do_bkg=False,
pre1=float(pars.pre1), pre2=float(pars.pre2),
norm1=float(pars.nor1), norm2=float(pars.nor2),
nnorm=float(pars.nnorm),
nvict=float(pars.nvict),
make_flat=bool(pars.flatten))
if do_bkg and hasattr(pars, 'rbkg'):
autobk(this, e0=float(pars.e0), rbkg=float(pars.rbkg),
Expand Down
145 changes: 64 additions & 81 deletions larch/plot/plotly_xafsplots.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ def get_display(win=1, *args, **kws):
)

def set_label_weight(label, w):
return label.replace('__W__', '{0:g}'.format(w))
return label.replace('_w_', '{0:g}'.format(w))

# common XAFS plot labels
def chirlab(kweight, show_mag=True, show_real=False, show_imag=False):
Expand Down Expand Up @@ -105,17 +105,17 @@ def chirlab(kweight, show_mag=True, show_real=False, show_imag=False):
chie = r'$\chi(E)$',
chie0 = r'$\chi(E)$',
chie1 = r'$E\chi(E) \rm\, (eV)$',
chiew = r'$E^{__W__}\chi(E) \rm\,(eV^{__W__})$',
chikw = r'$k^{{__W__}}\chi(k) \rm\,(\unicode{x212B}^{{-__W__}})$',
chiew = r'$E^{{_w_}\chi(E) \rm\,(eV^{_w_})$',
chikw = r'$k^{{_w_}}\chi(k) \rm\,(\unicode{x212B}^{{-_w_}})$',
chi0 = r'$\chi(k)$',
chi1 = r'$k\chi(k) \rm\,(\unicode{x212B}^{-1})$',
chi2 = r'$k^2\chi(k) \rm\,(\unicode{x212B}^{-2})$',
chi3 = r'$k^3\chi(k) \rm\,(\unicode{x212B}^{-3})$',
chir = r'$\chi(R) \rm\,(\unicode{x212B}^{{-__W__}})$',
chirmag = r'$|\chi(R)| \rm\,(\unicode{x212B}^{{-__W__}})$',
chirre = r'${{\rm Re}}[\chi(R)] \rm\,(\unicode{x212B}^{{-__W__}})$',
chirim = r'${{\rm Im}}[\chi(R)] \rm\,(\unicode{x212B}^{{-__W__}})$',
chirpha = r'${{\rm Phase}}[\chi(R)] \rm\,(\unicode{x212B}^{{-__W__}})$',
chir = r'$\chi(R) \rm\,(\unicode{x212B}^{{-_w_}})$',
chirmag = r'$|\chi(R)| \rm\,(\unicode{x212B}^{{-_w_}})$',
chirre = r'${{\rm Re}}[\chi(R)] \rm\,(\unicode{x212B}^{{-_w_}})$',
chirim = r'${{\rm Im}}[\chi(R)] \rm\,(\unicode{x212B}^{{-_w_}})$',
chirpha = r'${{\rm Phase}}[\chi(R)] \rm\,(\unicode{x212B}^{{-_w_}})$',
e0color = '#B2B282',
chirlab = chirlab)

Expand Down Expand Up @@ -625,9 +625,7 @@ def plot_chik(dgroup, kweight=None, kmax=None, show_window=True,

if kmax is not None:
fig.set_xrange(0, kmax)
ylabel = plotlabels.chi0
if kweight > 0:
ylabel = set_label_weight(plotlabels.chikw, kweight)
ylabel = set_label_weight(plotlabels.chikw, kweight)
fig.set_style(title=title, xaxis_title=plotlabels.k,
yaxis_title=ylabel)

Expand Down Expand Up @@ -924,17 +922,12 @@ def plot_path_k(dataset, ipath=0, kmin=0, kmax=None, offset=0, label=None,

chi_kw = offset + path.chi * path.k**kweight

fig = PlotlyFigure(two_yaxis=False)
fig.add_plot(path.k, chi_kw, label=label)

if kmin is not None or kmax is not None:
fig.set_xrange(kmin, kmax)

ylabel = set_label_weight(plotlabels.chikw, kweight)
fig.set_style(title=title, xaxis_title=plotlabels.k,
yaxis_title=ylabel)
fig.show()
return fig
_plot(path.k, chi_kw, label=label, xmin=kmin, xmax=kmax,
xlabel=plotlabels.k,
ylabel=set_label_weight(plotlabels.chikw, kweight),
win=win, new=new, delay_draw=delay_draw, _larch=_larch, **kws)
if delay_draw:
redraw(win=win, xmin=kmin, xmax=kmax, _larch=_larch)
#enddef

def plot_path_r(dataset, ipath, rmax=None, offset=0, label=None,
Expand Down Expand Up @@ -967,28 +960,28 @@ def plot_path_r(dataset, ipath, rmax=None, offset=0, label=None,
if label is None:
label = 'path %i' % (1+ipath)
#endif
kweight = dataset.transform.kweight
kweight =dataset.transform.kweight
ylabel = plotlabels.chirlab(kweight, show_mag=show_mag,
show_real=show_real, show_imag=show_imag)

fig = PlotlyFigure(two_yaxis=False)
opts = dict(xlabel=plotlabels.r, ylabel=ylabel, xmax=rmax, new=new,
delay_draw=True, _larch=_larch)

opts.update(kws)
if show_mag:
fig.add_plot(path.r, offset+path.chir_mag, label=f'|{label}|')

_plot(path.r, offset+path.chir_mag, label=label, **opts)
opts['new'] = False
#endif
if show_real:
fig.add_plot(path.r, offset+path.chir_re, label=f'Re[{label}]')

_plot(path.r, offset+path.chir_re, label=label, **opts)
opts['new'] = False
#endif
if show_imag:
fig.add_plot(path.r, offset+path.chir_im, label=f'Im[{label}]')

if rmax is not None:
fig.set_xrange(0, rmax)

ylabel = plotlabels.chirlab(kweight, show_mag=show_mag,
show_real=show_real, show_imag=show_imag)
fig.set_style(title=title, xaxis_title=plotlabels.r,
yaxis_title=ylabel)
fig.show()
return fig

_plot(path.r, offset+path.chir_im, label=label, **opts)
opts['new'] = False
#endif
redraw(win=win, xmax=rmax, _larch=_larch)
#enddef

def plot_paths_k(dataset, offset=-1, kmin=0, kmax=None, title=None,
new=True, delay_draw=False, win=1, _larch=None, **kws):
Expand Down Expand Up @@ -1018,22 +1011,18 @@ def plot_paths_k(dataset, offset=-1, kmin=0, kmax=None, title=None,

title = _get_title(dataset, title=title)

fig = PlotlyFigure(two_yaxis=False)
fig.add_plot(model.k, model_chi_kw, label='sum')

for ipath, path in enumerate(dataset.pathlist):
label = 'path %i' % (1+ipath)
chi_kw = offset + path.chi * path.k**kweight
fig.add_plot(path.k, chi_kw+(ipath+1)*offset, label=label)

if kmin is not None or kmax is not None:
fig.set_xrange(kmin, kmax)

ylabel = set_label_weight(plotlabels.chikw, kweight)
fig.set_style(title=title, xaxis_title=plotlabels.k,
yaxis_title=ylabel)
fig.show()
return fig
_plot(model.k, model_chi_kw, title=title, label='sum', new=new,
xlabel=plotlabels.r, ylabel=plotlabels.chikw.format(kweight),
xmin=kmin, xmax=kmax, win=win, delay_draw=True,_larch=_larch,
**kws)

for ipath in range(len(dataset.pathlist)):
plot_path_k(dataset, ipath, offset=(ipath+1)*offset,
kmin=kmin, kmax=kmax, new=False, delay_draw=True,
win=win, _larch=_larch)
#endfor
redraw(win=win, xmin=kmin, xmax=kmax, _larch=_larch)
#enddef

def plot_paths_r(dataset, offset=-0.25, rmax=None, show_mag=True,
show_real=False, show_imag=False, title=None, new=True,
Expand Down Expand Up @@ -1064,35 +1053,29 @@ def plot_paths_r(dataset, offset=-0.25, rmax=None, show_mag=True,
ylabel = plotlabels.chirlab(kweight, show_mag=show_mag,
show_real=show_real, show_imag=show_imag)
title = _get_title(dataset, title=title)


fig = PlotlyFigure(two_yaxis=False)
opts = dict(xlabel=plotlabels.r, ylabel=ylabel, xmax=rmax, new=new,
delay_draw=True, title=title, _larch=_larch)
opts.update(kws)
if show_mag:
fig.add_plot(model.r, model.chir_mag, label='|sum|')
_plot(model.r, model.chir_mag, label='|sum|', **opts)
opts['new'] = False
#endif
if show_real:
fig.add_plot(model.r, model.chir_re, label='Re[sum]')
_plot(model.r, model.chir_re, label='Re[sum]', **opts)
opts['new'] = False
#endif
if show_imag:
fig.add_plot(model.r, model.chir_im, label='Im[sum]')

for ipath, path in enumerate(dataset.pathlist):
label = 'path %i' % (1+ipath)
off = (ipath+1)*offset
if show_mag:
fig.add_plot(path.r, off+path.chir_mag, label=f'|{label}|')
if show_real:
fig.add_plot(path.r, off+path.chir_re, label=f'Re[{label}]')
if show_imag:
fig.add_plot(path.r, off+path.chir_im, label=f'Im[{label}]')

if rmax is not None:
fig.set_xrange(0, rmax)
_plot(model.r, model.chir_im, label='Im[sum]', **opts)
opts['new'] = False
#endif

ylabel = plotlabels.chirlab(kweight, show_mag=show_mag,
show_real=show_real, show_imag=show_imag)
fig.set_style(title=title, xaxis_title=plotlabels.r,
yaxis_title=ylabel)
fig.show()
return fig
for ipath in range(len(dataset.pathlist)):
plot_path_r(dataset, ipath, offset=(ipath+1)*offset,
show_mag=show_mag, show_real=show_real,
show_imag=show_imag, **opts)
#endfor
redraw(win=win, xmax=rmax,_larch=_larch)
#enddef


def extend_plotrange(x, y, xmin=None, xmax=None, extend=0.10):
Expand Down

0 comments on commit d3bcfb6

Please sign in to comment.