1 |
FUNCTION SECTIONGAPS_DAYBOUNDARY, day, gapsin, ndays=ndays, nwsg=nwsg |
2 |
|
3 |
if (n_elements(ndays) eq 0) then ndays=72 |
4 |
ppd=1440L |
5 |
nx=ndays*ppd |
6 |
gsecs=fltarr(nx)+1 |
7 |
|
8 |
daystr=strtrim(string(day),2) |
9 |
ndstr=strtrim(string(ndays),2) |
10 |
nsecs=0L |
11 |
openr,1,'secs.'+ndstr+'.'+daystr |
12 |
readf,1,nsecs |
13 |
secs=lonarr(2,nsecs) |
14 |
readf,1,secs |
15 |
close,1 |
16 |
|
17 |
startarr=secs[0,*] |
18 |
finisharr=secs[1,*] |
19 |
npts=0.0 |
20 |
maxpts=0.0 |
21 |
tmparr=lonarr(2) |
22 |
ind=0 |
23 |
|
24 |
j=0L |
25 |
while (j lt nsecs-1) do begin |
26 |
|
27 |
finish = finisharr[j] |
28 |
day0 = (finish/ppd)*ppd |
29 |
day1 = day0+ppd-1 |
30 |
if (startarr[j+1] gt day1) then begin |
31 |
j=j+1 |
32 |
continue |
33 |
endif |
34 |
start = startarr[j] > day0 |
35 |
maxpts = total(gapsin[start:finish]) |
36 |
tmparr=[start,finish] |
37 |
ind = 0 |
38 |
|
39 |
w=where(startarr gt finish and finisharr le day1,nw) |
40 |
for k=0,nw-1 do begin |
41 |
tmparr=[[tmparr],[startarr[w[k]],finisharr[w[k]]]] |
42 |
npts = total(gapsin[startarr[w[k]]:finisharr[w[k]]]) |
43 |
if (npts gt maxpts) then begin |
44 |
maxpts = npts |
45 |
ind = k+1 |
46 |
endif |
47 |
endfor |
48 |
jj = j + nw |
49 |
if (jj lt nsecs-1) then begin |
50 |
if (startarr[jj+1] le day1) then begin |
51 |
tmparr=[[tmparr],[startarr[jj+1],day1]] |
52 |
npts = total(gapsin[startarr[jj+1]:day1]) |
53 |
if (npts gt maxpts) then begin |
54 |
maxpts = npts |
55 |
ind = nw+1 |
56 |
endif |
57 |
endif |
58 |
endif |
59 |
|
60 |
start=tmparr[0,ind] |
61 |
finish=tmparr[1,ind] |
62 |
if (day0 lt start) then gsecs[day0:start-1]=0 |
63 |
if (day1 gt finish) then gsecs[finish+1:day1]=0 |
64 |
|
65 |
j=jj+1 |
66 |
|
67 |
endwhile |
68 |
|
69 |
wsg=where(gsecs eq 0,nwsg) |
70 |
return,wsg |
71 |
|
72 |
END |