blob: 08c2c4e164be889660a1df7a1139bfc6876da199 (
plain) (
blame)
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
|
include <mach.h>
include <ctype.h>
include <error.h>
include "pdm.h"
# PDM_AMPEP -- Calculate the amplitude and epoch for this data.
procedure pdm_ampep (pdmp, period)
pointer pdmp # PDM structure pointer
double period # period for which to calculate
int i, isave
double npt, ymin, ymax
errchk pdm_phase
begin
npt = PDM_NPT(pdmp)
# Find the maximum and minimum values in the data.
# The difference is the amplitude.
ymax = -MAX_DOUBLE
ymin = MAX_DOUBLE
do i = 1, npt {
if (PDM_INUSE(pdmp,i) == 0)
next
if (PDM_DY(pdmp,i) < ymin)
ymin = PDM_DY(pdmp,i)
if (PDM_DY(pdmp,i) > ymax) {
ymax = PDM_DY(pdmp,i)
isave = i
}
}
PDM_AMPL(pdmp) = ymax - ymin
PDM_EPOCH(pdmp) = PDM_X(pdmp, isave)
end
|