-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcentroidmin.f
More file actions
executable file
·51 lines (43 loc) · 1.13 KB
/
centroidmin.f
File metadata and controls
executable file
·51 lines (43 loc) · 1.13 KB
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
c find the centroid of a minimum in chisq given its
c approx location. indx is the index of the minimum
c we found with findmultmin or whatever
function centroidmin(n,x,y,indx)
integer indx
real x(n),y(n)
c real centroidmin
c look in a window this size around the min
nwtmin = 5
c buffer
nbuff = 3
c window for "continuum"
ncontwin = 10
csum=0.0
ncont=0
i1 = max(1,indx-nwtmin-nbuff-ncontwin)
i2 = max(1,indx-nwtmin-nbuff-1)
do i=i1,i2
csum=csum+y(i)
ncont=ncont+1
end do
i1= min(n,indx+nwtmin+nbuff+1)
i2= min(n,indx+nwtmin+nbuff+ncontwin)
do i=i1,i2
csum = csum+y(i)
ncont=ncont+1
end do
cont=csum/ncont
c this is like finding a center of mass:
c take the y-weighted mean of the x_i
c (but make the weights y minus continuum)
xysum = 0.0
wtsum = 0.0
i1 = min(n,indx-nwtmin)
i2 = min(n,indx+nwtmin)
do i=i1,i2
wt = y(i)-cont
xysum = xysum+wt*x(i)
wtsum = wtsum+wt
end do
centroidmin = xysum/wtsum
return
end