[6] | 1 | ;+ |
---|
| 2 | ; |
---|
[8] | 3 | ; .. _TropFlux_swr_NRT_19890101_20091231.pro: |
---|
[6] | 4 | ; |
---|
| 5 | ; ====================================== |
---|
| 6 | ; TropFlux_swr_NRT_19890101_20091231.pro |
---|
| 7 | ; ====================================== |
---|
| 8 | ; |
---|
[81] | 9 | ; DESCRITION |
---|
| 10 | ; ========== |
---|
[6] | 11 | ; |
---|
[81] | 12 | ; Correction of swr near real time on OAFLUX grid |
---|
| 13 | ; |
---|
| 14 | ; Corrected swr delay on OAFLUX grid |
---|
| 15 | ; has been produced by |
---|
| 16 | ; :file:`${PROJECT_OD}/TropFlux_swr_19890101_20071231_DT.nc` |
---|
| 17 | ; |
---|
| 18 | ; :file:`${PROJECT_OD}/olr_oafluxgrid_30n30s_19890101_20091231.nc` |
---|
| 19 | ; have been produced ++by pk |
---|
| 20 | ; |
---|
| 21 | ; Corrected swr near real time on OAFLUX grid |
---|
| 22 | ; ; is written in |
---|
| 23 | ; :file:`${PROJECT_OD}/TropFlux_swr_19890101_20091231_NRT.nc` |
---|
| 24 | ; if this file not already exists. |
---|
| 25 | ; |
---|
| 26 | ; This file will be used by :ref:`TropFlux_swr_BLND_19890101_20091231.pro`. |
---|
| 27 | ; |
---|
[8] | 28 | ; .. graphviz:: |
---|
| 29 | ; |
---|
[74] | 30 | ; digraph tropflux_swr_nrt_19890101_200912311 { |
---|
| 31 | ; |
---|
[81] | 32 | ; file_swr_dt [shape=ellipse,fontname=Courier,label="${PROJECT_OD}/TropFlux_swr_19890101_20071231_DT.nc"]; |
---|
| 33 | ; file_olr [shape=ellipse,fontname=Courier,label="${PROJECT_OD}/olr_oafluxgrid_30n30s_19890101_20091231.nc"]; |
---|
| 34 | ; file_out [shape=ellipse,fontname=Courier,label="${PROJECT_OD}/TropFlux_swr_19890101_20091231_NRT.nc"]; |
---|
| 35 | ; |
---|
[74] | 36 | ; tropflux_swr_nrt_19890101_200912311 [shape=box, |
---|
[8] | 37 | ; fontname=Courier, |
---|
| 38 | ; color=blue, |
---|
| 39 | ; URL="http://forge.ipsl.jussieu.fr/tropflux/browser/trunk/src/TropFlux_swr_NRT_19890101_200912311.pro", |
---|
[50] | 40 | ; label="${PROJECT}/src/TropFlux_swr_NRT_19890101_200912311.pro"]; |
---|
[74] | 41 | ; |
---|
[81] | 42 | ; {file_swr_dt file_olr}-> {tropflux_swr_nrt_19890101_200912311} -> {file_out} |
---|
[8] | 43 | ; } |
---|
| 44 | ; |
---|
[6] | 45 | ; SEE ALSO |
---|
| 46 | ; ======== |
---|
| 47 | ; |
---|
[81] | 48 | ; :ref:`project_profile.sh` |
---|
| 49 | ; |
---|
| 50 | ; :ref:`mooring_corrections` |
---|
| 51 | ; |
---|
| 52 | ; :ref:`data_in_swr` |
---|
| 53 | ; :ref:`data_in_olr` |
---|
| 54 | ; |
---|
[20] | 55 | ; :func:`initncdf <saxo:initncdf>` |
---|
| 56 | ; :func:`read_ncdf <saxo:read_ncdf>` |
---|
| 57 | ; :func:`julday <saxo:julday>` |
---|
| 58 | ; :func:`ncdf_quickwrite <saxo:ncdf_quickwrite>` |
---|
| 59 | ; |
---|
[6] | 60 | ; EXAMPLES |
---|
| 61 | ; ======== |
---|
| 62 | ; |
---|
| 63 | ; :: |
---|
| 64 | ; |
---|
[81] | 65 | ; IDL> .compile TropFlux_swr_NRT_19890101_20091231 |
---|
[6] | 66 | ; IDL> tropflux_swr_nrt_19890101_20091231 |
---|
| 67 | ; |
---|
| 68 | ; TODO |
---|
| 69 | ; ==== |
---|
| 70 | ; |
---|
[81] | 71 | ; remove NaNf values in ouptut file (may be not because of this module) |
---|
[6] | 72 | ; |
---|
[81] | 73 | ; why two sequence initcdf et read_ndcf on olr file ? |
---|
| 74 | ; |
---|
[6] | 75 | ; coding rules |
---|
| 76 | ; |
---|
[81] | 77 | ; why compile is needed ? uppercase in file name |
---|
| 78 | ; |
---|
[78] | 79 | ; change the name to swr_nrt_correction_ncdf.pro |
---|
[81] | 80 | ; to homogenize names of tools |
---|
[78] | 81 | ; |
---|
[81] | 82 | ; KNOWN ISSUES |
---|
| 83 | ; ============ |
---|
| 84 | ; |
---|
| 85 | ; test of existence of fullfilename not very efficient because |
---|
| 86 | ; MUST_EXIST keyword of :func:`isafile <saxo:isafile>` not yet implemented |
---|
| 87 | ; |
---|
[6] | 88 | ; EVOLUTIONS |
---|
| 89 | ; ========== |
---|
| 90 | ; |
---|
[81] | 91 | ; $Id$ |
---|
| 92 | ; |
---|
| 93 | ; $URL$ |
---|
| 94 | ; |
---|
| 95 | ; - fplod 20110812T075406Z aedon.locean-ipsl.upmc.fr (Darwin) |
---|
| 96 | ; |
---|
| 97 | ; * usage of ${PROJECT_OD} |
---|
| 98 | ; * complete description |
---|
| 99 | ; * remove v50 in filenames |
---|
| 100 | ; |
---|
[8] | 101 | ; - fplod 20101215T092145Z aedon.locean-ipsl.upmc.fr (Darwin) |
---|
| 102 | ; |
---|
| 103 | ; * add graph in header |
---|
| 104 | ; |
---|
[6] | 105 | ; - fplod 20101214T093615Z aedon.locean-ipsl.upmc.fr (Darwin) |
---|
| 106 | ; |
---|
| 107 | ; * minimal header |
---|
| 108 | ; |
---|
| 109 | ; - pbk 2008 |
---|
| 110 | ; |
---|
| 111 | ; * creation |
---|
| 112 | ; |
---|
| 113 | ;- |
---|
[5] | 114 | pro TropFlux_swr_NRT_19890101_20091231 |
---|
[81] | 115 | ; |
---|
| 116 | @cm_4cal |
---|
| 117 | @cm_4data |
---|
| 118 | @cm_4mesh |
---|
| 119 | @cm_4data |
---|
| 120 | @cm_project |
---|
| 121 | ; |
---|
| 122 | ; test if ${PROJECT_OD} defined |
---|
| 123 | CASE project_od_env OF |
---|
| 124 | '' : BEGIN |
---|
| 125 | msg = 'eee : ${PROJECT_OD} is not defined' |
---|
| 126 | ras = report(msg) |
---|
| 127 | STOP |
---|
| 128 | END |
---|
| 129 | ELSE: BEGIN |
---|
| 130 | msg = 'iii : ${PROJECT_OD} is ' + project_od_env |
---|
| 131 | ras = report(msg) |
---|
| 132 | END |
---|
| 133 | ENDCASE |
---|
| 134 | ; check if output data will be possible |
---|
| 135 | iodirout = isadirectory(project_od_env) |
---|
| 136 | ; |
---|
| 137 | ; existence and protection for reading |
---|
| 138 | IF (FILE_TEST(iodirout, /DIRECTORY, /EXECUTABLE, /READ) EQ 0) THEN BEGIN |
---|
| 139 | msg = 'eee : the directory' + iodirout + ' is not accessible.' |
---|
| 140 | ras = report(msg) |
---|
| 141 | STOP |
---|
| 142 | ENDIF |
---|
| 143 | ; |
---|
| 144 | ; existence and protection for writing |
---|
| 145 | IF (FILE_TEST(iodirout, /DIRECTORY, /WRITE) EQ 0) THEN BEGIN |
---|
| 146 | msg = 'eee : the directory' + iodirout + ' was not found.' |
---|
| 147 | ras = report(msg) |
---|
| 148 | STOP |
---|
| 149 | ENDIF |
---|
| 150 | ; |
---|
| 151 | ; build swr dt data filename |
---|
| 152 | filename_swr_dt='TropFlux_swr_19890101_20071231_DT.nc' |
---|
| 153 | ; |
---|
| 154 | ; check if this file exists |
---|
| 155 | msg='iii : looking for ' + filename_swr_dt |
---|
| 156 | ras = report(msg) |
---|
| 157 | fullfilename_swr_dt = isafile(iodirout + filename_swr_dt, NEW=0, /MUST_EXIST) |
---|
| 158 | IF fullfilename_swr_dt[0] EQ '' THEN BEGIN |
---|
| 159 | msg = 'eee : the file ' + fullfilename_swr_dt + ' was not found.' |
---|
| 160 | ras = report(msg) |
---|
| 161 | STOP |
---|
| 162 | ENDIF |
---|
| 163 | ; |
---|
| 164 | ; build olr data filename |
---|
| 165 | filename_olr='olr_oafluxgrid_30n30s_19890101_20091231.nc' |
---|
| 166 | ; |
---|
| 167 | ; check if this file exists |
---|
| 168 | msg='iii : looking for ' + filename_olr |
---|
| 169 | ras = report(msg) |
---|
| 170 | fullfilename_olr = isafile(iodirout + filename_olr, NEW=0, /MUST_EXIST) |
---|
| 171 | IF fullfilename_olr[0] EQ '' THEN BEGIN |
---|
| 172 | msg = 'eee : the file ' + fullfilename_olr + ' was not found.' |
---|
| 173 | ras = report(msg) |
---|
| 174 | STOP |
---|
| 175 | ENDIF |
---|
| 176 | ; |
---|
| 177 | ; build output filename |
---|
| 178 | filename_out = 'TropFlux_swr_19890101_20091231_NRT.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_swr_dt |
---|
| 188 | sw=read_ncdf("swr", 19890101, 20071231, file=fullfilename_swr_dt,/nostr) |
---|
[5] | 189 | |
---|
| 190 | swi=sw |
---|
| 191 | |
---|
[81] | 192 | initncdf, fullfilename_olr |
---|
| 193 | olr=read_ncdf('olr',19890100, 20071231, file=fullfilename_olr,/nost) |
---|
[5] | 194 | |
---|
| 195 | help, sw, olr |
---|
| 196 | |
---|
| 197 | ;;creating climatology |
---|
| 198 | |
---|
| 199 | ny=(2007-1989)+1 |
---|
| 200 | nt=365*ny |
---|
| 201 | olri=total(reform(olr(*,*,0:nt-1),nxt,nyt,365,ny),4)/ny |
---|
| 202 | swi=total(reform(swi(*,*,0:nt-1),nxt,nyt,365,ny),4)/ny |
---|
| 203 | |
---|
| 204 | help, olri, swi |
---|
| 205 | |
---|
| 206 | ;; applying smoothing |
---|
| 207 | nsmooth=45 |
---|
| 208 | |
---|
| 209 | swi=[[[swi]],[[swi]],[[swi]]] & olri=[[[olri]],[[olri]],[[olri]]] |
---|
| 210 | si=size(sw) & n1=si(1) & n2=si(2) |
---|
| 211 | |
---|
| 212 | for j=0,n2-1 do begin |
---|
| 213 | for i=0,n1-1 do begin |
---|
| 214 | x=reform(swi(i,j,*)) |
---|
| 215 | y=reform(olri(i,j,*)) |
---|
| 216 | swi(i,j,*)=smooth(x,nsmooth) |
---|
| 217 | olri(i,j,*)=smooth(y,nsmooth) |
---|
| 218 | endfor |
---|
| 219 | endfor |
---|
| 220 | |
---|
| 221 | swi=swi[*,*,365:365+364] & olri=olri[*,*,365:365+364] |
---|
| 222 | help, swi |
---|
| 223 | |
---|
[81] | 224 | initncdf, fullfilename_olr |
---|
| 225 | olr=read_ncdf('olr', 19890100, 20091231, box=box, file=fullfilename_olr,/nostr) |
---|
[5] | 226 | tt=time & jpt=n_elements(time) |
---|
| 227 | caldat, time,mon,day,yea |
---|
| 228 | swm=olr*0. & olrm=olr*0. |
---|
| 229 | for jt=0,jpt-1 do begin |
---|
| 230 | jtt=(time(jt)-julday(1,1,yea(jt))) < 364 |
---|
| 231 | swm(*,*,jt)=swi(*,*,jtt) |
---|
| 232 | olrm(*,*,jt)=olri(*,*,jtt) |
---|
| 233 | endfor |
---|
| 234 | |
---|
| 235 | help, swm, olrm |
---|
| 236 | |
---|
| 237 | olra=olr-olrm ; olr anomaly |
---|
| 238 | rec=swm+(olra/0.760364) ; reconstructed sw |
---|
| 239 | ;writing field |
---|
| 240 | time=julday(1,1,1989)+lindgen(7670) |
---|
| 241 | cda0=string(jul2date(tt(0)),format='(i8.8)') |
---|
| 242 | cda1=string(jul2date(tt(jpt-1)),format='(i8.8)') |
---|
| 243 | |
---|
| 244 | lat=reform(gphit(0,0:jpj-1)) |
---|
| 245 | lon=reform(glamt(0:jpi-1,0)) |
---|
| 246 | time=time-julday(1,1,1950) & jpt=n_elements(time) |
---|
| 247 | |
---|
[81] | 248 | ncfile='!' + fullfilename_out |
---|
[5] | 249 | lon_attr={units:'degrees_east',long_name:'Longitude'} |
---|
| 250 | lat_attr={units:'degrees_north',long_name:'Latitude'} |
---|
| 251 | time_attr={units:'days since 1950-01-01 00:00:00',long_name:'Time axis',time_origin:''} |
---|
| 252 | sw_attr={units:'w/m^2',missing_value:1.e20,long_name:'Net Shortwave Radiation',short_name:'swr',axis:'TYX'} |
---|
| 253 | globattr={source:'Reconstructed from corrected OLR anomalies and TropFlux mean SWR climatology',timerange:cda0+' - '+cda1} |
---|
| 254 | |
---|
| 255 | |
---|
| 256 | ncfields = 'sw[longitude,latitude,time]=rec:sw_attr; ' $ |
---|
| 257 | + 'longitude[]=lon:lon_attr; ' $ |
---|
| 258 | + 'latitude[]=lat:lat_attr; ' $ |
---|
| 259 | + 'time[*time]=time:time_attr ' $ |
---|
| 260 | + ' @ globattr' |
---|
| 261 | |
---|
| 262 | @ncdf_quickwrite |
---|
| 263 | |
---|
| 264 | end |
---|