diff options
author | Erich Eckner <git@eckner.net> | 2018-07-30 15:26:47 +0200 |
---|---|---|
committer | Erich Eckner <git@eckner.net> | 2018-07-30 15:26:47 +0200 |
commit | 59cecd0385f90e25ce6c73782d5b01bba5bc5f7c (patch) | |
tree | 0bcd591b3ed0b1f4851b32cd91eacff5ca19f59c | |
parent | dd8c2a6eeedea22559c9ac5272b37b2690ad6f4d (diff) | |
download | ROM-59cecd0385f90e25ce6c73782d5b01bba5bc5f7c.tar.xz |
fft nun fensterbar
-rw-r--r-- | ROM.lpr | 30 | ||||
-rw-r--r-- | ROM.lps | 122 | ||||
-rw-r--r-- | romunit.pas | 44 |
3 files changed, 131 insertions, 65 deletions
@@ -16,7 +16,7 @@ var inPulsO,inPuls,refPulsO,refPuls,surTraj,cRefPuls, surVel,inPulsArg,refPulsArg,surTrajArg,surVelArg: tExtPointArray; smooth,betaSmooth,veloSmooth: longint; - tmax,wmax,absShift,betaBound,veloBound: extended; + tmax,wmax,absShift,betaBound,veloBound,fftBreite: extended; force,fourier,mitAmplMod: boolean; f: textfile; s,t,u,lpicIn,rohIn,rohRef,outIn, @@ -37,6 +37,7 @@ begin absShift:=-1e9; betaBound:=0.95; fourier:=false; + fftBreite:=-1; mitAmplMod:=true; veloSmooth:=1; veloBound:=1; @@ -147,6 +148,11 @@ begin fourier:=true; continue; end; + if pos('FFT-Breite:',s)=1 then begin + delete(s,1,pos(':',s)); + fftBreite:=strToFloat(trim(s)); + continue; + end; if s='ohne FFT' then begin fourier:=false; continue; @@ -273,10 +279,18 @@ begin if outVel<>'' then interpoliere(surVel); writeln(stderr,' fertig'); + if fftBreite>0 then begin + fenstern(inPuls,fftBreite); + fenstern(refPuls,fftBreite); + fenstern(surTraj,fftBreite); + if outVel<>'' then + fenstern(surVel,fftBreite,true); + end; fft(inPuls,inPulsArg); fft(refPuls,refPulsArg); fft(surTraj,surTrajArg); - fft(surVel,surVelArg); + if outVel<>'' then + fft(surVel,surVelArg); inPuls[0]['y']:=0; refPuls[0]['y']:=0; surTraj[0]['y']:=0; @@ -287,8 +301,10 @@ begin cut(inPulsArg,surTraj[length(surTraj)-1]['x']); cut(refPuls,surTraj[length(surTraj)-1]['x']); cut(refPulsArg,surTraj[length(surTraj)-1]['x']); - cut(surVel,surTraj[length(surTraj)-1]['x']); - cut(surVelArg,surTraj[length(surTraj)-1]['x']); + if outVel<>'' then begin + cut(surVel,surTraj[length(surTraj)-1]['x']); + cut(surVelArg,surTraj[length(surTraj)-1]['x']); + end; end else begin cut(surTraj,wmax); @@ -297,8 +313,10 @@ begin cut(inPulsArg,wmax); cut(refPuls,wmax); cut(refPulsArg,wmax); - cut(surVel,wmax); - cut(surVelArg,wmax); + if outVel<>'' then begin + cut(surVel,wmax); + cut(surVelArg,wmax); + end; end; write(stderr,'alles normieren ...'); normiere(inPuls); @@ -7,9 +7,9 @@ <Unit0> <Filename Value="ROM.lpr"/> <IsPartOfProject Value="True"/> - <TopLine Value="246"/> - <CursorPos X="54" Y="258"/> - <UsageCount Value="103"/> + <TopLine Value="287"/> + <CursorPos X="11" Y="319"/> + <UsageCount Value="106"/> <Loaded Value="True"/> </Unit0> <Unit1> @@ -17,10 +17,10 @@ <IsPartOfProject Value="True"/> <IsVisibleTab Value="True"/> <EditorIndex Value="1"/> - <TopLine Value="865"/> - <CursorPos X="3" Y="888"/> - <FoldState Value=" T3iE040528"/> - <UsageCount Value="103"/> + <TopLine Value="1066"/> + <CursorPos X="3" Y="1095"/> + <FoldState Value=" T3iF04052F"/> + <UsageCount Value="106"/> <Loaded Value="True"/> </Unit1> <Unit2> @@ -28,7 +28,7 @@ <IsPartOfProject Value="True"/> <EditorIndex Value="-1"/> <CursorPos Y="10"/> - <UsageCount Value="102"/> + <UsageCount Value="105"/> </Unit2> <Unit3> <Filename Value="../units/matheunit.pas"/> @@ -40,131 +40,135 @@ <Unit4> <Filename Value="../Make/tools.pas"/> <EditorIndex Value="-1"/> - <UsageCount Value="10"/> + <UsageCount Value="9"/> </Unit4> <Unit5> <Filename Value="../units/systemunit.pas"/> <EditorIndex Value="2"/> <CursorPos Y="16"/> - <UsageCount Value="13"/> + <UsageCount Value="15"/> <Loaded Value="True"/> </Unit5> </Units> - <JumpHistory Count="29" HistoryIndex="28"> + <JumpHistory Count="30" HistoryIndex="29"> <Position1> <Filename Value="romunit.pas"/> - <Caret Line="31" Column="14" TopLine="2"/> + <Caret Line="966" Column="30" TopLine="953"/> </Position1> <Position2> - <Filename Value="ROM.lpr"/> - <Caret Line="29" Column="60" TopLine="18"/> + <Filename Value="romunit.pas"/> + <Caret Line="1045" Column="48" TopLine="988"/> </Position2> <Position3> <Filename Value="romunit.pas"/> - <Caret Line="294" Column="12" TopLine="277"/> </Position3> <Position4> <Filename Value="romunit.pas"/> - <Caret Line="31" Column="14" TopLine="13"/> + <Caret Line="45" Column="20" TopLine="31"/> </Position4> <Position5> - <Filename Value="ROM.lpr"/> - <Caret Line="29" Column="28" TopLine="252"/> + <Filename Value="romunit.pas"/> + <Caret Line="316" Column="42" TopLine="329"/> </Position5> <Position6> - <Filename Value="romunit.pas"/> - <Caret Line="15" Column="30"/> + <Filename Value="ROM.lpr"/> + <Caret Line="183" Column="98" TopLine="168"/> </Position6> <Position7> - <Filename Value="romunit.pas"/> - <Caret Line="378" Column="19" TopLine="369"/> + <Filename Value="ROM.lpr"/> </Position7> <Position8> - <Filename Value="romunit.pas"/> - <Caret Line="45" Column="20" TopLine="27"/> + <Filename Value="ROM.lpr"/> + <Caret Line="18" Column="9"/> </Position8> <Position9> - <Filename Value="romunit.pas"/> - <Caret Line="316" Column="42" TopLine="287"/> + <Filename Value="ROM.lpr"/> + <Caret Line="26" Column="19"/> </Position9> <Position10> - <Filename Value="romunit.pas"/> - <Caret Line="378" Column="28" TopLine="350"/> + <Filename Value="ROM.lpr"/> + <Caret Line="33" Column="9" TopLine="4"/> </Position10> <Position11> - <Filename Value="romunit.pas"/> - <Caret Line="964" Column="21" TopLine="953"/> + <Filename Value="ROM.lpr"/> + <Caret Line="93" Column="13" TopLine="64"/> </Position11> <Position12> - <Filename Value="romunit.pas"/> - <Caret Line="966" Column="30" TopLine="953"/> + <Filename Value="ROM.lpr"/> + <Caret Line="256" Column="21" TopLine="234"/> </Position12> <Position13> <Filename Value="romunit.pas"/> - <Caret Line="1045" Column="48" TopLine="988"/> + <Caret Line="23" Column="29" TopLine="5"/> </Position13> <Position14> - <Filename Value="romunit.pas"/> + <Filename Value="ROM.lpr"/> + <Caret Line="258" Column="14" TopLine="234"/> </Position14> <Position15> <Filename Value="romunit.pas"/> - <Caret Line="45" Column="20" TopLine="31"/> + <Caret Line="15" Column="30"/> </Position15> <Position16> - <Filename Value="romunit.pas"/> - <Caret Line="316" Column="42" TopLine="329"/> + <Filename Value="ROM.lpr"/> + <Caret Line="258" Column="14" TopLine="264"/> </Position16> <Position17> - <Filename Value="ROM.lpr"/> - <Caret Line="183" Column="98" TopLine="168"/> + <Filename Value="romunit.pas"/> + <Caret Line="32" Column="23" TopLine="14"/> </Position17> <Position18> - <Filename Value="ROM.lpr"/> + <Filename Value="romunit.pas"/> + <Caret Line="876" Column="31"/> </Position18> <Position19> - <Filename Value="ROM.lpr"/> - <Caret Line="18" Column="9"/> + <Filename Value="romunit.pas"/> + <Caret Line="888" TopLine="865"/> </Position19> <Position20> - <Filename Value="ROM.lpr"/> - <Caret Line="26" Column="19"/> + <Filename Value="romunit.pas"/> + <Caret Line="36"/> </Position20> <Position21> - <Filename Value="ROM.lpr"/> - <Caret Line="33" Column="9" TopLine="4"/> + <Filename Value="romunit.pas"/> + <Caret Line="1063" Column="40" TopLine="1041"/> </Position21> <Position22> - <Filename Value="ROM.lpr"/> - <Caret Line="93" Column="13" TopLine="64"/> + <Filename Value="romunit.pas"/> + <Caret Line="1062" Column="26" TopLine="1041"/> </Position22> <Position23> - <Filename Value="ROM.lpr"/> - <Caret Line="256" Column="21" TopLine="234"/> + <Filename Value="romunit.pas"/> + <Caret Line="1068" Column="72" TopLine="1042"/> </Position23> <Position24> - <Filename Value="romunit.pas"/> - <Caret Line="23" Column="29" TopLine="5"/> + <Filename Value="ROM.lpr"/> + <Caret Line="286" Column="22" TopLine="139"/> </Position24> <Position25> <Filename Value="ROM.lpr"/> - <Caret Line="258" Column="14" TopLine="234"/> + <Caret Line="280" Column="25" TopLine="254"/> </Position25> <Position26> - <Filename Value="romunit.pas"/> - <Caret Line="15" Column="30"/> + <Filename Value="ROM.lpr"/> + <Caret Line="17" Column="11"/> </Position26> <Position27> <Filename Value="ROM.lpr"/> - <Caret Line="258" Column="14" TopLine="264"/> + <Caret Line="271" Column="26" TopLine="257"/> </Position27> <Position28> <Filename Value="romunit.pas"/> - <Caret Line="32" Column="23" TopLine="14"/> + <Caret Line="26" Column="19" TopLine="8"/> </Position28> <Position29> - <Filename Value="romunit.pas"/> - <Caret Line="876" Column="31"/> + <Filename Value="ROM.lpr"/> + <Caret Line="286" Column="37" TopLine="257"/> </Position29> + <Position30> + <Filename Value="romunit.pas"/> + <Caret Line="35" Column="61" TopLine="17"/> + </Position30> </JumpHistory> </ProjectSession> </CONFIG> diff --git a/romunit.pas b/romunit.pas index 41fa0c3..28e0df5 100644 --- a/romunit.pas +++ b/romunit.pas @@ -32,6 +32,7 @@ procedure fft(var dat: tExtPointArray; out datArg: tExtPointArray); procedure interpoliere(var dat: tExtPointArray); procedure normiere(var dat: tExtPointArray); procedure berechneRefPuls(inPuls,surTraj: tExtPointArray; betaGlaette: longint; betaBound: extended; out cRefPuls: tExtPointArray); +procedure fenstern(var dat: tExtPointArray; breite: extended; alteMitte: boolean = false); type tSortThread = class(tThread) @@ -1055,5 +1056,48 @@ begin fertig:=true; end; +var + fensterMitte: longint; + +procedure fenstern(var dat: tExtPointArray; breite: extended; alteMitte: boolean = false); +var + i,j,len: longint; + extrema: tLongintArray; + pp,mpp: extended; +begin + if not alteMitte then begin + setlength(extrema,0); + len:=0; + for i:=1 to length(dat)-2 do + if (dat[i]['y']>dat[i-1]['y']) xor + (dat[i+1]['y']>dat[i]['y']) then begin + if length(extrema)<=len then + setlength(extrema,len+65536); + extrema[len]:=i; + inc(len); + end; + setlength(extrema,len); + fensterMitte:=-1; + mpp:=-1; + for i:=0 to length(extrema)-1 do begin + pp:=-1; + for j:=0 to length(extrema)-1 do + if (abs(dat[extrema[j]]['x']-dat[extrema[i]]['x'])<2) and + (abs(dat[extrema[j]]['y']-dat[extrema[i]]['y'])>pp) then + pp:=abs(dat[extrema[j]]['y']-dat[extrema[i]]['y']); + if pp>mpp then begin + mpp:=pp; + fensterMitte:=extrema[i]; + end; + end; + end; + + for i:=0 to length(dat)-1 do + if abs(dat[i]['x']-dat[fensterMitte]['x']) >= breite then + dat[i]['y']:=0 + else + dat[i]['y']:=dat[i]['y'] * (1+cos((dat[i]['x']-dat[fensterMitte]['x'])/breite*pi))/2; +end; + end. |