-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfixcloser.pro
49 lines (39 loc) · 1.62 KB
/
fixcloser.pro
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
PRO fixclosure
dirs=file_search('ihop?')
dt=30 & LH=23 & H=24 & Rn=20 & G=25
nsteps=48
FOR i=0,n_elements(dirs)-1 DO BEGIN
cd, current=olddir, dirs[i]
measurefile=file_search('IHOPUDS*.txt')
junk=load_cols(measurefile, data)
closure=(data[LH,*]+data[H,*])/(data[Rn,*]+data[G,*])
dailyclosure=dailyrainfall(closure, dt, /average)
print, "Closure for ; "+measurefile+" ="+strcompress(mean(closure))
IF abs(mean(closure)-1) GT 0.05 THEN BEGIN
print, ' FIXING : '+measurefile, format='($,A)'
;; for more human readable form see bottom of file for for loop version
;;
;; this assumes that the number of elements in data is an exact multiple of n_dailyclosure
adjustment=rebin( $
(1-transpose(dailyclosure))/2.0, $
2, n_elements(data[0,*]), /sample)
data[[LH,H],*]+=data[[LH,H],*] * adjustment
openw, oun, /get, 'new'+measurefile
printf, oun, data, $
format='(2(3I5,I8,I5),'+strcompress(n_elements(data[*,0])-10)+'F10.2)'
close, oun
free_lun, oun
print, ' FIXED'
ENDIF
ENDFOR
END
;; for loop version of adjustment, loops over days now do it in one big array
; FOR j=0, n_elements(dailyclosure)-1 DO BEGIN
; adjustment=(1-dailyclosure[j])/2.0
;
; data[LH,j:j+nsteps-1]+=data[LH,j:j+nsteps-1] * adjustment
; data[H,j:j+nsteps-1]+=data[H,j:j+nsteps-1] * adjustment
;
; printf, oun, data[*,j:j+nsteps-1], $
; format='(2(3I5,I8,I5),'+strcompress(n_elements(data[*,0])-10)+'F10.2)'
; ENDFOR