[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 | ; |
---|
| 11 | ; :file:`${PROJECT_OD}/erai_lwr_19890101_20091231_oafluxgrid.nc` have been |
---|
| 12 | ; produced by :ref:`interp_erai_lwr_1989_2009.pro`. |
---|
| 13 | ; |
---|
| 14 | ; Corrected lwr on OAFLUX grid is written in |
---|
| 15 | ; :file:`${PROJECT_OD}/TropFlux_lwr_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 lwr_correction_ncdf { |
---|
| 23 | ; graph [ |
---|
| 24 | ; rankdir="LR", |
---|
| 25 | ; ] |
---|
| 26 | ; |
---|
[72] | 27 | ; file_in [shape=ellipse,fontname=Courier,label="${PROJECT_OD}/erai_lwr_19890101_20091231_oafluxgrid.nc"]; |
---|
| 28 | ; file_out [shape=ellipse,fontname=Courier,label="${PROJECT_OD}/TropFlux_lwr_19890101_20091231.nc"]; |
---|
[9] | 29 | ; |
---|
| 30 | ; lwr_correction_ncdf [shape=box, |
---|
| 31 | ; fontname=Courier, |
---|
| 32 | ; color=blue, |
---|
| 33 | ; URL="http://forge.ipsl.jussieu.fr/tropflux/browser/trunk/src/lwr_correction_ncdf.pro", |
---|
[50] | 34 | ; label="${PROJECT}/src/lwr_correction_ncdf.pro"]; |
---|
[9] | 35 | ; |
---|
[72] | 36 | ; {file_in} -> {lwr_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_lwr_1989_2009.pro` |
---|
| 48 | ; |
---|
[20] | 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> lwr_correction_ncdf |
---|
| 62 | ; |
---|
| 63 | ; TODO |
---|
| 64 | ; ==== |
---|
| 65 | ; |
---|
| 66 | ; coding rules |
---|
| 67 | ; |
---|
[72] | 68 | ; lwr long name 'Air Temperature at 2m" : ??? |
---|
| 69 | ; |
---|
| 70 | ; 19890101 is not provided in ERA-Intermim file str : a possible workaround is |
---|
| 71 | ; to copy 19890102 |
---|
| 72 | ; dataset to 19890101 using nco before processing. see |
---|
| 73 | ; ref:`compute_erai_daily_region_2d.sh` |
---|
| 74 | ; |
---|
| 75 | ; here I (fp) replace hard coded date 19890102 by 19890101. must check |
---|
| 76 | ; consistency with this module and interp_erai_lwr_1989_2009.pro. |
---|
| 77 | ; |
---|
| 78 | ; KNOWN ISSUES |
---|
| 79 | ; ============ |
---|
| 80 | ; |
---|
| 81 | ; test of existence of fullfilename_in not very efficient because |
---|
| 82 | ; MUST_EXIST keyword of :func:`isafile <saxo:isafile>` not yet implemented |
---|
| 83 | ; |
---|
[6] | 84 | ; EVOLUTIONS |
---|
| 85 | ; ========== |
---|
| 86 | ; |
---|
[72] | 87 | ; - fplod 20110808T120234Z cratos (Linux) |
---|
| 88 | ; |
---|
| 89 | ; * usage of ${PROJECT_OD} |
---|
| 90 | ; * complete description |
---|
| 91 | ; * replace erai_lwr_19890102_20091231_oafluxgrid.nc by erai_lwr_19890101_20091231 |
---|
| 92 | ; * remove v1 in output filename |
---|
| 93 | ; |
---|
[9] | 94 | ; - fplod 20101215T113707Z aedon.locean-ipsl.upmc.fr (Darwin) |
---|
| 95 | ; |
---|
| 96 | ; * add graph in header |
---|
| 97 | ; |
---|
[6] | 98 | ; - fplod 20101214T093615Z aedon.locean-ipsl.upmc.fr (Darwin) |
---|
| 99 | ; |
---|
| 100 | ; * minimal header |
---|
| 101 | ; |
---|
| 102 | ; - pbk 2008 |
---|
| 103 | ; |
---|
| 104 | ; * creation |
---|
| 105 | ; |
---|
| 106 | ;- |
---|
[5] | 107 | pro lwr_correction_ncdf |
---|
[72] | 108 | ; |
---|
| 109 | @cm_4cal |
---|
| 110 | @cm_4data |
---|
| 111 | @cm_4mesh |
---|
| 112 | @cm_4data |
---|
| 113 | @cm_project |
---|
| 114 | ; |
---|
| 115 | ; test if ${PROJECT_OD} defined |
---|
| 116 | CASE project_od_env OF |
---|
| 117 | '' : BEGIN |
---|
| 118 | msg = 'eee : ${PROJECT_OD} is not defined' |
---|
| 119 | ras = report(msg) |
---|
| 120 | STOP |
---|
| 121 | END |
---|
| 122 | ELSE: BEGIN |
---|
| 123 | msg = 'iii : ${PROJECT_OD} is ' + project_od_env |
---|
| 124 | ras = report(msg) |
---|
| 125 | END |
---|
| 126 | ENDCASE |
---|
| 127 | ; |
---|
| 128 | ; check if output data will be possible |
---|
| 129 | iodirout = isadirectory(project_od_env) |
---|
| 130 | ; |
---|
| 131 | ; existence and protection for reading |
---|
| 132 | IF (FILE_TEST(iodirout, /DIRECTORY, /EXECUTABLE, /READ) EQ 0) THEN BEGIN |
---|
| 133 | msg = 'eee : the directory' + iodirout + ' is not accessible.' |
---|
| 134 | ras = report(msg) |
---|
| 135 | STOP |
---|
| 136 | ENDIF |
---|
| 137 | ; |
---|
| 138 | ; existence and protection for writing |
---|
| 139 | IF (FILE_TEST(iodirout, /DIRECTORY, /WRITE) EQ 0) THEN BEGIN |
---|
| 140 | msg = 'eee : the directory' + iodirout + ' was not found.' |
---|
| 141 | ras = report(msg) |
---|
| 142 | STOP |
---|
| 143 | ENDIF |
---|
| 144 | ; |
---|
[5] | 145 | da1=19880101 & da2=20091231 |
---|
[72] | 146 | ; |
---|
| 147 | ; build data filename |
---|
| 148 | filename='erai_lwr_19890101_20091231_oafluxgrid.nc' |
---|
| 149 | ; |
---|
| 150 | ; check if this file exists |
---|
| 151 | fullfilename = isafile(iodirout + filename, NEW=0, /MUST_EXIST) |
---|
| 152 | IF fullfilename[0] EQ '' THEN BEGIN |
---|
| 153 | msg = 'eee : the file ' + fullfilename + ' was not found.' |
---|
| 154 | ras = report(msg) |
---|
| 155 | STOP |
---|
| 156 | ENDIF |
---|
| 157 | ; |
---|
| 158 | ; build output filename |
---|
| 159 | filename_out = 'TropFlux_lwr_19890101_20091231.nc' |
---|
| 160 | fullfilename_out = iodirout + filename_out |
---|
| 161 | ; in order to avoid unexpected overwritten |
---|
| 162 | IF (FILE_TEST(fullfilename_out) EQ 1) THEN BEGIN |
---|
| 163 | msg = 'eee : the file ' + fullfilename_out + ' already exists.' |
---|
| 164 | ras = report(msg) |
---|
| 165 | STOP |
---|
| 166 | ENDIF |
---|
| 167 | ; |
---|
| 168 | initncdf, fullfilename |
---|
| 169 | lwr=read_ncdf('lwr',da1,da2,file=fullfilename,/nostr) |
---|
[5] | 170 | help, lwr |
---|
[72] | 171 | ; |
---|
[5] | 172 | lwr_mean=grossemoyenne(lwr,'t',/nan) |
---|
| 173 | help,lwr_mean |
---|
| 174 | |
---|
| 175 | tt=time & jpt=n_elements(time) |
---|
| 176 | caldat, time,mon,day,yea |
---|
| 177 | lwr_m=lwr*0. |
---|
| 178 | |
---|
| 179 | for jt=0,jpt-1 do begin |
---|
| 180 | jtt=(time(jt)-julday(1,1,yea(jt))) < 364 |
---|
| 181 | t=reform(lwr_mean(*,*)) |
---|
| 182 | lwr_m(*,*,jt)=t |
---|
| 183 | endfor |
---|
| 184 | help, lwr_m |
---|
| 185 | |
---|
| 186 | lwr_ano=lwr-lwr_m |
---|
| 187 | |
---|
| 188 | ;; correction for mean based on scatter |
---|
| 189 | lwr_m=lwr_m+4.61667 |
---|
| 190 | |
---|
| 191 | help, lwr_ano |
---|
| 192 | |
---|
| 193 | ;; applying the correction for varyability based on the scatter |
---|
| 194 | lwr_ano=lwr_ano*(1/0.760667) |
---|
| 195 | |
---|
| 196 | ;; applying the correction for varyability based on the scatter |
---|
| 197 | |
---|
| 198 | lwr_new=lwr_m+lwr_ano |
---|
| 199 | help, lwr_new |
---|
| 200 | |
---|
| 201 | ;writing field |
---|
| 202 | lat=reform(gphit(0,0:jpj-1)) |
---|
| 203 | lon=reform(glamt(0:jpi-1,0)) |
---|
| 204 | time=timegen(7669, units='days', start=julday(1,2,1989)) & jpt=n_elements(time) |
---|
| 205 | |
---|
| 206 | cda0=string(jul2date(time(0)),format='(i8.8)') |
---|
| 207 | cda1=string(jul2date(time(jpt-1)),format='(i8.8)') |
---|
| 208 | |
---|
| 209 | time=time-julday(1,1,1950) & jpt=n_elements(time) |
---|
| 210 | |
---|
[72] | 211 | ncfile='!' + fullfilename_out |
---|
[5] | 212 | lon_attr={units:'degrees_east',long_name:'Longitude'} |
---|
| 213 | lat_attr={units:'degrees_north',long_name:'Latitude'} |
---|
| 214 | time_attr={units:'days since 1950-01-01 00:00:00',long_name:'Time axis',time_origin:'1950-JAN-01 00:00:00'} |
---|
| 215 | lwr_attr={units:'degK',missing_value:1.e20,long_name:'Air Temperature at 2m',short_name:'lwr',axis:'TYX'} |
---|
| 216 | globattr={source:'Basic data obtained from ERAI. Mean correction for bias and correction for variability are applied',timerange:cda0+' - '+cda1} |
---|
| 217 | |
---|
| 218 | ncfields = 'lwr[longitude,latitude,time]=lwr_new:lwr_attr; ' $ |
---|
| 219 | + 'longitude[]=lon:lon_attr; ' $ |
---|
| 220 | + 'latitude[]=lat:lat_attr; ' $ |
---|
| 221 | + 'time[*time]=time:time_attr ' $ |
---|
| 222 | + ' @ globattr' |
---|
| 223 | |
---|
| 224 | @ncdf_quickwrite |
---|
| 225 | |
---|
| 226 | end |
---|