Changeset 107 for trunk/src


Ignore:
Timestamp:
11/30/11 15:53:12 (12 years ago)
Author:
pinsard
Message:

first diag on pkb tools for timeseries

Location:
trunk/src
Files:
4 edited
2 copied

Legend:

Unmodified
Added
Removed
  • trunk/src/basic_variable_evaluation_tpr_timeseries.pro

    r106 r107  
    1 ;------------------------------------------------------------ 
     1;+ 
     2; 
     3; .. _basic_variable_evaluation_tpr_timeseries.pro: 
     4; 
     5; ============================================ 
     6; basic_variable_evaluation_tpr_timeseries.pro 
     7; ============================================ 
     8; 
     9; DESCRIPTION 
     10; =========== 
     11; 
     12; SEE ALSO 
     13; ======== 
     14; 
     15; :ref:`project_profile.sh` 
     16; :ref:`project_init.pro` 
     17; :ref:`cm_project.pro` 
     18; 
     19; use :func:`read_basic_var`, :func:`x_site_location`, :func:`y_site_location` 
     20; 
     21; TODO 
     22; ==== 
     23; 
     24; make it work : missing extract_tpr_location.pro 
     25; 
     26; uncomment var parameter 
     27; 
     28; correct bad check on unavailable tpr data 
     29; 
     30; EXAMPLES 
     31; ======== 
     32; 
     33; :: 
     34; 
     35;   IDL> date1 = 20000101L 
     36;   IDL> date2 = 20091231L 
     37;   IDL> basic_variable_evaluation_tpr_timeseries, date1, date2 
     38; 
     39; EVOLUTIONS 
     40; ========== 
     41; 
     42; $Id$ 
     43; 
     44; $URL$ 
     45; 
     46; - fplod 20111130T133857Z cratos (Linux) 
     47; 
     48;   * try to make it work on my account on cratos 
     49;   * remove x_site_location and  x_site_location because already exist 
     50; 
     51;- 
    252pro basic_variable_evaluation_tpr_timeseries, $ 
    353;                   var,    $ ;;  basic variable (sst, t2m, q2m, ws) to calculate the statistics 
    454                    date1,  $ ;;  start date (in julian date. eg. 20000101) 
    555                    date2     ;;  end date (in julian date eg. 20091231) 
    6  
    756@common 
     57@cm_project 
    858;------------------------------------------------------------ 
    959reinitplt, /z,/invert 
    1060key_portrait = 0 
    11 openps, FILENAME = 'idl.ps' 
     61openps, FILENAME = project_od_env+'basic_variable_evaluation_tpr_timeseries.ps' 
    1262;------------------------------------------------------------ 
    1363;; part to change 
     
    1767;------------------------------------------------------------ 
    1868;; Before running this program, you have to compile the following subroutines 
    19 ;; .r read_basic_var  
     69;; .r read_basic_var 
    2070 
    2171;; TPR locations.  This needs to be updated with time since more locations are added to the array. 
     
    3787close,/all 
    3888 
    39 fi='/Users/pkb/work/MY_SAXO/TropFlux_update/basic_var_stat.txt' 
     89fi = project_id_env + 'basic_var_stat.txt' 
    4090openw,1,fi 
    4191 
     
    4494;; First, this program reads the full TropFlux data and later extract it at specific TPR locations 
    4595 
    46 file="/Volumes/PAYASAM/TropFlux/TropFlux/sst_tropflux_1d_1989_2010.nc" 
     96file = project_id_env + "sst_tropflux_1d_1989_2010.nc" 
    4797initncdf, file 
    4898var=read_ncdf("sst", date1, date2, file=file,/nostr) 
     
    66116    if (y ge 0. and y le 30.) then y=y+360. 
    67117    dx=0.5 & dy=0.5 & box=[y-dy, y+dy, x-dx, x+dx] 
    68       
     118 
    69119    read_basic_var, csite,date1,date2,nsmooth, $ 
    70120            at, rh, sst, wu, wv, ws 
    71  
     121help, sst 
     122print, sst 
    72123;; select the appropriate variables for evaluation (trp = sw or lw or sh or lh) 
    73124 
     
    89140           cstat=string(cor, bias, std, rmsd, format='(f4.2,3x,f7.2,3x,f4.2,3x,f5.2)') 
    90141           print, cstat 
    91   
     142 
    92143;;         PLOTTING THE TIME-SERIES 
    93144           array=[tpr, var_tpr] & mi=min(array,/nan) & ma=max(array,/nan) & int=(ma-mi)/3. 
     
    103154 
    104155close,/all 
    105 ;---------------------------------------------------------- 
    106156closeps 
    107157 
    108 fig='basic_variable_evaluation_tpr_timeseries.ps' 
    109 spawn, 'mv '+psdir+'idl.ps '+updatedir+fig 
    110 spawn, 'gv '+updatedir+fig 
    111 return 
    112158end 
    113 ;-------------------------------------------------------------------------- 
    114 function x_site_location, site 
    115     n1=strpos(site, 's') 
    116 if (n1 gt -1) then begin 
    117     ns=-1. 
    118     x=strmid(site, 0, n1) 
    119     x=float(x)*ns 
    120 endif else begin 
    121     n1=strpos(site, 'n') 
    122     x=strmid(site, 0, n1) 
    123     ny=1. 
    124     x=float(x)*ny 
    125 endelse 
    126 return, float(x) 
    127 end 
    128 ;-------------------------------------------------------------------------- 
    129 function y_site_location, site 
    130     n1=strpos(site, 'e') 
    131 if (n1 gt -1) then begin 
    132     n=strpos(site, 's') 
    133     if (n gt -1) then begin 
    134         y=strmid(site, n+1, n1-n-1) 
    135     endif else begin 
    136         n=strpos(site, 'n') 
    137         y=strmid(site, n+1, n1-n-1) 
    138     endelse 
    139  
    140 endif else begin 
    141     n1=strpos(site, 'w') 
    142     n=strpos(site, 's') 
    143     if (n gt -1) then begin 
    144         y=strmid(site, n+1, n1-n-1) 
    145         y=180+(180-float(y)) 
    146     endif else begin 
    147         n=strpos(site, 'n') 
    148         y=strmid(site, n+1, n1-n-1) 
    149         y=180+(180-float(y)) 
    150    endelse 
    151 endelse 
    152 return,float(y) 
    153 end 
    154  
    155 ;-------------------------------------------------------------------------- 
    156  
  • trunk/src/flux_evaluation_tpr_map.pro

    r106 r107  
    1 ;------------------------------------------------------------ 
     1;+ 
     2; 
     3; .. _flux_evaluation_tpr_map.pro: 
     4; 
     5; =========================== 
     6; flux_evaluation_tpr_map.pro 
     7; =========================== 
     8; 
     9; DESCRIPTION 
     10; =========== 
     11; 
     12; SEE ALSO 
     13; ======== 
     14; 
     15; :ref:`project_profile.sh` 
     16; :ref:`project_init.pro` 
     17; :ref:`cm_project.pro` 
     18; 
     19; TODO 
     20; ==== 
     21; 
     22; make it work : need output of flux_evaluation_tpr_timeseries.pro 
     23; 
     24; uncomment var 
     25;  
     26; coding rules 
     27; 
     28; EXAMPLES 
     29; ======== 
     30; 
     31; :: 
     32; 
     33;   IDL> date1 = 20000101L 
     34;   IDL> date2 = 20091231L 
     35;   IDL> flux_evaluation_tpr_map, date1, date2 
     36; 
     37; EVOLUTIONS 
     38; ========== 
     39; 
     40; $Id$ 
     41; 
     42; $URL$ 
     43; 
     44; - fplod 20111130T142224Z cratos (Linux) 
     45; 
     46;   * try to make it work on my account on cratos 
     47;   * remove x_site_location and  x_site_location because already exist 
     48; 
     49;- 
    250pro flux_evaluation_tpr_map, $ 
    351;                    var,    $ ;;  flux variable (swr, lwr, lhf, shf) to calculate the statistics 
     
    654 
    755@common 
    8 ;------------------------------------------------------------ 
     56@cm_project 
    957reinitplt, /z,/invert 
    1058key_portrait = 1 
    11 openps, FILENAME = 'idl.ps' 
    12 ;------------------------------------------------------------ 
     59openps, FILENAME = project_od_env+'flux_evaluation_tpr_map.ps' 
     60; 
    1361;; part to change 
    1462 
     
    2169rmsd_mi=0       &  rmsd_ma=15    & rmsd_int=1.5 
    2270cor_mi=0.5      &  cor_ma=1.     & cor_int=0.025 
    23  
    24 ;------------------------------------------------------------ 
    2571 
    2672;; TPR locations.  This needs to be updated with time since more locations are added to the array. 
     
    3783          '21n23w', '4n23w', '4n38w', '6s10w', '8n38w', '8s30w'] 
    3884 
    39 ;------------------------------------------------------------------------------------------------------------------------ 
    4085;;   This program will create the following text files with statistics of respective variables 
    41 ;------------------------------------------------------------------------------------------------------------------------ 
     86 
    4287close,/all 
    4388 
    44 ;fi='/Users/pkb/work/MY_SAXO/TropFlux_update/flux_stat.txt' 
    45 ;openw,1,fi 
    46 ;printf,1, 'x     y      cor    bias     std ratio     rmsd' 
    47 ;------------------------------------------------------------------------------------------------------------------------ 
    4889erase 
    4990;; PLOTING THE MAPS 
    5091 
    51 fi='/Users/pkb/work/MY_SAXO/TropFlux_update/flux_stat.txt' 
     92fi = project_od_env + 'flux_stat.txt' 
    5293res=read_ascii(fi,data_start=1) 
    5394ff=res.field1 
     
    66107cstat=string(corr_t, bias_t, std_t, rmsd_t, format='(f4.2,3x,f7.2,3x,f4.2,3x,f5.2)') 
    67108 
    68 file='/Users/pkb/data/heat_budget/OAFLUX/mask_oaflux_30N30S.nc' 
     109file= project_id_env + 'mask_oaflux_30N30S.nc' 
    69110initncdf, file 
    70111domdef, 30,390,-30,30 
     
    97138endfor 
    98139 
    99 ;---------------------------------------------------------- 
    100140plt,msk,realcont=2,/nocont,/nofill,xminor=1,yminor=1,lct=64,bias_mi, bias_ma, int=bias_int,/noer, marge=marge1, $ 
    101141   title='2) Mean bias', subtitle='', small=[1,4,2],/rempl 
     
    122162  plots, x,y,psym=8,symsize=1.5,color=0 
    123163endfor 
    124 ;---------------------------------------------------------- 
    125164plt,msk,realcont=2,/nocont,/nofill,xminor=1,yminor=1,lct=64,rmsd_mi, rmsd_ma, int=rmsd_int,/noer, $ 
    126165   title='3) RMSD ', subtitle='', small=[1,4,3],/rempl, marge=marge1 
     
    146185  plots, x,y,psym=8,symsize=1.5,color=0 
    147186endfor 
    148 ;---------------------------------------------------------- 
    149187plt,msk,realcont=2,/nocont,/nofill,xminor=1,yminor=1,lct=64,std_mi, std_ma, int=std_int,/noer, $ 
    150188   title='4) STD ratio', subtitle='', small=[1,4,4],/rempl, marge=marge1 
     
    173211 
    174212erase 
    175 ;---------------------------------------------------------- 
    176  
    177213;; computing the pdf 
    178214 
     
    195231xyouts, 0, -150, cstat, charsize=1.2 
    196232 
    197 ;---------------------------------------------------------- 
    198233closeps 
    199234 
    200 fig='flux_evaluation_tpr_map.ps' 
    201 spawn, 'mv '+psdir+'idl.ps '+updatedir+fig 
    202 spawn, 'gv '+updatedir+fig 
    203 return 
    204235end 
    205 ;-------------------------------------------------------------------------- 
    206 function x_site_location, site 
    207     n1=strpos(site, 's') 
    208 if (n1 gt -1) then begin 
    209     ns=-1. 
    210     x=strmid(site, 0, n1) 
    211     x=float(x)*ns 
    212 endif else begin 
    213     n1=strpos(site, 'n') 
    214     x=strmid(site, 0, n1) 
    215     ny=1. 
    216     x=float(x)*ny 
    217 endelse 
    218 return, float(x) 
    219 end 
    220 ;-------------------------------------------------------------------------- 
    221 function y_site_location, site 
    222     n1=strpos(site, 'e') 
    223 if (n1 gt -1) then begin 
    224     n=strpos(site, 's') 
    225     if (n gt -1) then begin 
    226         y=strmid(site, n+1, n1-n-1) 
    227     endif else begin 
    228         n=strpos(site, 'n') 
    229         y=strmid(site, n+1, n1-n-1) 
    230     endelse 
    231  
    232 endif else begin 
    233     n1=strpos(site, 'w') 
    234     n=strpos(site, 's') 
    235     if (n gt -1) then begin 
    236         y=strmid(site, n+1, n1-n-1) 
    237         y=180+(180-float(y)) 
    238     endif else begin 
    239         n=strpos(site, 'n') 
    240         y=strmid(site, n+1, n1-n-1) 
    241         y=180+(180-float(y)) 
    242    endelse 
    243 endelse 
    244 return,float(y) 
    245 end 
    246  
    247 ;-------------------------------------------------------------------------- 
    248  
  • trunk/src/flux_evaluation_tpr_timeseries.pro

    r106 r107  
    1 ;------------------------------------------------------------ 
     1;+ 
     2; 
     3; .. _flux_evaluation_tpr_timeseries.pro: 
     4; 
     5; ================================== 
     6; flux_evaluation_tpr_timeseries.pro 
     7; ================================== 
     8; 
     9; DESCRIPTION 
     10; =========== 
     11; 
     12; SEE ALSO 
     13; ======== 
     14; 
     15; :ref:`project_profile.sh` 
     16; :ref:`project_init.pro` 
     17; :ref:`cm_project.pro` 
     18; 
     19; TODO 
     20; ==== 
     21; 
     22; make it work : missing READ_TPR_NETFLUX 
     23; 
     24; EXAMPLES 
     25; ======== 
     26; 
     27; :: 
     28; 
     29;   IDL> date1 = 20000101L 
     30;   IDL> date2 = 20091231L 
     31;   IDL> flux_evaluation_tpr_timeseries, date1, date2 
     32; 
     33; EVOLUTIONS 
     34; ========== 
     35; 
     36; $Id$ 
     37; 
     38; $URL$ 
     39; 
     40; - fplod 20111130T141341Z cratos (Linux) 
     41; 
     42;   * try to make it work on my account on cratos 
     43;   * remove x_site_location and  x_site_location because already exist 
     44; 
     45;- 
    246pro flux_evaluation_tpr_timeseries, $ 
    347;                    var,    $ ;;  flux variable (swr, lwr, lhf, shf) to calculate the statistics 
     
    650 
    751@common 
    8 ;------------------------------------------------------------ 
     52@cm_project 
    953reinitplt, /z,/invert 
    1054key_portrait = 0 
    11 openps, FILENAME = 'idl.ps' 
     55openps, FILENAME = project_od_env+'flux_evaluation_tpr_timeseries.ps' 
    1256;------------------------------------------------------------ 
    1357;; part to change 
     
    4589close,/all 
    4690 
    47 fi='/Users/pkb/work/MY_SAXO/TropFlux_update/flux_stat.txt' 
     91fi=project_id_env + 'flux_stat.txt' 
    4892openw,1,fi 
    4993 
     
    5296;; First, this program reads the full TropFlux data and later extract it at specific TPR locations 
    5397 
    54 file="/Volumes/PAYASAM/TropFlux/TropFlux/shf_tropflux_1d_1989_2010.nc" 
     98file = project_id_env + "shf_tropflux_1d_1989_2010.nc" 
    5599initncdf, file 
    56100var=-1*read_ncdf("shf", date1, date2, file=file,/nostr) 
     
    74118    if (y ge 0. and y le 30.) then y=y+360. 
    75119    dx=0.5 & dy=0.5 & box=[y-dy, y+dy, x-dx, x+dx] 
    76       
     120 
    77121    read_tpr_netflux, csite,date1,date2,nsmooth, $ 
    78122            sw,lw,sh,lh 
     
    97141           cstat=string(cor, bias, std, rmsd, format='(f4.2,3x,f7.2,3x,f4.2,3x,f5.2)') 
    98142           print, cstat 
    99   
     143 
    100144;;         PLOTTING THE TIME-SERIES 
    101145           array=[tpr, var_tpr] & mi=min(array,/nan) & ma=max(array,/nan) & int=(ma-mi)/3. 
     
    111155 
    112156close,/all 
    113 ;---------------------------------------------------------- 
    114157closeps 
    115158 
    116 fig='flux_evaluation_tpr_timeseries.ps' 
    117 spawn, 'mv '+psdir+'idl.ps '+updatedir+fig 
    118 spawn, 'gv '+updatedir+fig 
    119 return 
    120159end 
    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  
  • trunk/src/read_basic_var.pro

    r106 r107  
    1 ;------------------------------------------------------------------------------------------------- 
     1;+ 
     2; 
     3; .. _read_basic_var.pro: 
     4; 
     5; ================== 
     6; read_basic_var.pro 
     7; ================== 
     8; 
     9; DESCRIPTION 
     10; =========== 
     11; 
     12; SEE ALSO 
     13; ======== 
     14; 
     15; :ref:`project_profile.sh` 
     16; 
     17; called by :ref:`basic_variable_evaluation_tpr_timeseries.pro` 
     18; 
     19; TODO 
     20; ==== 
     21; 
     22; supprimer ./paper01/fig3/read_basic_var.pro 
     23; car ce module a l'air d'être le même 
     24; 
     25; make it work 
     26; 
     27; coding rules 
     28; 
     29; EVOLUTIONS 
     30; ========== 
     31; 
     32; $Id$ 
     33; 
     34; $URL$ 
     35; 
     36; - fplod 20111130T133857Z cratos (Linux) 
     37; 
     38;   * try to make it work on my account on cratos 
     39; 
     40;- 
    241pro read_basic_var, csite,date1,date2,nsmooth, $ 
    342                     at, rh, sst, wu, wv, ws 
    443 
    5 ; 
    6 ;------------------------------------------------------------------------------------------------- 
    744@common 
    8  
    9 ;dir='/Volumes/Iomega_HDD/work/flux_reconstruction/mooriing_all/' 
    10 dir="/Volumes/PAYASAM/mooriing_all/" 
    11 ; 
     45@cm_project 
     46 
    1247;; DEFINE THE OUTPUT TIME AXIS 
    1348; 
     
    2560 
    2661;;SHORTWAVE 
    27 fi=dir+'rad'+csite+'_dy.cdf' 
     62fi=project_id_env+'rad'+csite+'_dy.cdf' 
    2863f=file_test(fi) 
    2964sw=fltarr(jpt)+!values.f_nan 
     
    4580 
    4681;;LHF 
    47 fi=dir+'qlat'+csite+'_dy.cdf' 
     82fi=project_id_env+'qlat'+csite+'_dy.cdf' 
    4883f=file_test(fi) 
    4984lh=fltarr(jpt)+!values.f_nan 
     
    6297 
    6398;;POSITION 
    64 fi=dir+'pos'+csite+'_dy.cdf' 
     99fi=project_id_env+'pos'+csite+'_dy.cdf' 
    65100f=file_test(fi) 
    66101lat=fltarr(jpt)+!values.f_nan 
     
    76111    lon(tt0(ind))=lon0(ind) 
    77112  endif 
    78 endif  
     113endif 
    79114 
    80115 
    81116;;MET PARAMETERS 
    82 fi=dir+'met'+csite+'_dy.cdf' 
     117fi=project_id_env+'met'+csite+'_dy.cdf' 
    83118f=file_test(fi) 
    84119wu=fltarr(jpt)+!values.f_nan 
     
    123158ind_at=where(at_q ne 1 and at_q ne 2)   &  ind_ws=where(ws_q ne 1 and ws_q ne 2) 
    124159ind_rh=where(rh_q ne 1 and rh_q ne 2)   &  ind_sst=where(sst_q ne 1 and sst_q ne 2) 
    125 ind_lh=where(lh_q ne 1 and lh_q ne 2)  
    126   
     160ind_lh=where(lh_q ne 1 and lh_q ne 2) 
     161 
    127162ind=union(ind_at, union(ind_rh, union(ind_ws, union(ind_lh, ind_sst)))) 
    128163 
     
    136171;; Replace missing values by "NaN" 
    137172; 
    138 tsvars=['at','sw','rh','sst','wu','wv','ws','lat','lon']  
     173tsvars=['at','sw','rh','sst','wu','wv','ws','lat','lon'] 
    139174vars=[tsvars] 
    140175nn=n_elements(vars) 
     
    151186ws=smooth(ws,nsmooth,/nan) & sw=smooth(sw,nsmooth,/nan) 
    152187 
    153 ;------------------------------------------------------------------------------------------------- 
    154188end 
    155 ;------------------------------------------------------------------------------------------------- 
    156  
    157  
    158 ;------------------------------------------------------------------------------------------------- 
     189 
    159190function time_lec, fi 
    160191tt=ncdf_lec(fi,var='time') 
     
    168199return, tt 
    169200end 
    170  
    171 ;------------------------------------------------------------------------------------------------- 
Note: See TracChangeset for help on using the changeset viewer.