1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
|
program ROM;
{$DEFINE UseCThreads}
{$mode objfpc}{$H+}
uses
{$IFDEF UNIX}{$IFDEF UseCThreads}
cthreads,
{$ENDIF}{$ENDIF}
Classes
{ you can add units after this },
SysUtils,ROMunit, mathunit, Math;
var inPulsO,inPuls,refPuls,surTraj,cRefPuls: tExtPointArray;
i,smooth: longint;
tmax,wmax,absShift: extended;
force,fourier: boolean;
const Verwendung='Verwendung: ROM ($Einfallspuls_Datei $Ausfallspuls_Datei)/(- $trace-Datei-Prefix) $output_inPuls $output_refPuls $output_Trajektorie $output_cRefPuls '+
'[-s/--smooth $n] [-f/--force] [-t/--tmax $t] [-w/--wmax $w] [-F/--FFT] [-d/--dt $dt]';
begin
if paramcount<6 then Fehler(Verwendung);
i:=7;
force:=false;
smooth:=1;
tmax:=-1;
wmax:=-1;
fourier:=false;
absShift:=-1e9;
while i<=paramcount do begin
if (paramstr(i)='--force') or (paramstr(i)='-f') then begin
force:=true;
inc(i);
continue;
end;
if (paramstr(i)='--smooth') or (paramstr(i)='-s') then begin
inc(i);
smooth:=strtoint(paramstr(i));
inc(i);
continue;
end;
if (paramstr(i)='--tmax') or (paramstr(i)='-t') then begin
inc(i);
tmax:=strtofloat(paramstr(i));
inc(i);
continue;
end;
if (paramstr(i)='--wmax') or (paramstr(i)='-w') then begin
inc(i);
wmax:=strtofloat(paramstr(i));
fourier:=true;
inc(i);
continue;
end;
if (paramstr(i)='--dt') or (paramstr(i)='-d') then begin
inc(i);
if paramstr(i)='auto' then begin
absShift:=-1e9;
inc(i);
continue;
end;
if paramstr(i)='input' then begin
if paramstr(1)<>'-' then Fehler('Ich brauche zur Bestimmung der Gesamtverschiebung die Inputdatei vom LPIC!');
absShift:=-2e9;
inc(i);
continue;
end;
absShift:=strtofloat(paramstr(i));
inc(i);
continue;
end;
if (paramstr(i)='--FFT') or (paramstr(i)='-F') then begin
fourier:=true;
inc(i);
continue;
end;
Fehler(Verwendung);
end;
if paramstr(1)='-' then
readRawInputs(paramstr(2),inPulsO,refPuls,absShift)
else begin
readTextInput(paramstr(1),inPulsO);
readTextInput(paramstr(2),refPuls);
end;
write(stderr,'Input sortieren ...');
sort(inPulsO);
sort(refPuls);
writeln(stderr,' fertig');
uniq(inPulsO,false);
uniq(refPuls,false);
write(stderr,'Input interpolieren ...');
interpoliere(inPulsO);
interpoliere(refPuls);
writeln(stderr,' fertig');
flip(refPuls);
integrate(inPulsO,inPuls);
integrate(refPuls);
removeLinearOffset(inPuls);
removeLinearOffset(refPuls);
if smooth>1 then begin
write(stderr,'glätten ...');
smoothen(inPuls,smooth);
smoothen(refPuls,smooth);
writeln(stderr,' fertig');
end;
cut(inPuls,tmax);
cut(refPuls,tmax);
for i:=3 to 5 do
if (paramstr(i)<>'-') and fileexists(paramstr(i)) and not force then Fehler('Die Ausgabedatei '''+paramstr(i)+''' existiert bereits!');
gesamtverschiebung(inPuls,refPuls,absShift);
write(stderr,'Trajektorie berechnen ...');
berechneTrajektorie(inPuls,refPuls,surTraj,absShift*byte(not fourier));
writeln(stderr,' fertig');
write(stderr,'Ergebnis sortieren ...');
sort(surTraj);
writeln(stderr,' fertig');
uniq(surTraj,false);
if fourier then begin
write(stderr,'Ergebnis interpolieren ...');
interpoliere(surTraj);
writeln(stderr,' fertig');
fft(inPuls);
fft(refPuls);
fft(surTraj);
inPuls[0].y:=0;
refPuls[0].y:=0;
surTraj[0].y:=0;
if wmax<0 then begin
cut(surTraj,min(refPuls[length(refPuls)-1].x,inPuls[length(inPuls)-1].x)/2);
cut(inPuls,surTraj[length(surTraj)-1].x);
cut(refPuls,surTraj[length(surTraj)-1].x);
end
else begin
cut(surTraj,wmax);
cut(inPuls,wmax);
cut(refPuls,wmax);
end;
write(stderr,'alles normieren ...');
normiere(inPuls);
normiere(refPuls);
normiere(surTraj);
writeln(stderr,' fertig');
end
else begin
write(stderr,'Reflektierten Puls berechnen ...');
berechneRefPuls(inPulsO,surTraj,cRefPuls);
integrate(cRefPuls);
writeln(stderr,' fertig');
end;
if paramstr(3)<>'-' then writeOutput(paramstr(3),inPuls);
if paramstr(4)<>'-' then writeOutput(paramstr(4),refPuls);
if paramstr(5)<>'-' then writeOutput(paramstr(5),surTraj);
if (paramstr(6)<>'-') and not fourier then writeOutput(paramstr(6),cRefPuls);
end.
|