[6] | 1 | ;+ |
---|
| 2 | ; |
---|
| 3 | ; .. _TropFlux_swr_BLND_19890101_20091231.pro: |
---|
| 4 | ; |
---|
| 5 | ; ======================================= |
---|
| 6 | ; TropFlux_swr_BLND_19890101_20091231.pro |
---|
| 7 | ; ======================================= |
---|
| 8 | ; |
---|
[81] | 9 | ; DESCRIPTION |
---|
| 10 | ; =========== |
---|
| 11 | ; |
---|
[74] | 12 | ; :file:`${PROJECT_OD}/TropFlux_swr_19890101_20071231_DT.nc` |
---|
| 13 | ; containing ++ |
---|
[85] | 14 | ; has been produced by |
---|
| 15 | ; :ref:`TropFlux_swr_DT_19890101_20071231.pro`. |
---|
[74] | 16 | ; |
---|
| 17 | ; :file:`${PROJECT_OD}/TropFlux_swr_19890101_20091231_NRT.nc` |
---|
| 18 | ; containing ++ |
---|
[85] | 19 | ; has been produced by |
---|
| 20 | ; :ref:`TropFlux_swr_NRT_19890101_20091231.pro`. |
---|
[74] | 21 | ; |
---|
| 22 | ; :file:`${PROJECT_OD}/TropFlux_gustiness_19890101_20091231.nc` containing ++ |
---|
[85] | 23 | ; has been produced by |
---|
| 24 | ; :ref:` cronin_gustiness_ncdf.pro`. |
---|
[74] | 25 | ; |
---|
| 26 | ; ++ are written |
---|
| 27 | ; in :file:`${PROJECT_OD}/TropFlux_swr_19890101_20091231_BLND.nc` |
---|
| 28 | ; if this file not already exists. |
---|
| 29 | ; |
---|
[88] | 30 | ; This file will be used by :ref:`TropFlux_NRT_ncdf.pro`. |
---|
[74] | 31 | ; |
---|
[8] | 32 | ; .. graphviz:: |
---|
| 33 | ; |
---|
[74] | 34 | ; digraph tropflux_swr_blnd_19890101_20091231 { |
---|
[8] | 35 | ; |
---|
[74] | 36 | ; file_dt [shape=ellipse,fontname=Courier,label="${PROJECT_OD}/TropFlux_swr_19890101_20071231_DT.nc"]; |
---|
| 37 | ; file_nrt [shape=ellipse,fontname=Courier,label="${PROJECT_OD}/TropFlux_swr_19890101_20091231_NRT.nc"]; |
---|
| 38 | ; file_gustiness [shape=ellipse,fontname=Courier,label="${PROJECT_OD}/TropFlux_gustiness_19890101_20091231.nc"]; |
---|
| 39 | ; file_out [shape=ellipse,fontname=Courier,label="${PROJECT_OD}/TropFlux_swr_19890101_20091231_blnd.nc"]; |
---|
[8] | 40 | ; |
---|
[74] | 41 | ; tropflux_swr_blnd_19890101_20091231 [shape=box, |
---|
[8] | 42 | ; fontname=Courier, |
---|
| 43 | ; color=blue, |
---|
| 44 | ; URL="http://forge.ipsl.jussieu.fr/tropflux/browser/trunk/src/TropFlux_swr_BLND_19890101_20091231.pro", |
---|
[50] | 45 | ; label="${PROJECT}/src/TropFlux_swr_BLND_19890101_20091231.pro"]; |
---|
[8] | 46 | ; |
---|
[74] | 47 | ; {file_dt file_nrt file_gustiness} -> {tropflux_swr_blnd_19890101_20091231} -> {file_out} |
---|
| 48 | ; |
---|
[8] | 49 | ; } |
---|
| 50 | ; |
---|
[6] | 51 | ; SEE ALSO |
---|
| 52 | ; ======== |
---|
| 53 | ; |
---|
[81] | 54 | ; :ref:`project_profile.sh` |
---|
| 55 | ; |
---|
| 56 | ; :ref:`mooring_corrections` |
---|
| 57 | ; |
---|
| 58 | ; :ref:`data_in_swr` |
---|
| 59 | ; |
---|
[20] | 60 | ; :func:`initncdf <saxo:initncdf>` |
---|
| 61 | ; :func:`read_ncdf <saxo:read_ncdf>` |
---|
| 62 | ; :func:`julday <saxo:julday>` |
---|
| 63 | ; :func:`ncdf_quickwrite <saxo:ncdf_quickwrite>` |
---|
| 64 | ; |
---|
[88] | 65 | ; :ref:`Tropflux_NRT_ncdf.pro` |
---|
[81] | 66 | ; |
---|
[6] | 67 | ; EXAMPLES |
---|
| 68 | ; ======== |
---|
| 69 | ; |
---|
| 70 | ; :: |
---|
| 71 | ; |
---|
[74] | 72 | ; IDL> .compile TropFlux_swr_BLND_19890101_20091231 |
---|
[6] | 73 | ; IDL> tropflux_swr_blnd_19890101_20091231 |
---|
| 74 | ; |
---|
| 75 | ; TODO |
---|
| 76 | ; ==== |
---|
| 77 | ; |
---|
[88] | 78 | ; submit read_ncdf with 19890101 pb to saxo-dev |
---|
[81] | 79 | ; |
---|
[74] | 80 | ; avoid mix lower/uppercase in pro name to avoid compile |
---|
[6] | 81 | ; |
---|
| 82 | ; coding rules |
---|
| 83 | ; |
---|
[74] | 84 | ; complete description |
---|
| 85 | ; |
---|
[88] | 86 | ; why 20080100, 20100112 as date1 and date2 when readind nrt |
---|
[74] | 87 | ; |
---|
[88] | 88 | ; why two read_ncdf for nrt |
---|
[74] | 89 | ; |
---|
[88] | 90 | ; according to pk 20110811 we can include this process in |
---|
| 91 | ; TropFlux_swr_NRT_19890101_20091231.pro ... later |
---|
[78] | 92 | ; |
---|
[74] | 93 | ; KNOWN ISSUES |
---|
| 94 | ; ============ |
---|
| 95 | ; |
---|
| 96 | ; test of existence of fullfilename_in not very efficient because |
---|
| 97 | ; MUST_EXIST keyword of :func:`isafile <saxo:isafile>` not yet implemented |
---|
| 98 | ; |
---|
[6] | 99 | ; EVOLUTIONS |
---|
| 100 | ; ========== |
---|
| 101 | ; |
---|
[90] | 102 | ; $Id: TropFlux_swr_BLND_19890101_20091231.pro 88 2011-08-19 15:40:14Z pinsard $ |
---|
[85] | 103 | ; |
---|
[81] | 104 | ; $URL$ |
---|
| 105 | ; |
---|
[88] | 106 | ; - fplod 20110819T120412Z aedon.locean-ipsl.upmc.fr (Darwin) |
---|
| 107 | ; |
---|
| 108 | ; * change 19890101 to 19890100 to read 6939 timesteps in DT file |
---|
| 109 | ; even if uggly and understanted SAXO strange behaviour |
---|
| 110 | ; |
---|
| 111 | ; this resolve crash on cratos idl7:: |
---|
| 112 | ; |
---|
| 113 | ; % Attempt to subscript SWR_DT with JT is out of range. |
---|
| 114 | ; |
---|
| 115 | ; line:: |
---|
| 116 | ; |
---|
| 117 | ; for jt=0,jpt-1 do swr_merged(*,*,jt)=swr_dt(*,*,jt)*a(jt)+(1-a(jt))*swr_nrt(*,*,jt) |
---|
| 118 | ; |
---|
| 119 | ; problably because 6938+731=7669 and not 7670 when |
---|
| 120 | ; :samp:`dt=read_ncdf("swr", 19890101, 20071231, file=fullfilename_dt,/nostr)` |
---|
| 121 | ; was used :: |
---|
| 122 | ; |
---|
| 123 | ; DT FLOAT = Array[350, 60, 6938] |
---|
| 124 | ; NRT FLOAT = Array[350, 60, 731] |
---|
| 125 | ; SWR_DT FLOAT = Array[350, 60, 7669] |
---|
| 126 | ; SWR_NRT FLOAT = Array[350, 60, 7670] |
---|
| 127 | ; |
---|
| 128 | ; nb jours 19890101-20071231:: |
---|
| 129 | ; |
---|
| 130 | ; IDL> print, julday(12,31,2007) - julday(01, 01, 1989) +1 |
---|
| 131 | ; 6939 |
---|
| 132 | ; |
---|
| 133 | ; et ncdump -h $PROJECT_OD/TropFlux_swr_19890101_20071231_DT.nc time = UNLIMITED ; // (6939 currently) |
---|
| 134 | ; |
---|
| 135 | ; nb jours 19890101-20091231:: |
---|
| 136 | ; |
---|
| 137 | ; IDL> print, julday(12,31,2009) - julday(01, 01, 1989) +1 |
---|
| 138 | ; 7670 |
---|
| 139 | ; |
---|
| 140 | ; strange behaviour of read_ncdf ... see:: |
---|
| 141 | ; |
---|
| 142 | ; IDL> fullfilename_dt='TropFlux_swr_19890101_20071231_DT.nc' |
---|
| 143 | ; IDL> dt=read_ncdf("swr", 19890100, 20071231, file=fullfilename_dt,/nostr) |
---|
| 144 | ; IDL> print, 'first time step (should crash with invalid date)', jul2date(time[0]) |
---|
| 145 | ; first time step (should be 19890101) 19890101. |
---|
| 146 | ; IDL> dt=read_ncdf("swr", 19890101, 20071231, file=fullfilename_dt,/nostr) |
---|
| 147 | ; IDL> print, 'first time step (should be 19890101)', jul2date(time[0]) |
---|
| 148 | ; first time step (should be 19890101) 19890102. |
---|
| 149 | ; |
---|
| 150 | ; * correction for reading gustiness file |
---|
| 151 | ; |
---|
[74] | 152 | ; - fplod 20110809T115747Z aedon.locean-ipsl.upmc.fr (Darwin) |
---|
| 153 | ; |
---|
| 154 | ; * usage of ${PROJECT_OD} |
---|
| 155 | ; * remove v* from filenames (in and out) |
---|
| 156 | ; * add test on IO files |
---|
| 157 | ; |
---|
[8] | 158 | ; - fplod 20101215T085754Z aedon.locean-ipsl.upmc.fr (Darwin) |
---|
| 159 | ; |
---|
| 160 | ; * add graph in header |
---|
| 161 | ; |
---|
[6] | 162 | ; - fplod 20101214T093615Z aedon.locean-ipsl.upmc.fr (Darwin) |
---|
| 163 | ; |
---|
| 164 | ; * minimal header |
---|
| 165 | ; |
---|
| 166 | ; - pbk 2008 |
---|
| 167 | ; |
---|
| 168 | ; * creation |
---|
| 169 | ; |
---|
| 170 | ;- |
---|
[5] | 171 | pro TropFlux_swr_BLND_19890101_20091231 |
---|
[74] | 172 | ; |
---|
| 173 | @cm_4cal |
---|
| 174 | @cm_4data |
---|
| 175 | @cm_4mesh |
---|
| 176 | @cm_4data |
---|
| 177 | @cm_project |
---|
| 178 | ; |
---|
| 179 | ; test if ${PROJECT_OD} defined |
---|
| 180 | CASE project_od_env OF |
---|
| 181 | '' : BEGIN |
---|
| 182 | msg = 'eee : ${PROJECT_OD} is not defined' |
---|
| 183 | ras = report(msg) |
---|
| 184 | STOP |
---|
| 185 | END |
---|
| 186 | ELSE: BEGIN |
---|
| 187 | msg = 'iii : ${PROJECT_OD} is ' + project_od_env |
---|
| 188 | ras = report(msg) |
---|
| 189 | END |
---|
| 190 | ENDCASE |
---|
| 191 | ; |
---|
| 192 | ; check if output data will be possible |
---|
| 193 | iodirout = isadirectory(project_od_env) |
---|
| 194 | ; |
---|
| 195 | ; existence and protection for reading |
---|
| 196 | IF (FILE_TEST(iodirout, /DIRECTORY, /EXECUTABLE, /READ) EQ 0) THEN BEGIN |
---|
| 197 | msg = 'eee : the directory' + iodirout + ' is not accessible.' |
---|
| 198 | ras = report(msg) |
---|
| 199 | STOP |
---|
| 200 | ENDIF |
---|
| 201 | ; |
---|
| 202 | ; existence and protection for writing |
---|
| 203 | IF (FILE_TEST(iodirout, /DIRECTORY, /WRITE) EQ 0) THEN BEGIN |
---|
| 204 | msg = 'eee : the directory' + iodirout + ' was not found.' |
---|
| 205 | ras = report(msg) |
---|
| 206 | STOP |
---|
| 207 | ENDIF |
---|
| 208 | ; |
---|
| 209 | ; build dt data filename |
---|
| 210 | filename_dt="TropFlux_swr_19890101_20071231_DT.nc" |
---|
| 211 | ; |
---|
| 212 | ; check if this file exists |
---|
| 213 | msg='iii : looking for ' + filename_dt |
---|
| 214 | ras = report(msg) |
---|
| 215 | fullfilename_dt = isafile(iodirout + filename_dt, NEW=0, /MUST_EXIST) |
---|
| 216 | IF fullfilename_dt[0] EQ '' THEN BEGIN |
---|
| 217 | msg = 'eee : the file ' + fullfilename_dt + ' was not found.' |
---|
| 218 | ras = report(msg) |
---|
| 219 | STOP |
---|
| 220 | ENDIF |
---|
[5] | 221 | |
---|
[74] | 222 | ; build nrt data filename |
---|
| 223 | filename_nrt="TropFlux_swr_19890101_20091231_NRT.nc" |
---|
| 224 | ; |
---|
| 225 | ; check if this file exists |
---|
| 226 | msg='iii : looking for ' + filename_nrt |
---|
| 227 | ras = report(msg) |
---|
| 228 | fullfilename_nrt = isafile(iodirout + filename_nrt, NEW=0, /MUST_EXIST) |
---|
| 229 | IF fullfilename_nrt[0] EQ '' THEN BEGIN |
---|
| 230 | msg = 'eee : the file ' + fullfilename_nrt + ' was not found.' |
---|
| 231 | ras = report(msg) |
---|
| 232 | STOP |
---|
| 233 | ENDIF |
---|
| 234 | ; |
---|
| 235 | ; build wg data filename |
---|
| 236 | filename_wg="TropFlux_gustiness_19890101_20091231.nc" |
---|
| 237 | ; |
---|
| 238 | ; check if this file exists |
---|
| 239 | msg='iii : looking for ' + filename_wg |
---|
| 240 | ras = report(msg) |
---|
| 241 | fullfilename_wg = isafile(iodirout + filename_wg, NEW=0, /MUST_EXIST) |
---|
| 242 | IF fullfilename_wg[0] EQ '' THEN BEGIN |
---|
| 243 | msg = 'eee : the file ' + fullfilename_wg + ' was not found.' |
---|
| 244 | ras = report(msg) |
---|
| 245 | STOP |
---|
| 246 | ENDIF |
---|
| 247 | ; |
---|
| 248 | ; build output filename |
---|
| 249 | filename_out = 'TropFlux_swr_19890101_20091231_BLND.nc' |
---|
| 250 | fullfilename_out = iodirout + filename_out |
---|
| 251 | ; in order to avoid unexpected overwritten |
---|
| 252 | IF (FILE_TEST(fullfilename_out) EQ 1) THEN BEGIN |
---|
| 253 | msg = 'eee : the file ' + fullfilename_out + ' already exists.' |
---|
| 254 | ras = report(msg) |
---|
| 255 | STOP |
---|
| 256 | ENDIF |
---|
| 257 | ; |
---|
| 258 | initncdf, fullfilename_dt |
---|
[88] | 259 | dt=read_ncdf("swr", 19890100, 20071231, file=fullfilename_dt,/nostr) |
---|
| 260 | print, 'www : should crash with invalide date 19890100' |
---|
[5] | 261 | help, dt |
---|
[88] | 262 | print, 'first time step (should be 19890101)', jul2date(time[0]) |
---|
| 263 | print, 'last time step (should be 20071231)', jul2date(time[jpt-1]) |
---|
[5] | 264 | |
---|
[74] | 265 | initncdf, fullfilename_nrt |
---|
| 266 | nrt=read_ncdf("sw", 20080100, 20100112, file=fullfilename_nrt,/nostr) |
---|
[5] | 267 | help, nrt |
---|
| 268 | |
---|
[74] | 269 | swr_nrt=read_ncdf("sw", 19880101, 20100112, file=fullfilename_nrt,/nostr) |
---|
[5] | 270 | |
---|
| 271 | swr_dt=[[[dt]],[[nrt]]] |
---|
[88] | 272 | help, nrt, swr_dt, swr_nrt |
---|
[5] | 273 | |
---|
| 274 | swr_merged=swr_dt*0. |
---|
| 275 | |
---|
[94] | 276 | time=timegen(7670, units='days', start=julday(1,1,1989,0)) |
---|
| 277 | jpt=n_elements(time) |
---|
[5] | 278 | |
---|
| 279 | a=interpol([1.,0.],[julday(10,01,2007),julday(12,31,2007)],time) |
---|
| 280 | a=((a > 0.) < 1.) |
---|
[88] | 281 | for jt=0,jpt-1 do begin |
---|
| 282 | swr_merged(*,*,jt)=swr_dt(*,*,jt)*a(jt)+(1-a(jt))*swr_nrt(*,*,jt) |
---|
| 283 | endfor |
---|
[5] | 284 | |
---|
[88] | 285 | initncdf, fullfilename_wg |
---|
[94] | 286 | time=timegen(7670, units='days', start=julday(1,1,1989,0)) |
---|
| 287 | jpt=n_elements(time) |
---|
[5] | 288 | lat=reform(gphit(0,0:jpj-1)) |
---|
| 289 | lon=reform(glamt(0:jpi-1,0)) |
---|
| 290 | cda0=string(jul2date(time(0)),format='(i8.8)') |
---|
| 291 | cda1=string(jul2date(time(jpt-1)),format='(i8.8)') |
---|
| 292 | |
---|
| 293 | time=time-julday(1,1,1950,00,00) |
---|
[74] | 294 | ncfile='!' + fullfilename_out |
---|
[5] | 295 | lon_attr={units:'degrees_east',long_name:'Longitude'} |
---|
| 296 | lat_attr={units:'degrees_north',long_name:'Latitude'} |
---|
| 297 | time_attr={units:'days since 1950-01-01 00:00:00',long_name:'Time axis',time_origin:'1950-JAN-01 00:00:00'} |
---|
| 298 | sw_attr={units:'w/m^2',missing_value:1.e20,long_name:'Net Shortwave Radiation',short_name:'swr',axis:'TYX'} |
---|
| 299 | globattr={source:'ISCCP based SWR until 2007, after 2007 timeseries is completed with OLR based SWR. A linear transition is applied from ISCCP based SWR to OLR based SWR'} |
---|
| 300 | |
---|
| 301 | ncfields = 'swr[longitude,latitude,time]=swr_merged:sw_attr; ' $ |
---|
| 302 | + 'longitude[]=lon:lon_attr; ' $ |
---|
| 303 | + 'latitude[]=lat:lat_attr; ' $ |
---|
| 304 | + 'time[*time]=time:time_attr ' $ |
---|
| 305 | + ' @ globattr' |
---|
| 306 | |
---|
| 307 | @ncdf_quickwrite |
---|
| 308 | |
---|
| 309 | end |
---|