1 | ;------------------------------------------------------------ |
---|
2 | pro flux_evaluation_tpr_timeseries, $ |
---|
3 | ; var, $ ;; flux variable (swr, lwr, lhf, shf) to calculate the statistics |
---|
4 | date1, $ ;; start date (in julian date. eg. 20000101) |
---|
5 | date2 ;; end date (in julian date eg. 20091231) |
---|
6 | |
---|
7 | @common |
---|
8 | ;------------------------------------------------------------ |
---|
9 | reinitplt, /z,/invert |
---|
10 | key_portrait = 0 |
---|
11 | openps, FILENAME = 'idl.ps' |
---|
12 | ;------------------------------------------------------------ |
---|
13 | ;; part to change |
---|
14 | |
---|
15 | min_obs=10. ;; this will allow to calculate statistics at locations with more than 180. valid observation |
---|
16 | |
---|
17 | ;; choose the appropriate min and max values for the following. |
---|
18 | |
---|
19 | bias_mi=-5 & bias_ma=5 & bias_int=0.5 |
---|
20 | std_mi=0.5 & std_ma=1.5 & std_int=0.05 |
---|
21 | rmsd_mi=0 & rmsd_ma=15 & rmsd_int=1.5 |
---|
22 | cor_mi=0.5 & cor_ma=1. & cor_int=0.025 |
---|
23 | |
---|
24 | ;------------------------------------------------------------ |
---|
25 | ;; Before running this program, you have to compile the following subroutines |
---|
26 | ;; .r extract_tpr_location |
---|
27 | ;; .r read_tpr_netflux |
---|
28 | |
---|
29 | ;; TPR locations. This needs to be updated with time since more locations are added to the array. |
---|
30 | |
---|
31 | sitelist=['5n165e','8s67e','12s55e', '8s55e', '8s80.5e', '1.5s80.5e', '0n80.5e', '1.5n80.5e', '1.5s90e', $ |
---|
32 | '0n90e', '1.5n90e', '4n90e','8n90e','12n90e', '15n90e', '5s95e', $ |
---|
33 | '8s165e', '8s180w', '8s155w', '8s125w', '8s110w', '8s95w', '5s156e', '5s165e', '5s180w', '5s170w', $ |
---|
34 | '5s155w', '5s140w', '5s125w', '5s110w', '5s95w', '2s156e', '2s165e', '2s180w', '2s170w', '2s155w', '2s140w', $ |
---|
35 | '2s125w', '2s110w', '2s95w', '0n147e', '0n156e', '0n165e', '0n180w', '0n170w', '0n155w', '0n140w', '0n125w', $ |
---|
36 | '0n110w', '0n95w', '2n147e', '2n156e', '2n165e', '2n180w', '2n170w', '2n155w', '2n140w', '2n125w', '2n110w', $ |
---|
37 | '2n95w', '5n147e', '5n156e', '5n170w', '5n155w', '5n140w', '5n125w', '5n110w', '5n95w', $ |
---|
38 | '8n156e', '8n165e', '8n180w', '8n170w', '9n140w', '8n125w', '8n110w', '8n95w', $ |
---|
39 | '0n0e', '0n10w', '0n23w', '0n35w', '10s10w', '12n23w', '12n38w', '14s32w', '15n38w', '19s34w', '20n38w', $ |
---|
40 | '21n23w', '4n23w', '4n38w', '6s10w', '8n38w', '8s30w'] |
---|
41 | |
---|
42 | ;------------------------------------------------------------------------------------------------------------------------ |
---|
43 | ;; This program will create the following text files with statistics of respective variables |
---|
44 | ;------------------------------------------------------------------------------------------------------------------------ |
---|
45 | close,/all |
---|
46 | |
---|
47 | fi='/Users/pkb/work/MY_SAXO/TropFlux_update/flux_stat.txt' |
---|
48 | openw,1,fi |
---|
49 | |
---|
50 | printf,1, 'x y cor bias std ratio rmsd' |
---|
51 | ;------------------------------------------------------------------------------------------------------------------------ |
---|
52 | ;; First, this program reads the full TropFlux data and later extract it at specific TPR locations |
---|
53 | |
---|
54 | file="/Volumes/PAYASAM/TropFlux/TropFlux/shf_tropflux_1d_1989_2010.nc" |
---|
55 | initncdf, file |
---|
56 | var=-1*read_ncdf("shf", date1, date2, file=file,/nostr) |
---|
57 | help, var |
---|
58 | |
---|
59 | ;------------------------------------------------------------------------------------------------------------------------ |
---|
60 | nn=n_elements(sitelist) |
---|
61 | date1=date1 |
---|
62 | date2=date2 |
---|
63 | nsmooth=1. ;; this will return daily TPR values |
---|
64 | mooring=0 & product=0 |
---|
65 | |
---|
66 | for n=0, nn-1 do begin |
---|
67 | |
---|
68 | ;; reading data from mooring |
---|
69 | |
---|
70 | site=sitelist(n) & csite=site |
---|
71 | print, csite |
---|
72 | x=x_site_location(site) |
---|
73 | y=y_site_location(site) |
---|
74 | if (y ge 0. and y le 30.) then y=y+360. |
---|
75 | dx=0.5 & dy=0.5 & box=[y-dy, y+dy, x-dx, x+dx] |
---|
76 | |
---|
77 | read_tpr_netflux, csite,date1,date2,nsmooth, $ |
---|
78 | sw,lw,sh,lh |
---|
79 | |
---|
80 | ;; select the appropriate variables for evaluation (trp = sw or lw or sh or lh) |
---|
81 | |
---|
82 | tpr=sh |
---|
83 | |
---|
84 | ind=where(finite(tpr)) & no_valid=n_elements(ind) |
---|
85 | |
---|
86 | if (no_valid ge min_obs) then begin |
---|
87 | |
---|
88 | |
---|
89 | extract_tpr_location,var,box, $ |
---|
90 | var_tpr |
---|
91 | var_tpr=reform(var_tpr) |
---|
92 | |
---|
93 | stats_5d, tpr,var_tpr, $ ;; tpr=TPR observation and var_tpr=gridded product extracted at TPR location |
---|
94 | cor, bias, std, rmsd |
---|
95 | |
---|
96 | printf, 1, x, y, cor, bias, std, rmsd, format='(f6.2, 3x, f6.2, 3x, f4.2, 3x, f7.2, 3x, f4.2, 3x, f5.2)' |
---|
97 | cstat=string(cor, bias, std, rmsd, format='(f4.2,3x,f7.2,3x,f4.2,3x,f5.2)') |
---|
98 | print, cstat |
---|
99 | |
---|
100 | ;; PLOTTING THE TIME-SERIES |
---|
101 | array=[tpr, var_tpr] & mi=min(array,/nan) & ma=max(array,/nan) & int=(ma-mi)/3. |
---|
102 | pltt, ts_smooth(tpr,5,/nan), "t",/rempl, small=[1,3,1], lct=65, $ |
---|
103 | title='Five day stats are shown below. TPR (black) and Product (red) at'+csite+' ', charsize=1., $ |
---|
104 | subtitle=cstat |
---|
105 | ind=where(finite(tpr,/nan)) & var_tpr(ind)=!Values.f_nan |
---|
106 | pltt, ts_smooth(var_tpr,5,/nan), "t",/ov1d, color=250 |
---|
107 | erase |
---|
108 | mooring=[mooring,tpr] & product=[product,var_tpr] |
---|
109 | endif |
---|
110 | endfor |
---|
111 | |
---|
112 | close,/all |
---|
113 | ;---------------------------------------------------------- |
---|
114 | closeps |
---|
115 | |
---|
116 | fig='flux_evaluation_tpr_timeseries.ps' |
---|
117 | spawn, 'mv '+psdir+'idl.ps '+updatedir+fig |
---|
118 | spawn, 'gv '+updatedir+fig |
---|
119 | return |
---|
120 | end |
---|
121 | ;-------------------------------------------------------------------------- |
---|
122 | function x_site_location, site |
---|
123 | n1=strpos(site, 's') |
---|
124 | if (n1 gt -1) then begin |
---|
125 | ns=-1. |
---|
126 | x=strmid(site, 0, n1) |
---|
127 | x=float(x)*ns |
---|
128 | endif else begin |
---|
129 | n1=strpos(site, 'n') |
---|
130 | x=strmid(site, 0, n1) |
---|
131 | ny=1. |
---|
132 | x=float(x)*ny |
---|
133 | endelse |
---|
134 | return, float(x) |
---|
135 | end |
---|
136 | ;-------------------------------------------------------------------------- |
---|
137 | function y_site_location, site |
---|
138 | n1=strpos(site, 'e') |
---|
139 | if (n1 gt -1) then begin |
---|
140 | n=strpos(site, 's') |
---|
141 | if (n gt -1) then begin |
---|
142 | y=strmid(site, n+1, n1-n-1) |
---|
143 | endif else begin |
---|
144 | n=strpos(site, 'n') |
---|
145 | y=strmid(site, n+1, n1-n-1) |
---|
146 | endelse |
---|
147 | |
---|
148 | endif else begin |
---|
149 | n1=strpos(site, 'w') |
---|
150 | n=strpos(site, 's') |
---|
151 | if (n gt -1) then begin |
---|
152 | y=strmid(site, n+1, n1-n-1) |
---|
153 | y=180+(180-float(y)) |
---|
154 | endif else begin |
---|
155 | n=strpos(site, 'n') |
---|
156 | y=strmid(site, n+1, n1-n-1) |
---|
157 | y=180+(180-float(y)) |
---|
158 | endelse |
---|
159 | endelse |
---|
160 | return,float(y) |
---|
161 | end |
---|
162 | |
---|
163 | ;-------------------------------------------------------------------------- |
---|
164 | |
---|