[6] | 1 | ;+ |
---|
| 2 | ; |
---|
| 3 | ; .. _lwr_correction_ncdf.pro: |
---|
| 4 | ; |
---|
| 5 | ; ======================= |
---|
| 6 | ; lwr_correction_ncdf.pro |
---|
| 7 | ; ======================= |
---|
| 8 | ; |
---|
[72] | 9 | ; Correction of lwr on OAFLUX grid |
---|
| 10 | ; |
---|
[92] | 11 | ; :file:`${PROJECT_OD}/erai_lwr_19890101_20091231_oafluxgrid.nc` |
---|
[88] | 12 | ; containing |
---|
| 13 | ; ++ |
---|
[92] | 14 | ; have been produced by |
---|
[167] | 15 | ; :func:`interp_erai_lwr` and :ref:`add_19890101.sh`. |
---|
[72] | 16 | ; |
---|
[92] | 17 | ; Corrected lwr on OAFLUX grid |
---|
[88] | 18 | ; is written in |
---|
[72] | 19 | ; :file:`${PROJECT_OD}/TropFlux_lwr_19890101_20091231.nc` |
---|
| 20 | ; if this file not already exists. |
---|
| 21 | ; |
---|
[92] | 22 | ; This output file |
---|
| 23 | ; :file:`${PROJECT_OD}/TropFlux_lwr_19890101_20091231.nc` |
---|
[100] | 24 | ; will be used by |
---|
| 25 | ; :ref:`TropFlux_19890101_20091231.pro`. |
---|
[72] | 26 | ; |
---|
[92] | 27 | ; .. only:: man |
---|
| 28 | ; |
---|
| 29 | ; Figure is visible on PDF and HTML documents only. |
---|
| 30 | ; |
---|
| 31 | ; .. only:: html or latex |
---|
| 32 | ; |
---|
[9] | 33 | ; .. graphviz:: |
---|
| 34 | ; |
---|
| 35 | ; digraph lwr_correction_ncdf { |
---|
| 36 | ; |
---|
[72] | 37 | ; file_in [shape=ellipse,fontname=Courier,label="${PROJECT_OD}/erai_lwr_19890101_20091231_oafluxgrid.nc"]; |
---|
| 38 | ; file_out [shape=ellipse,fontname=Courier,label="${PROJECT_OD}/TropFlux_lwr_19890101_20091231.nc"]; |
---|
[9] | 39 | ; |
---|
| 40 | ; lwr_correction_ncdf [shape=box, |
---|
| 41 | ; fontname=Courier, |
---|
| 42 | ; color=blue, |
---|
| 43 | ; URL="http://forge.ipsl.jussieu.fr/tropflux/browser/trunk/src/lwr_correction_ncdf.pro", |
---|
[50] | 44 | ; label="${PROJECT}/src/lwr_correction_ncdf.pro"]; |
---|
[9] | 45 | ; |
---|
[72] | 46 | ; {file_in} -> {lwr_correction_ncdf} -> {file_out} |
---|
[9] | 47 | ; |
---|
| 48 | ; } |
---|
| 49 | ; |
---|
[6] | 50 | ; SEE ALSO |
---|
| 51 | ; ======== |
---|
| 52 | ; |
---|
[72] | 53 | ; :ref:`project_profile.sh` |
---|
| 54 | ; |
---|
| 55 | ; :ref:`mooring_corrections` |
---|
| 56 | ; |
---|
[167] | 57 | ; :func:`interp_erai_lwr` and :ref:`add_19890101.sh` |
---|
[72] | 58 | ; |
---|
[20] | 59 | ; :func:`initncdf <saxo:initncdf>` |
---|
| 60 | ; :func:`read_ncdf <saxo:read_ncdf>` |
---|
| 61 | ; :func:`grossemoyenne <saxo:grossemoyenne>` |
---|
| 62 | ; :func:`julday <saxo:julday>` |
---|
| 63 | ; :func:`caldat <saxo:caldat>` |
---|
| 64 | ; :func:`ncdf_quickwrite <saxo:ncdf_quickwrite>` |
---|
| 65 | ; |
---|
[6] | 66 | ; EXAMPLES |
---|
| 67 | ; ======== |
---|
| 68 | ; |
---|
| 69 | ; :: |
---|
| 70 | ; |
---|
| 71 | ; IDL> lwr_correction_ncdf |
---|
| 72 | ; |
---|
| 73 | ; TODO |
---|
| 74 | ; ==== |
---|
| 75 | ; |
---|
| 76 | ; coding rules |
---|
| 77 | ; |
---|
[72] | 78 | ; lwr long name 'Air Temperature at 2m" : ??? |
---|
| 79 | ; |
---|
[88] | 80 | ; remove hard doded time |
---|
[72] | 81 | ; |
---|
[88] | 82 | ; add_19890101.sh sould not be the previous step in a near future |
---|
[80] | 83 | ; |
---|
[72] | 84 | ; KNOWN ISSUES |
---|
| 85 | ; ============ |
---|
| 86 | ; |
---|
| 87 | ; test of existence of fullfilename_in not very efficient because |
---|
| 88 | ; MUST_EXIST keyword of :func:`isafile <saxo:isafile>` not yet implemented |
---|
| 89 | ; |
---|
[6] | 90 | ; EVOLUTIONS |
---|
| 91 | ; ========== |
---|
| 92 | ; |
---|
[90] | 93 | ; $Id: lwr_correction_ncdf.pro 88 2011-08-19 15:40:14Z pinsard $ |
---|
[85] | 94 | ; |
---|
| 95 | ; $URL$ |
---|
| 96 | ; |
---|
[88] | 97 | ; - fplod 20110819T105050Z aedon.locean-ipsl.upmc.fr (Darwin) |
---|
| 98 | ; |
---|
[167] | 99 | ; * replace previous step interp_erai_lwr_1989_2009.pro |
---|
[88] | 100 | ; by :ref:`add_19890101.sh` |
---|
| 101 | ; * change 19890102 to 19890101 |
---|
| 102 | ; |
---|
[72] | 103 | ; - fplod 20110808T120234Z cratos (Linux) |
---|
| 104 | ; |
---|
| 105 | ; * usage of ${PROJECT_OD} |
---|
| 106 | ; * complete description |
---|
| 107 | ; * replace erai_lwr_19890102_20091231_oafluxgrid.nc by erai_lwr_19890101_20091231 |
---|
| 108 | ; * remove v1 in output filename |
---|
| 109 | ; |
---|
[9] | 110 | ; - fplod 20101215T113707Z aedon.locean-ipsl.upmc.fr (Darwin) |
---|
| 111 | ; |
---|
| 112 | ; * add graph in header |
---|
| 113 | ; |
---|
[6] | 114 | ; - fplod 20101214T093615Z aedon.locean-ipsl.upmc.fr (Darwin) |
---|
| 115 | ; |
---|
| 116 | ; * minimal header |
---|
| 117 | ; |
---|
| 118 | ; - pbk 2008 |
---|
| 119 | ; |
---|
| 120 | ; * creation |
---|
| 121 | ; |
---|
| 122 | ;- |
---|
[5] | 123 | pro lwr_correction_ncdf |
---|
[72] | 124 | ; |
---|
| 125 | @cm_4cal |
---|
| 126 | @cm_4data |
---|
| 127 | @cm_4mesh |
---|
| 128 | @cm_4data |
---|
| 129 | @cm_project |
---|
| 130 | ; |
---|
| 131 | ; test if ${PROJECT_OD} defined |
---|
| 132 | CASE project_od_env OF |
---|
| 133 | '' : BEGIN |
---|
| 134 | msg = 'eee : ${PROJECT_OD} is not defined' |
---|
| 135 | ras = report(msg) |
---|
| 136 | STOP |
---|
| 137 | END |
---|
| 138 | ELSE: BEGIN |
---|
| 139 | msg = 'iii : ${PROJECT_OD} is ' + project_od_env |
---|
| 140 | ras = report(msg) |
---|
| 141 | END |
---|
| 142 | ENDCASE |
---|
| 143 | ; |
---|
| 144 | ; check if output data will be possible |
---|
| 145 | iodirout = isadirectory(project_od_env) |
---|
| 146 | ; |
---|
| 147 | ; existence and protection for reading |
---|
| 148 | IF (FILE_TEST(iodirout, /DIRECTORY, /EXECUTABLE, /READ) EQ 0) THEN BEGIN |
---|
| 149 | msg = 'eee : the directory' + iodirout + ' is not accessible.' |
---|
| 150 | ras = report(msg) |
---|
| 151 | STOP |
---|
| 152 | ENDIF |
---|
| 153 | ; |
---|
| 154 | ; existence and protection for writing |
---|
| 155 | IF (FILE_TEST(iodirout, /DIRECTORY, /WRITE) EQ 0) THEN BEGIN |
---|
| 156 | msg = 'eee : the directory' + iodirout + ' was not found.' |
---|
| 157 | ras = report(msg) |
---|
| 158 | STOP |
---|
| 159 | ENDIF |
---|
| 160 | ; |
---|
[97] | 161 | da1=19880101 |
---|
[94] | 162 | da2=20091231 |
---|
[72] | 163 | ; |
---|
| 164 | ; build data filename |
---|
| 165 | filename='erai_lwr_19890101_20091231_oafluxgrid.nc' |
---|
| 166 | ; |
---|
| 167 | ; check if this file exists |
---|
[92] | 168 | msg='iii : looking for ' + filename |
---|
| 169 | ras = report(msg) |
---|
[72] | 170 | fullfilename = isafile(iodirout + filename, NEW=0, /MUST_EXIST) |
---|
| 171 | IF fullfilename[0] EQ '' THEN BEGIN |
---|
| 172 | msg = 'eee : the file ' + fullfilename + ' was not found.' |
---|
| 173 | ras = report(msg) |
---|
| 174 | STOP |
---|
| 175 | ENDIF |
---|
| 176 | ; |
---|
| 177 | ; build output filename |
---|
| 178 | filename_out = 'TropFlux_lwr_19890101_20091231.nc' |
---|
| 179 | fullfilename_out = iodirout + filename_out |
---|
| 180 | ; in order to avoid unexpected overwritten |
---|
| 181 | IF (FILE_TEST(fullfilename_out) EQ 1) THEN BEGIN |
---|
| 182 | msg = 'eee : the file ' + fullfilename_out + ' already exists.' |
---|
| 183 | ras = report(msg) |
---|
| 184 | STOP |
---|
| 185 | ENDIF |
---|
| 186 | ; |
---|
| 187 | initncdf, fullfilename |
---|
| 188 | lwr=read_ncdf('lwr',da1,da2,file=fullfilename,/nostr) |
---|
[5] | 189 | help, lwr |
---|
[72] | 190 | ; |
---|
[5] | 191 | lwr_mean=grossemoyenne(lwr,'t',/nan) |
---|
| 192 | help,lwr_mean |
---|
[97] | 193 | ; |
---|
[94] | 194 | jpt=n_elements(time) |
---|
[5] | 195 | caldat, time,mon,day,yea |
---|
| 196 | lwr_m=lwr*0. |
---|
[97] | 197 | ; |
---|
[5] | 198 | for jt=0,jpt-1 do begin |
---|
| 199 | jtt=(time(jt)-julday(1,1,yea(jt))) < 364 |
---|
| 200 | t=reform(lwr_mean(*,*)) |
---|
| 201 | lwr_m(*,*,jt)=t |
---|
| 202 | endfor |
---|
| 203 | help, lwr_m |
---|
[97] | 204 | ; |
---|
[5] | 205 | lwr_ano=lwr-lwr_m |
---|
[97] | 206 | ; |
---|
| 207 | ; correction for mean based on scatter |
---|
[5] | 208 | lwr_m=lwr_m+4.61667 |
---|
[97] | 209 | ; |
---|
[5] | 210 | help, lwr_ano |
---|
[97] | 211 | ; |
---|
| 212 | ; applying the correction for varyability based on the scatter |
---|
[5] | 213 | lwr_ano=lwr_ano*(1/0.760667) |
---|
[97] | 214 | ; |
---|
| 215 | ; applying the correction for varyability based on the scatter |
---|
| 216 | ; |
---|
[5] | 217 | lwr_new=lwr_m+lwr_ano |
---|
| 218 | help, lwr_new |
---|
[97] | 219 | ; |
---|
[5] | 220 | ;writing field |
---|
| 221 | lat=reform(gphit(0,0:jpj-1)) |
---|
| 222 | lon=reform(glamt(0:jpi-1,0)) |
---|
[100] | 223 | time=timegen(7670, start=julday(1,1,1989,0), units='days') |
---|
[94] | 224 | jpt=n_elements(time) |
---|
[97] | 225 | ; |
---|
[5] | 226 | cda0=string(jul2date(time(0)),format='(i8.8)') |
---|
| 227 | cda1=string(jul2date(time(jpt-1)),format='(i8.8)') |
---|
[97] | 228 | ; |
---|
| 229 | time=time-julday(1,1,1950) |
---|
[94] | 230 | jpt=n_elements(time) |
---|
[97] | 231 | ; |
---|
[72] | 232 | ncfile='!' + fullfilename_out |
---|
[5] | 233 | lon_attr={units:'degrees_east',long_name:'Longitude'} |
---|
| 234 | lat_attr={units:'degrees_north',long_name:'Latitude'} |
---|
| 235 | time_attr={units:'days since 1950-01-01 00:00:00',long_name:'Time axis',time_origin:'1950-JAN-01 00:00:00'} |
---|
[100] | 236 | globattr={source:'Basic data obtained from ERAI. Mean correction for bias and correction for variability are applied',timerange:cda0+' - '+cda1} |
---|
[5] | 237 | lwr_attr={units:'degK',missing_value:1.e20,long_name:'Air Temperature at 2m',short_name:'lwr',axis:'TYX'} |
---|
[97] | 238 | ; |
---|
[5] | 239 | ncfields = 'lwr[longitude,latitude,time]=lwr_new:lwr_attr; ' $ |
---|
| 240 | + 'longitude[]=lon:lon_attr; ' $ |
---|
| 241 | + 'latitude[]=lat:lat_attr; ' $ |
---|
| 242 | + 'time[*time]=time:time_attr ' $ |
---|
| 243 | + ' @ globattr' |
---|
[97] | 244 | ; |
---|
[5] | 245 | @ncdf_quickwrite |
---|
[97] | 246 | ; |
---|
[5] | 247 | end |
---|