[6] | 1 | ;+ |
---|
| 2 | ; |
---|
| 3 | ; .. _ws_correction_ncdf.pro: |
---|
| 4 | ; |
---|
| 5 | ; ====================== |
---|
| 6 | ; ws_correction_ncdf.pro |
---|
| 7 | ; ====================== |
---|
| 8 | ; |
---|
[72] | 9 | ; Correction of ws on OAFLUX grid |
---|
| 10 | ; |
---|
| 11 | ; :file:`${PROJECT_OD}/erai_ws_19890101_20091231_oafluxgrid.nc` have been |
---|
| 12 | ; produced by :ref:`interp_erai_ws_1989_2009.pro`. |
---|
| 13 | ; |
---|
| 14 | ; Corrected ws on OAFLUX grid is written in |
---|
| 15 | ; :file:`${PROJECT_OD}/TropFlux_ws_19890101_20091231.nc` |
---|
| 16 | ; if this file not already exists. |
---|
| 17 | ; |
---|
| 18 | ; This file will be used by :ref:`TropFlux_19890101_20091231.pro`. |
---|
| 19 | ; |
---|
[9] | 20 | ; .. graphviz:: |
---|
| 21 | ; |
---|
| 22 | ; digraph ws_correction_ncdf { |
---|
| 23 | ; graph [ |
---|
| 24 | ; rankdir="LR", |
---|
| 25 | ; ] |
---|
[72] | 26 | ; |
---|
| 27 | ; file_in [shape=ellipse,fontname=Courier,label="${PROJECT_OD}/erai_ws_19890101_20091231_oafluxgrid.nc"]; |
---|
| 28 | ; file_out [shape=ellipse,fontname=Courier,label="${PROJECT_OD}/TropFlux_ws_19890101_20091231.nc"]; |
---|
| 29 | ; |
---|
[9] | 30 | ; ws_correction_ncdf [shape=box, |
---|
| 31 | ; fontname=Courier, |
---|
| 32 | ; color=blue, |
---|
| 33 | ; URL="http://forge.ipsl.jussieu.fr/tropflux/browser/trunk/src/ws_correction_ncdf.pro", |
---|
[50] | 34 | ; label="${PROJECT}/src/ws_correction_ncdf.pro"]; |
---|
[9] | 35 | ; |
---|
[72] | 36 | ; {file_in} -> {ws_correction_ncdf} -> {file_out} |
---|
[9] | 37 | ; |
---|
| 38 | ; } |
---|
| 39 | ; |
---|
[6] | 40 | ; SEE ALSO |
---|
| 41 | ; ======== |
---|
| 42 | ; |
---|
[72] | 43 | ; :ref:`project_profile.sh` |
---|
| 44 | ; |
---|
| 45 | ; :ref:`mooring_corrections` |
---|
| 46 | ; |
---|
| 47 | ; :ref:`interp_erai_vs_1989_2009.pro` |
---|
| 48 | ; |
---|
| 49 | ; :func:`initncdf <saxo:initncdf>` |
---|
| 50 | ; :func:`read_ncdf <saxo:read_ncdf>` |
---|
| 51 | ; :func:`grossemoyenne <saxo:grossemoyenne>` |
---|
| 52 | ; :func:`julday <saxo:julday>` |
---|
| 53 | ; :func:`caldat <saxo:caldat>` |
---|
| 54 | ; :func:`ncdf_quickwrite <saxo:ncdf_quickwrite>` |
---|
| 55 | ; |
---|
[6] | 56 | ; EXAMPLES |
---|
| 57 | ; ======== |
---|
| 58 | ; |
---|
| 59 | ; :: |
---|
| 60 | ; |
---|
| 61 | ; IDL> ws_correction_ncdf |
---|
| 62 | ; |
---|
| 63 | ; TODO |
---|
| 64 | ; ==== |
---|
| 65 | ; |
---|
| 66 | ; coding rules |
---|
| 67 | ; |
---|
[72] | 68 | ; hard coded correction |
---|
| 69 | ; |
---|
| 70 | ; KNOWN ISSUES |
---|
| 71 | ; ============ |
---|
| 72 | ; |
---|
| 73 | ; test of existence of fullfilename_in not very efficient because |
---|
| 74 | ; MUST_EXIST keyword of :func:`isafile <saxo:isafile>` not yet implemented |
---|
| 75 | ; |
---|
[6] | 76 | ; EVOLUTIONS |
---|
| 77 | ; ========== |
---|
| 78 | ; |
---|
[72] | 79 | ; - fplod 20110808T131954Z aedon.locean-ipsl.upmc.fr (Darwin) |
---|
| 80 | ; |
---|
| 81 | ; * usage of ${PROJECT_OD} |
---|
| 82 | ; * complete description |
---|
| 83 | ; * remove v20 in output filename |
---|
| 84 | |
---|
[9] | 85 | ; - fplod 20101215T115916Z aedon.locean-ipsl.upmc.fr (Darwin) |
---|
| 86 | ; |
---|
| 87 | ; * add graph in header |
---|
| 88 | ; |
---|
[6] | 89 | ; - fplod 20101214T093615Z aedon.locean-ipsl.upmc.fr (Darwin) |
---|
| 90 | ; |
---|
| 91 | ; * minimal header |
---|
| 92 | ; |
---|
| 93 | ; - pbk 2008 |
---|
| 94 | ; |
---|
| 95 | ; * creation |
---|
| 96 | ; |
---|
| 97 | ;- |
---|
[5] | 98 | pro ws_correction_ncdf |
---|
[72] | 99 | ; |
---|
| 100 | @cm_4cal |
---|
| 101 | @cm_4data |
---|
| 102 | @cm_4mesh |
---|
| 103 | @cm_4data |
---|
| 104 | @cm_project |
---|
| 105 | ; |
---|
| 106 | ; test if ${PROJECT_OD} defined |
---|
| 107 | CASE project_od_env OF |
---|
| 108 | '' : BEGIN |
---|
| 109 | msg = 'eee : ${PROJECT_OD} is not defined' |
---|
| 110 | ras = report(msg) |
---|
| 111 | STOP |
---|
| 112 | END |
---|
| 113 | ELSE: BEGIN |
---|
| 114 | msg = 'iii : ${PROJECT_OD} is ' + project_od_env |
---|
| 115 | ras = report(msg) |
---|
| 116 | END |
---|
| 117 | ENDCASE |
---|
| 118 | ; |
---|
| 119 | ; check if output data will be possible |
---|
| 120 | iodirout = isadirectory(project_od_env) |
---|
| 121 | ; |
---|
| 122 | ; existence and protection for reading |
---|
| 123 | IF (FILE_TEST(iodirout, /DIRECTORY, /EXECUTABLE, /READ) EQ 0) THEN BEGIN |
---|
| 124 | msg = 'eee : the directory' + iodirout + ' is not accessible.' |
---|
| 125 | ras = report(msg) |
---|
| 126 | STOP |
---|
| 127 | ENDIF |
---|
| 128 | ; |
---|
| 129 | ; existence and protection for writing |
---|
| 130 | IF (FILE_TEST(iodirout, /DIRECTORY, /WRITE) EQ 0) THEN BEGIN |
---|
| 131 | msg = 'eee : the directory' + iodirout + ' was not found.' |
---|
| 132 | ras = report(msg) |
---|
| 133 | STOP |
---|
| 134 | ENDIF |
---|
| 135 | ; |
---|
[5] | 136 | da1=19880101 & da2=20101231 |
---|
[72] | 137 | ; |
---|
| 138 | ; build data filename |
---|
| 139 | filename='erai_ws_19890101_20091231_oafluxgrid.nc' |
---|
| 140 | ; |
---|
| 141 | ; check if this file exists |
---|
| 142 | fullfilename = isafile(iodirout + filename, NEW=0, /MUST_EXIST) |
---|
| 143 | IF fullfilename[0] EQ '' THEN BEGIN |
---|
| 144 | msg = 'eee : the file ' + fullfilename + ' was not found.' |
---|
| 145 | ras = report(msg) |
---|
| 146 | STOP |
---|
| 147 | ENDIF |
---|
| 148 | ; |
---|
| 149 | ; build output filename |
---|
| 150 | filename_out = 'TropFlux_ws_19890101_20091231.nc' |
---|
| 151 | fullfilename_out = iodirout + filename_out |
---|
| 152 | ; in order to avoid unexpected overwritten |
---|
| 153 | IF (FILE_TEST(fullfilename_out) EQ 1) THEN BEGIN |
---|
| 154 | msg = 'eee : the file ' + fullfilename_out + ' already exists.' |
---|
| 155 | ras = report(msg) |
---|
| 156 | STOP |
---|
| 157 | ENDIF |
---|
| 158 | ; |
---|
| 159 | initncdf, fullfilename |
---|
| 160 | u=read_ncdf('u10',da1,da2,file=fullfilename,/nostr) |
---|
| 161 | v=read_ncdf('v10',da1,da2,file=fullfilename,/nostr) |
---|
[5] | 162 | w=sqrt(u*u+v*v) |
---|
| 163 | |
---|
| 164 | help, w |
---|
| 165 | |
---|
| 166 | w_mean=grossemoyenne(w,'t',/nan) |
---|
| 167 | help, w_mean |
---|
| 168 | |
---|
| 169 | tt=time & jpt=n_elements(time) |
---|
| 170 | caldat, time,mon,day,yea |
---|
| 171 | w_m=w*0. |
---|
| 172 | |
---|
| 173 | for jt=0,jpt-1 do begin |
---|
| 174 | jtt=(time(jt)-julday(1,1,yea(jt))) < 364 |
---|
| 175 | q=reform(w_mean(*,*)) |
---|
| 176 | w_m(*,*,jt)=q |
---|
| 177 | endfor |
---|
| 178 | help, w_m |
---|
| 179 | |
---|
| 180 | w_ano=w-w_m |
---|
| 181 | |
---|
| 182 | ;; correction for mean based on scatter |
---|
| 183 | ;w_m=w_m+0.282667 ;; (2000-2008) |
---|
| 184 | w_m=w_m+0.276739 ;; (2000-2009) |
---|
| 185 | |
---|
| 186 | help, w_ano |
---|
| 187 | |
---|
| 188 | ;; applying the correction for varyability based on the scatter |
---|
| 189 | ;w_ano=w_ano*(1/0.897667) ;; (2000-2008) |
---|
| 190 | w_ano=w_ano*(1/0.903587) ;; (2000-2009) |
---|
| 191 | |
---|
| 192 | w_new=w_m+w_ano |
---|
| 193 | help, w_new |
---|
| 194 | |
---|
| 195 | ;writing field |
---|
| 196 | lat=reform(gphit(0,0:jpj-1)) |
---|
| 197 | lon=reform(glamt(0:jpi-1,0)) |
---|
| 198 | time=timegen(7670, units='days', start=julday(1,1,1989,0)) & jpt=n_elements(time) |
---|
| 199 | |
---|
| 200 | cda0=string(jul2date(time(0)),format='(i8.8)') |
---|
| 201 | cda1=string(jul2date(time(jpt-1)),format='(i8.8)') |
---|
| 202 | |
---|
| 203 | time=time-julday(1,1,1950) & jpt=n_elements(time) |
---|
| 204 | |
---|
[72] | 205 | ncfile='!' + fullfilename_out |
---|
[5] | 206 | lon_attr={units:'degrees_east',long_name:'Longitude'} |
---|
| 207 | lat_attr={units:'degrees_north',long_name:'Latitude'} |
---|
| 208 | time_attr={units:'days since 1950-01-01 00:00:00',long_name:'Time axis',time_origin:'1950-JAN-01 00:00:00'} |
---|
| 209 | w_attr={units:'m/s',missing_value:1.e20,long_name:'mean wind speed',short_name:'w',axis:'TYX'} |
---|
| 210 | globattr={source:'Basic data obtained from ERAI. Bias and variability correction are applied',timerange:cda0+' - '+cda1} |
---|
| 211 | |
---|
| 212 | ncfields = 'ws[longitude,latitude,time]=w_new:w_attr; ' $ |
---|
| 213 | + 'longitude[]=lon:lon_attr; ' $ |
---|
| 214 | + 'latitude[]=lat:lat_attr; ' $ |
---|
| 215 | + 'time[*time]=time:time_attr ' $ |
---|
| 216 | + ' @ globattr' |
---|
| 217 | |
---|
| 218 | @ncdf_quickwrite |
---|
| 219 | |
---|
| 220 | end |
---|