# Fityk 0.7.8 ### syntax testing ### this script doesn't assume location of any other files (ie. no data files ### are read, and produces only file in current directory, which start with ### `tmp_' prefix, eg. tmp_foo.xy # first set some options useful for testing set exit-on-warning = 1 set autoplot = never set pseudo-random-seed = 174924 set verbosity = verbose # ... and then issue as many commands as possible, checking for sytax errors # predefined data transformations M=500 x=n/100 M=500; x=n/100; y=sin(x); s=1 Y[1...] = Y[n-1] + y[n];S = sqrt(max2(1,y)) Y[...-1] = (y[n+1]-y[n])/(x[n+1]-x[n]);X[...-1] = (x[n+1]+x[n])/2 M=M-1;S = sqrt(max2(1,y)) S = s / sum(n > 0 ? (x[n] - x[n-1]) * (y[n-1] + y[n])/2 : 0); Y = y / sum(n > 0 ? (x[n] - x[n-1]) * (y[n-1] + y[n])/2 : 0) X[...-1] = (x[n]+x[n+1])/2;Y[...-1] = y[n]+y[n+1]; S[...-1] = sqrt(s[n]^2+s[n]^2); delete(n%2==1) Y=max2(y,0) delete(not a) Y=x , X=y , S=sqrt(max2(1,Y)) Y=-y a=true X = 4*pi * sin(x/2*pi/180) / 1.54051 X = asin(x/(4*pi)*1.54051) * 2*180/pi X = x[0] + n * (x[M-1]-x[0]) / (M-1), Y = y[x=X], S = s[x=X], A = a[x=X] del @0 set @0.title = 'Title X' @+ = 0 set @1.title = TitleY M = 400 in @1 X=n/M*3*pi in @1 Y=sin(x) in @1 plot in @1 sleep 0.3 M = 800 in @0 X = 10 + n/M*90 in @0 delete @1 Y = 30 Y = y + 3000 * exp(-((x-21.2)/0.3)^2) # Gaussian Y = y + 2450 / (1 + ((x-41.4)/0.3)^2) #Lorentzian $height=1901; $center=75.313; $hwhm=0.5; $shape=2.4 Y = y + $height/(1+((x-$center)/$hwhm)^2*(2^(1/$shape)-1))^$shape #Pearson VII S = sqrt(max2(1, y)) Y = randnormal(y, s) #noise plot in @0 sleep 0.3 %p = guess Lorentzian center=~75 plot in @0 sleep 0.2 del %p guess Gaussian %lo = guess SplitGaussian [38:] plot in @0 sleep 0.3 %lo = guess LorentzianA [38:44] %pe = Pearson7(height=~1901, center=~75.313, hwhm=~1/2, shape=2.4) F += %pe %ble = copy(%pe) dele %pe F += Pearson7(~2000, ~75, ~0.6, ~2) fit 2 in @0 fit+ 15 with fitting-method=Nelder-Mead-simplex fit 10 with fitting-method=Genetic-Algorithms fit 10 %fun = copy(%_1) i+ %ble, %lo $a = %ble.shape $a = %ble.shape + %lo.hwhm $b = ~{%ble.shape} + {%lo.hwhm} $abc = F[0].hwhm + 1 $abc = {F[0].hwhm + 0.1} @0.F[0].hwhm = $abc F.hwhm = $abc F.hwhm = ~{F[0].hwhm + 0.1} %lo_cp = copy(@0.F[1]) del %lo_cp fit fit history 0 fit h -1 f u f redo fi undo fi re fit history clear info version info variables i $a, $_11 inf types i functions i %fun(3), %ble(2 + 5*sin(2/3*pi) + %fun(3.3)) i %fun, %ble i datasets i commands i view i @0.F i @0.F[0], @0.F[-1] i @0.Z i formula in @0 i @0.dF(12*3) i data in @0 i filename in @0, title in @0 i fit i fit-history i set i errors i guess in @0 i guess [10:40] in @0 i ((3+5) * (2.1+pi) * exp(5)/cos(ln(3)))^2 in @0 i GaussianA, Gaussian, Linear i SplitGaussian i formula i min(y), max(s) i min(y if 20<x<25) i sum(y-y[0]) i avg(y*y), stddev(y if y > avg(y)) i darea(y-@0.F(x) if 15<x<20) info+ version, variables i+ $a, $_11 inf+ types i+ functions i+ %fun(3), %ble(2 + 5*sin(2/3*pi) + %fun(3.3)) i+ %fun, %ble i+ datasets i+ commands i+ view i+ @0.F i+ @0.F[0], @0.F[-1] i+ @0.Z i+ formula in @0 i+ @0.dF(12*3) i+ data in @0 i+ filename, title i+ fit i+ fit-history i+ set i+ errors i+ guess in @0 i+ guess [10:40] in @0 i+ ((3+5) * (2.1+pi) * exp(5)/cos(ln(3)))^2 in @0 i+ GaussianA, Gaussian, Linear # data expressions $foo = {y[0] in @0} + 1 $foo = 3 + 1 Y = y / $foo i 2*(findx(%fun, %fun.Center, %fun.Center+10, %fun.Height/2) - %fun.Center) i %fun.FWHM %c = Constant(~0.001) Z = %c + %fun Z -= %c Z = 0 Z += %c X = x + @0.Z(x) del %c i %fun(extremum(%fun, 10, 50)) i s[x=19.92]^2 in @0, y[x=19.92] in @0 plot p [30:40.2][-1:] p . . plot . [:1000] plo [:50] pl [40:] . plo [] in @* plo [:50] in @0 @+ = @0 @+ = 0 @2 = @0 + @1 del @2 @+ = avg_same_x @0 + @1 delete @2 @1.F = copy(@0.F) @1.Z = copy(@0.Z) with epsilon=0.1 @1 = sum_same_x @1 #test variable rhs syntax parsing $t1 = 3 $t2 = -$t1 $t3 = $t1+(-$t2^2) $t4=sin($t1)^2+(-cos($t1))^2 $t5=voigt($t4, ~3) define Bleh(area, center, fwhm, shape) = GaussianA(area*(1-shape), center, fwhm) + LorentzianA(area*shape, center, fwhm+0.2) %bleh = Bleh(~123., 30, ~4, ~0.5) undefine Bleh define Bleh(a) = Linear(0, a) %bleh = Bleh(~{pi}) i+ Bleh, %bleh del %bleh #TODO def Foo(a,b,c)= ....formula... info commands[2:5] # commands from script are not stored in commands[] ... info commands[8] # ... so it can be empty info+ commands[8] commands > tmp_log.fit commands+ > tmp_log.fit commands > /dev/null commands < tmp_log.fit # it's an empty file (with some comments) info commands[0:4] >tmp_foo.fit info+ commands[0] >>tmp_foo.fit info @0 (x, y) info @* (x, y, s) > tmp_foo2.xy info @0 (x, y, a) > tmp_foo3.xy info @0 (x, y, s, @0.F(x), (y-@0.F(x))/s, a) > tmp_foo4.xy info @0 (x, y, s, F(x), (y-F(x))/s, a) > tmp_foo4.xy info peaks in @0 > tmp_foo5.xy info+ peaks in @0 > tmp_foo6.xy info formula in @0 > tmp_foo7.xy info+ formula in @0 > tmp_foo8.xy info+ peaks in @* > tmp_foo9.xy dump > tmp_dump.fit # settings set can-cancel-guess # only shows info set can-cancel-guess = 1 set cut-function-level = 0 set fitting-method = Levenberg-Marquardt set formula-export-style = normal set guess-at-center-pm = 1 set height-correction = 1 set lm-lambda-down-factor = 10 set lm-lambda-start = 0.001 set lm-lambda-up-factor = 10 set lm-max-lambda = 1e+15 set lm-stop-rel-change = 0.0001 set max-wssr-evaluations = 1000 set nm-convergence = 0.0001 set nm-distribution = bound set nm-move-all = 0 set nm-move-factor = 1 set variable-domain-percent = 30 set width-correction = 1 set epsilon = 1e-12 set data-default-sigma=one set data-default-sigma=sqrt set verbosity = debug set verbosity = normal set verbosity = quiet set verbosity = verbose set exit-on-warning = 0 reset #quit