[6] | 1 | ;+ |
---|
| 2 | ; |
---|
| 3 | ; .. _interp_olr_30n30s_1989_2009.pro: |
---|
| 4 | ; |
---|
| 5 | ; =============================== |
---|
| 6 | ; interp_olr_30n30s_1989_2009.pro |
---|
| 7 | ; =============================== |
---|
| 8 | ; |
---|
[81] | 9 | ; DESCRIPTION |
---|
| 10 | ; =========== |
---|
| 11 | ; |
---|
| 12 | ; Interpolation of OLR to OAFLUX grid |
---|
| 13 | ; |
---|
| 14 | ; :file:`${PROJECT_ID}/olr.day.mean.nc` |
---|
| 15 | ; have been produced by |
---|
| 16 | ; :ref:`get_olr.sh` |
---|
| 17 | ; |
---|
| 18 | ; :file:`${PROJECT_ID}/mask_oaflux_30N30S.nc` containing OAFLUX grid |
---|
| 19 | ; have been produced by |
---|
| 20 | ; :ref:`oaflux_mask_30N30S.pro`. |
---|
| 21 | ; |
---|
| 22 | ; Interpolated OLR is written in |
---|
| 23 | ; :file:`${PROJECT_OD}/${PROJECT_OD}/olr_oafluxgrid_30n30s_19890101_20091231.nc` |
---|
| 24 | ; if this file not already exists. |
---|
| 25 | ; |
---|
| 26 | ; This output file will be used by |
---|
| 27 | ; :ref:`TropFlux_swr_NRT_19890101_20091231.pro`. |
---|
| 28 | ; |
---|
[9] | 29 | ; .. graphviz:: |
---|
| 30 | ; |
---|
| 31 | ; digraph interp_olr_30n30s_1989_2009{ |
---|
| 32 | ; |
---|
[81] | 33 | ; file_in [shape=ellipse,fontname=Courier,label="${PROJECT_ID}/olr.day.mean_new.nc"]; |
---|
[50] | 34 | ; mask [shape=ellipse,fontname=Courier,label="${PROJECT_ID}/mask_oaflux_30N30S.nc"]; |
---|
[81] | 35 | ; file_out [shape=ellipse,fontname=Courier,label="${PROJECT_OD}/olr_oafluxgrid_30n30s_19890101_20091231.nc"]; |
---|
[9] | 36 | ; |
---|
| 37 | ; interp_olr_30n30s_1989_2009 [shape=box, |
---|
| 38 | ; fontname=Courier, |
---|
| 39 | ; color=blue, |
---|
| 40 | ; URL="http://forge.ipsl.jussieu.fr/tropflux/browser/trunk/src/interp_olr_30n30s_1989_2009.pro", |
---|
[50] | 41 | ; label="${PROJECT}/src/interp_olr_30n30s_1989_2009.pro"]; |
---|
[9] | 42 | ; |
---|
[81] | 43 | ; {file_in mask} -> {interp_olr_30n30s_1989_2009} -> {file_out} |
---|
[9] | 44 | ; |
---|
[100] | 45 | ; } |
---|
[9] | 46 | ; |
---|
[6] | 47 | ; SEE ALSO |
---|
| 48 | ; ======== |
---|
| 49 | ; |
---|
[50] | 50 | ; :ref:`project_profile.sh` |
---|
[19] | 51 | ; |
---|
[81] | 52 | ; :ref:`interpolate_data` |
---|
| 53 | ; |
---|
| 54 | ; :ref:`data_in_olr`, :ref:`get_olr.sh` |
---|
| 55 | ; |
---|
[20] | 56 | ; :func:`report <saxo:report>` |
---|
| 57 | ; :func:`isadirectory <saxo:isadirectory>` |
---|
| 58 | ; :func:`isafile <saxo:isafile>` |
---|
| 59 | ; :func:`initncdf <saxo:initncdf>` |
---|
| 60 | ; :func:`read_ncdf <saxo:read_ncdf>` |
---|
| 61 | ; :func:`domdef <saxo:domdef>` |
---|
| 62 | ; :func:`call_interp2d <saxo:call_interp2d>` |
---|
| 63 | ; :func:`ncdf_quickwrite <saxo:ncdf_quickwrite>` |
---|
| 64 | ; |
---|
[6] | 65 | ; EXAMPLES |
---|
| 66 | ; ======== |
---|
| 67 | ; |
---|
| 68 | ; :: |
---|
| 69 | ; |
---|
[81] | 70 | ; IDL> .compile file_interp |
---|
[6] | 71 | ; IDL> interp_olr_30n30s_1989_2009 |
---|
| 72 | ; |
---|
| 73 | ; TODO |
---|
| 74 | ; ==== |
---|
| 75 | ; |
---|
[81] | 76 | ; how can we avoid this message :: |
---|
[6] | 77 | ; |
---|
[81] | 78 | ; % initncdf: the zaxis was not found..., check the use of ZAXISNAME keyword if you want to find one... |
---|
[97] | 79 | ; |
---|
[81] | 80 | ; I think we do not need any zaxis |
---|
| 81 | ; |
---|
| 82 | ; strange second value (1) in the file produced on cratos idl 7 20110812:: |
---|
| 83 | ; |
---|
| 84 | ; $ ncdump $PROJECT_OD/olr_oafluxgrid_30n30s_19890101_20091231.nc |
---|
| 85 | ; olr = |
---|
[97] | 86 | ; 1e+20, 1, 258.15, 264.882, 271.614, 273.8116, 271.4748, 269.138, 266.6868, |
---|
[81] | 87 | ; |
---|
[6] | 88 | ; coding rules |
---|
| 89 | ; |
---|
[81] | 90 | ; check OUTMASK_IND and SET_OUTMSKVAL added to call_interp2d call |
---|
[19] | 91 | ; |
---|
[81] | 92 | ; pb with mixing interpolated and uninterpolated OLR data |
---|
| 93 | ; check if the input file is the right one (interpolated with get_olr.sh vs non interpolated with get_olr_int.sh) |
---|
[78] | 94 | ; |
---|
| 95 | ; uninterpolated OLR is more timely |
---|
[81] | 96 | ; |
---|
[78] | 97 | ; cf. pk and jv to solve this issue |
---|
| 98 | ; |
---|
[81] | 99 | ; KNOWN ISSUES |
---|
| 100 | ; ============ |
---|
| 101 | ; |
---|
[19] | 102 | ; test of existence of fullfilename_msk not very efficient because |
---|
| 103 | ; MUST_EXIST keyword of :func:`isafile <saxo:isafile>` not yet implemented |
---|
| 104 | ; |
---|
[6] | 105 | ; EVOLUTIONS |
---|
| 106 | ; ========== |
---|
| 107 | ; |
---|
[90] | 108 | ; $Id: interp_olr_30n30s_1989_2009.pro 88 2011-08-19 15:40:14Z pinsard $ |
---|
[81] | 109 | ; |
---|
| 110 | ; $URL$ |
---|
| 111 | ; |
---|
| 112 | ; - fplod 20110812T084449Z aedon.locean-ipsl.upmc.fr (Darwin) |
---|
| 113 | ; |
---|
| 114 | ; * remove new from filename |
---|
| 115 | ; * usage of $PROJECT_ID and $PROJECT_OD |
---|
| 116 | ; * add OUTMASK_IND and SET_OUTMSKVAL to call_interp2d call |
---|
| 117 | ; * complete description |
---|
| 118 | ; |
---|
[19] | 119 | ; - fplod 20101217T140745Z aedon.locean-ipsl.upmc.fr (Darwin) |
---|
| 120 | ; |
---|
| 121 | ; * remove hard coded directory for mask_oaflux_30N30S.nc |
---|
| 122 | ; |
---|
[9] | 123 | ; - fplod 20101215T113118Z aedon.locean-ipsl.upmc.fr (Darwin) |
---|
| 124 | ; |
---|
| 125 | ; * add graph in header |
---|
| 126 | ; |
---|
[6] | 127 | ; - fplod 20101214T093615Z aedon.locean-ipsl.upmc.fr (Darwin) |
---|
| 128 | ; |
---|
| 129 | ; * minimal header |
---|
| 130 | ; |
---|
| 131 | ; - pbk 2008 |
---|
| 132 | ; |
---|
| 133 | ; * creation |
---|
| 134 | ; |
---|
| 135 | ;- |
---|
[5] | 136 | pro interp_olr_30n30s_1989_2009 |
---|
[19] | 137 | ; |
---|
[81] | 138 | @cm_4cal |
---|
| 139 | @cm_4data |
---|
| 140 | @cm_4mesh |
---|
| 141 | @cm_4data |
---|
| 142 | @cm_project |
---|
| 143 | ; |
---|
[20] | 144 | ; check for input directory |
---|
[19] | 145 | ; |
---|
[50] | 146 | ; test if ${PROJECT_ID} defined |
---|
| 147 | CASE project_id_env OF |
---|
[19] | 148 | '' : BEGIN |
---|
[50] | 149 | msg = 'eee : ${PROJECT_ID} is not defined' |
---|
[19] | 150 | ras = report(msg) |
---|
| 151 | STOP |
---|
| 152 | END |
---|
| 153 | ELSE: BEGIN |
---|
[50] | 154 | msg = 'iii : ${PROJECT_ID} is ' + project_id_env |
---|
[19] | 155 | ras = report(msg) |
---|
| 156 | END |
---|
| 157 | ENDCASE |
---|
| 158 | ; |
---|
[50] | 159 | iodirin = isadirectory(project_id_env) |
---|
[19] | 160 | ; |
---|
[50] | 161 | ; existence and protection of ${PROJECT_ID} |
---|
[19] | 162 | IF (FILE_TEST(iodirin, /DIRECTORY, /EXECUTABLE, /READ) EQ 0) THEN BEGIN |
---|
| 163 | msg = 'eee : the directory' + iodirin + ' is not accessible.' |
---|
| 164 | ras = report(msg) |
---|
| 165 | STOP |
---|
| 166 | ENDIF |
---|
| 167 | ; |
---|
| 168 | ; build mask filename |
---|
| 169 | filename_msk='mask_oaflux_30N30S.nc' |
---|
| 170 | ; |
---|
| 171 | ; check if this file exists |
---|
[81] | 172 | msg='iii : looking for ' + filename_msk |
---|
| 173 | ras = report(msg) |
---|
[19] | 174 | fullfilename_msk = isafile(iodirin + filename_msk, NEW=0, /MUST_EXIST) |
---|
| 175 | IF fullfilename_msk[0] EQ '' THEN BEGIN |
---|
| 176 | msg = 'eee : the file ' + fullfilename_msk + ' was not found.' |
---|
| 177 | ras = report(msg) |
---|
| 178 | STOP |
---|
| 179 | ENDIF |
---|
[81] | 180 | ; |
---|
| 181 | ; build data filename |
---|
| 182 | filename='olr.day.mean.nc' |
---|
| 183 | ; |
---|
| 184 | ; check if this file exists |
---|
| 185 | msg='iii : looking for ' + filename |
---|
| 186 | ras = report(msg) |
---|
| 187 | fullfilename = isafile(iodirin + filename, NEW=0, /MUST_EXIST) |
---|
| 188 | IF fullfilename[0] EQ '' THEN BEGIN |
---|
| 189 | msg = 'eee : the file ' + fullfilename + ' was not found.' |
---|
| 190 | ras = report(msg) |
---|
| 191 | STOP |
---|
| 192 | ENDIF |
---|
| 193 | ; |
---|
| 194 | ; test if ${PROJECT_OD} defined |
---|
| 195 | CASE project_od_env OF |
---|
| 196 | '' : BEGIN |
---|
| 197 | msg = 'eee : ${PROJECT_OD} is not defined' |
---|
| 198 | ras = report(msg) |
---|
| 199 | STOP |
---|
| 200 | END |
---|
| 201 | ELSE: BEGIN |
---|
| 202 | msg = 'iii : ${PROJECT_OD} is ' + project_od_env |
---|
| 203 | ras = report(msg) |
---|
| 204 | END |
---|
| 205 | ENDCASE |
---|
| 206 | ; |
---|
| 207 | ; check if output data will be possible |
---|
| 208 | iodirout = isadirectory(project_od_env) |
---|
| 209 | ; |
---|
| 210 | ; existence and protection |
---|
| 211 | IF (FILE_TEST(iodirout, /DIRECTORY, /WRITE) EQ 0) THEN BEGIN |
---|
| 212 | msg = 'eee : the directory' + iodirout + ' was not found.' |
---|
| 213 | ras = report(msg) |
---|
| 214 | STOP |
---|
| 215 | ENDIF |
---|
| 216 | ; |
---|
| 217 | ; build output filename |
---|
| 218 | filename_out = 'olr_oafluxgrid_30n30s_19890101_20091231.nc' |
---|
| 219 | fullfilename_out = iodirout + filename_out |
---|
| 220 | ; in order to avoid unexpected overwritten |
---|
| 221 | IF (FILE_TEST(fullfilename_out) EQ 1) THEN BEGIN |
---|
| 222 | msg = 'eee : the file ' + fullfilename_out + ' already exists.' |
---|
| 223 | ras = report(msg) |
---|
| 224 | STOP |
---|
| 225 | ENDIF |
---|
| 226 | ; |
---|
| 227 | initncdf, fullfilename |
---|
[5] | 228 | domdef |
---|
[97] | 229 | latin=reform(gphit(0,*)) |
---|
[94] | 230 | lonin=reform(glamt(*,0)) |
---|
[5] | 231 | print, 'lat grid ',min(latin),max(latin),latin(1)-latin(0) |
---|
| 232 | print, 'lon grid ',min(lonin),max(lonin),lonin(1)-lonin(0) |
---|
[81] | 233 | olrin=read_ncdf("olr",19881231, 20091231, file=fullfilename,/nostr) |
---|
[97] | 234 | ; |
---|
| 235 | timein=time |
---|
[94] | 236 | jptin=jpt |
---|
[98] | 237 | mskin=glamt*0.+1. |
---|
[97] | 238 | ; |
---|
[19] | 239 | initncdf, fullfilename_msk |
---|
[5] | 240 | domdef |
---|
[97] | 241 | latout=reform(gphit(0,*)) |
---|
[94] | 242 | lonout=reform(glamt(*,0)) |
---|
[5] | 243 | print, 'lat grid ',min(latout),max(latout),latout(1)-latout(0) |
---|
| 244 | print, 'lon grid ',min(lonout),max(lonout),lonout(1)-lonout(0) |
---|
[19] | 245 | mskout=read_ncdf("msk", file=fullfilename_msk,/nostr) |
---|
[97] | 246 | ; |
---|
[5] | 247 | help, olrin,lonin,latin,mskin,lonout,latout,mskout |
---|
[97] | 248 | ; |
---|
[5] | 249 | olrout=fltarr(jpi,jpj,jptin) |
---|
[97] | 250 | ; |
---|
[5] | 251 | for jt=0,jptin-1 do begin |
---|
[97] | 252 | ; |
---|
[5] | 253 | print, 'Interpolation jt=',jt,' / ',jptin-1 |
---|
| 254 | tab_olr=reform(olrin(*,*,jt)) |
---|
[97] | 255 | ; |
---|
[81] | 256 | olrout(*,*,jt)=call_interp2d(tab_olr,lonin,latin,mskin $ |
---|
| 257 | , lonout,latout,method='bilinear' $ |
---|
| 258 | , OUTMASK_IND=mskout, SET_OUTMSKVAL=mskout) |
---|
[5] | 259 | olrout(*,*,jt)=olrout(*,*,jt)*mskout+(1.-mskout)*1.e20 |
---|
[97] | 260 | ; |
---|
[5] | 261 | endfor |
---|
[97] | 262 | ; |
---|
[5] | 263 | timein=timein-julday(1,1,1950,00,00) |
---|
[97] | 264 | ; |
---|
[5] | 265 | lat=latout |
---|
| 266 | lon=lonout |
---|
[81] | 267 | ncfile='!' + fullfilename_out |
---|
[5] | 268 | lon_attr={units:'degrees_east',long_name:'Longitude'} |
---|
| 269 | lat_attr={units:'degrees_north',long_name:'Latitude'} |
---|
[100] | 270 | time_attr={units:'days since 1950-01-01 00:00:00',long_name:'Time axis',time_origin:'1950-JAN-01 00:00:00'} |
---|
| 271 | globattr={source:'NOAA OLR, cf http://www.cdc.noaa.gov/cdc/data.interp_OLR.html, interpolated to 1x1 degree grid and with oaflux mask'} |
---|
[5] | 272 | olr_attr={units:'w/m^2',missing_value:1e20,long_name:'Outgoing Longwave Radiation',short_name:'olr',axis:'TYX'} |
---|
[97] | 273 | ; |
---|
[5] | 274 | ncfields = 'olr[longitude,latitude,time]=olrout:olr_attr; ' $ |
---|
| 275 | + 'longitude[]=lon:lon_attr; ' $ |
---|
| 276 | + 'latitude[]=lat:lat_attr; ' $ |
---|
| 277 | + 'time[*time]=timein:time_attr ' $ |
---|
| 278 | + ' @ globattr' |
---|
[97] | 279 | ; |
---|
[5] | 280 | @ncdf_quickwrite |
---|
[97] | 281 | ; |
---|
[5] | 282 | end |
---|