source: trunk/src/flux_evaluation_tpr_timeseries.pro @ 106

Last change on this file since 106 was 106, checked in by pinsard, 12 years ago

add pkb tools for timeseries

  • Property svn:executable set to *
  • Property svn:keywords set to URL Id
File size: 6.1 KB
Line 
1;------------------------------------------------------------
2pro 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;------------------------------------------------------------
9reinitplt, /z,/invert
10key_portrait = 0
11openps, FILENAME = 'idl.ps'
12;------------------------------------------------------------
13;; part to change
14
15min_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
19bias_mi=-5      &  bias_ma=5     & bias_int=0.5
20std_mi=0.5      &  std_ma=1.5    & std_int=0.05
21rmsd_mi=0       &  rmsd_ma=15    & rmsd_int=1.5
22cor_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
31sitelist=['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;------------------------------------------------------------------------------------------------------------------------
45close,/all
46
47fi='/Users/pkb/work/MY_SAXO/TropFlux_update/flux_stat.txt'
48openw,1,fi
49
50printf,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
54file="/Volumes/PAYASAM/TropFlux/TropFlux/shf_tropflux_1d_1989_2010.nc"
55initncdf, file
56var=-1*read_ncdf("shf", date1, date2, file=file,/nostr)
57help, var
58
59;------------------------------------------------------------------------------------------------------------------------
60nn=n_elements(sitelist)
61date1=date1
62date2=date2
63nsmooth=1. ;; this will return daily TPR values
64mooring=0 & product=0
65
66for 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
110endfor
111
112close,/all
113;----------------------------------------------------------
114closeps
115
116fig='flux_evaluation_tpr_timeseries.ps'
117spawn, 'mv '+psdir+'idl.ps '+updatedir+fig
118spawn, 'gv '+updatedir+fig
119return
120end
121;--------------------------------------------------------------------------
122function x_site_location, site
123    n1=strpos(site, 's')
124if (n1 gt -1) then begin
125    ns=-1.
126    x=strmid(site, 0, n1)
127    x=float(x)*ns
128endif else begin
129    n1=strpos(site, 'n')
130    x=strmid(site, 0, n1)
131    ny=1.
132    x=float(x)*ny
133endelse
134return, float(x)
135end
136;--------------------------------------------------------------------------
137function y_site_location, site
138    n1=strpos(site, 'e')
139if (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
148endif 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
159endelse
160return,float(y)
161end
162
163;--------------------------------------------------------------------------
164
Note: See TracBrowser for help on using the repository browser.