# [Ifeffit] linear combination using program code of athena

Bernd Griesebock griesebock at uni-wuppertal.de
Sun Jan 7 20:31:48 CST 2007

```Hi all,

I have a little problem using ifeffit with program code taken from athena.
I try to make some linear combination calculations. Using Athena it
works but using the code with ifeffit, I get some errors. Everything
works fine untill the following lines:

unguess
erase @group l___cf
set l___cf.eee = rh.energy+0
set l___cf_npts = npts(l___cf.energy)
set l___cf.data = splint(l___cf.eee,  rh.flat, l___cf.energy)

** cannot set scalar value to array **
l___cf.data = splint(l___cf.eee,rh.flat,l___cf.energy)

The problem here seems to be the array "l___cf.energy". It is empty and
I never found some declarations for it. At the beginning of my program I
wrong with that code?

Thank you for help, best regards
Bernd

P.S. If it helps, here is the complete code for ifeffit of my perl program:

#get standards

group=\"cu\", label = 'energy_KeV xmu')");
ifeffit(" set cu.energy = cu.energy_KeV * 1000");
ifeffit(" set ___n = npts(cu.energy_KeV)");
ifeffit(" pre_edge(\"cu.energy+0\", cu.xmu, e0=8979.1, pre1=-150,
pre2=-30, norm_order=3, norm1=150, norm2=430)");
ifeffit(" spline(\"cu.energy+0\", cu.xmu, e0=8979.1, rbkg=1.0, kmin=0.5,
kmax=12, kweight=1, dk=2, kwindow=kaiser-bessel, \
pre1=-150, pre2=-30, norm_order=3, norm1=150, norm2=430,
ifeffit(" set cu.preline = pre_offset + pre_slope * (cu.energy + 0)");
ifeffit(" set cu.postline = norm_c0 + norm_c1 * (cu.energy + 0.000000) +
norm_c2 * (cu.energy + 0.000000)**2");
ifeffit(" step cu.energy e0 cu.theta");
ifeffit(" set flat_c0 = norm_c0 - pre_offset");
ifeffit(" set flat_c1 = norm_c1 - pre_slope");
ifeffit(" set flat_c2 = norm_c2");
ifeffit(" set cu.line = (flat_c0 + flat_c1 * (cu.energy+0) + flat_c2 *
(cu.energy+0)**2)");
ifeffit(" set cu.flat = (cu.pre + (edge_step - cu.line) * cu.theta) /
edge_step");
ifeffit(" set cu.fbkg =
(cu.bkg-cu.preline+(edge_step-cu.line)*cu.theta)/edge_step");

group=\"cuo\", label = 'energy_KeV xmu')");
ifeffit(" set cuo.energy = cuo.energy_KeV * 1000");
ifeffit(" set ___n = npts(cuo.energy_KeV)");
ifeffit(" pre_edge(\"cuo.energy+0\", cuo.xmu, e0=8991.6, pre1=-150,
pre2=-30, norm_order=3, norm1=150, norm2=430)");
ifeffit(" spline(\"cuo.energy+0\", cuo.xmu, e0=8991.6, rbkg=1.0,
kmin=0.5, kmax=12, kweight=1, dk=2, kwindow=kaiser-bessel, \
pre1=-150, pre2=-30, norm_order=3, norm1=150, norm2=430,
ifeffit(" set cuo.preline = pre_offset + pre_slope * (cuo.energy + 0)");
ifeffit(" set cuo.postline = norm_c0 + norm_c1 * (cuo.energy + 0.000000)
+ norm_c2 * (cuo.energy + 0.000000)**2");
ifeffit(" step cuo.energy e0 cuo.theta");
ifeffit(" set flat_c0 = norm_c0 - pre_offset");
ifeffit(" set flat_c1 = norm_c1 - pre_slope");
ifeffit(" set flat_c2 = norm_c2");
ifeffit(" set cuo.line = (flat_c0 + flat_c1 * (cuo.energy+0) + flat_c2 *
(cuo.energy+0)**2)");
ifeffit(" set cuo.flat = (cuo.pre + (edge_step - cuo.line) * cuo.theta)
/ edge_step");
ifeffit(" set cuo.fbkg =
(cuo.bkg-cuo.preline+(edge_step-cuo.line)*cuo.theta)/edge_step");

group=\"cu2o\", label = 'energy_KeV xmu')");
ifeffit(" set cu2o.energy = cu2o.energy_KeV * 1000");
ifeffit(" set ___n = npts(cu2o.energy_KeV)");
ifeffit(" pre_edge(\"cu2o.energy+0\", cu2o.xmu, e0=8980.6,  pre1=-150,
pre2=-30, norm_order=3, norm1=150, norm2=430)");
ifeffit(" spline(\"cu2o.energy+0\", cu2o.xmu, e0=8980.6, rbkg=1.0,
kmin=0.5, kmax=12, kweight=1, dk=2, kwindow=kaiser-bessel, \
pre1=-150, pre2=-30, norm_order=3, norm1=150, norm2=430,
ifeffit(" set cu2o.preline = pre_offset + pre_slope * (cu2o.energy + 0)");
ifeffit(" set cu2o.postline = norm_c0 + norm_c1 * (cu2o.energy +
0.000000) + norm_c2 * (cu2o.energy + 0.000000)**2");
ifeffit(" step cu2o.energy e0 cu2o.theta");
ifeffit(" set flat_c0 = norm_c0 - pre_offset");
ifeffit(" set flat_c1 = norm_c1 - pre_slope");
ifeffit(" set flat_c2 = norm_c2");
ifeffit(" set cu2o.line = (flat_c0 + flat_c1 * (cu2o.energy+0) + flat_c2
* (cu2o.energy+0)**2)");
ifeffit(" set cu2o.flat = (cu2o.pre + (edge_step - cu2o.line) *
cu2o.theta) / edge_step");
ifeffit(" set cu2o.fbkg =
(cu2o.bkg-cu2o.preline+(edge_step-cu2o.line)*cu2o.theta)/edge_step");

#get data

ifeffit(" read_data(file = /tmp/spektrum\$i.dat, group=\"rh\", label =
'energy_KeV xmu')");
ifeffit(" set rh.energy = rh.energy_KeV * 1000");
ifeffit(" set ___n = npts(rh.energy_KeV)");
ifeffit(" pre_edge(\"rh.energy+0\", rh.xmu, pre1=-150, pre2=-30,
norm_order=3, norm1=150, norm2=430)");
ifeffit(" spline(\"rh.energy+0\", rh.xmu, rbkg=1.0, kmin=0.5, kmax=12,
kweight=1, dk=2, kwindow=kaiser-bessel, \
pre1=-150, pre2=-30, norm_order=3, norm1=150, norm2=430,
\$estart = get_scalar("e0");
ifeffit(" set rh.preline = pre_offset + pre_slope * (rh.energy + 0)");
ifeffit(" set rh.postline = norm_c0 + norm_c1 * (rh.energy + 0.000000) +
norm_c2 * (rh.energy + 0.000000)**2");
ifeffit(" step rh.energy e0 rh.theta");
ifeffit(" set flat_c0 = norm_c0 - pre_offset");
ifeffit(" set flat_c1 = norm_c1 - pre_slope");
ifeffit(" set flat_c2 = norm_c2");
ifeffit(" set rh.line = (flat_c0 + flat_c1 * (rh.energy+0) + flat_c2 *
(rh.energy+0)**2)");
ifeffit(" set rh.flat = (rh.pre + (edge_step - rh.line) * rh.theta) /
edge_step");
ifeffit(" set rh.fbkg =
(rh.bkg-rh.preline+(edge_step-rh.line)*rh.theta)/edge_step");

ifeffit(" set &status = 0");
ifeffit(" erase delta_e1 delta_w1 delta_ww1");
ifeffit(" erase delta_e2 delta_w2 delta_ww2");
ifeffit(" erase delta_e3 delta_w3 delta_ww3");
ifeffit(" erase delta_e4 delta_w4 delta_ww4");
ifeffit(" erase delta_yint delta_slope");

# performing linear combination fit in norm(E)

ifeffit(" unguess");
ifeffit(" erase \@group l___cf");
ifeffit(" set l___cf.eee = rh.energy+0");

ifeffit(" set l___cf_npts = npts(l___cf.energy)");
ifeffit(" set l___cf.data = splint(l___cf.eee, rh.flat, l___cf.energy)");

ifeffit(" guess e1 = 0");
ifeffit(" guess ww1 = 0.333");
ifeffit(" def w1 = max(0,min(ww1,1))");
ifeffit(" def l___cf.1 = abs(w1)*splint(cu.energy+e1+0.00, cu.flat,
l___cf.energy)");

ifeffit(" def e2 = e1");
ifeffit(" guess ww2 = 0.333");
ifeffit(" def w2 = max(0,min(ww2,1))");
ifeffit(" def l___cf.2 = abs(w2)*splint(cuo.energy+e2+0.00, cuo.flat,
l___cf.energy)");

ifeffit(" def w3 = max(0, 1 - (w1+w2))");
ifeffit(" def e3 = e1");
ifeffit(" def l___cf.3 = w3*splint(cu20.energy+e3+0.00, cu2o.flat,
l___cf.energy)");
ifeffit(" def l___cf.mix = l___cf.1 + l___cf.2 + l___cf.3");
ifeffit(" def l___cf.resid = l___cf.mix - l___cf.data");
\$xmin = \$estart - 20;
\$xmax = \$estart + 30;
ifeffit(" minimize(l___cf.resid, x=l___cf.energy, \$xmin, \$xmax)");

...
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://millenia.cars.aps.anl.gov/pipermail/ifeffit/attachments/20070108/e9107223/attachment.html>
```