;+ ; ; ===================== ; interp_olr_30n30s.pro ; ===================== ; ; .. function:: interp_olr_30n30s(yyyymmddb,yyyymmdde) ; ; DESCRIPTION ; =========== ; ; Interpolation of OLR to OAFLUX grid ; ; :file:`${PROJECT_ID}/olr.day.mean.nc` ; have been produced by ; :ref:`get_olr.sh` ; ; :file:`${PROJECT_ID}/mask_oaflux_30N30S.nc` containing OAFLUX grid ; have been produced by ; :func:`oaflux_mask_30n30s`. ; ; Interpolated OLR is written in ; :file:`${PROJECT_OD}/${PROJECT_OD}/olr_oafluxgrid_30n30s_{yyyymmdd}_{yyyymmdd}.nc` ; if this file not already exists. ; ; This output file will be used by ; :func:`tropflux_swr_nrt`. ; ; .. graphviz:: ; ; digraph interp_olr_30n30s{ ; ; file_in [shape=ellipse, ; fontname=Courier, ; label="${PROJECT_ID}/olr.day.mean_new.nc"]; ; mask [shape=ellipse, ; fontname=Courier, ; label="${PROJECT_ID}/mask_oaflux_30N30S.nc"]; ; file_out [shape=ellipse, ; fontname=Courier, ; label="${PROJECT_OD}/olr_oafluxgrid_30n30s_{yyyymmdd}_{yyyymmdd}.nc"]; ; ; interp_olr_30n30s [shape=box, ; fontname=Courier, ; color=blue, ; URL="http://forge.ipsl.jussieu.fr/tropflux/browser/trunk/src/interp_olr_30n30s.pro", ; label="${PROJECT}/src/interp_olr_30n30s.pro"]; ; ; {file_in mask} -> {interp_olr_30n30s} -> {file_out} ; ; } ; ; SEE ALSO ; ======== ; ; :ref:`interpolate_data` ; ; Used by :ref:`tropflux.sh` ; ; :ref:`project_profile.sh` ; ; :ref:`data_in_olr`, :ref:`get_olr.sh` ; ; :func:`report ` ; :func:`isadirectory ` ; :func:`isafile ` ; :func:`initncdf ` ; :func:`read_ncdf ` ; :func:`domdef ` ; :func:`call_interp2d ` ; :func:`ncdf_quickwrite ` ; ; EXAMPLES ; ======== ; ; .. code-block:: idl ; ; .compile file_interp ; yyyymmddb = 20000101L ; yyyymmdde = 20001231L ; result = interp_olr_30n30s(yyyymmddb, yyyymmdde) ; print, result ; ; TODO ; ==== ; ; hard coded attributes for time origin ; ; how can we avoid this message : ; ; .. parsed-literal:: ; ; % initncdf: the zaxis was not found..., check the use of ZAXISNAME keyword if you want to find one... ; ; I think we do not need any zaxis ; ; strange second value [1] in the file produced on cratos idl 7 20110812: ; ; .. code-block:: bash ; ; ncdump $PROJECT_OD/olr_oafluxgrid_30n30s_19890101_20091231.nc ; ; .. parsed-literal:: ; ; olr = ; 1e+20, 1, 258.15, 264.882, 271.614, 273.8116, 271.4748, 269.138, 266.6868, ; ; coding rules ; ; check OUTMASK_IND and SET_OUTMSKVAL added to call_interp2d call ; ; pb with mixing interpolated and uninterpolated OLR data ; check if the input file is the right one (interpolated with get_olr.sh vs ; non interpolated with get_olr_int.sh) ; ; uninterpolated OLR is more timely ; ; cf. pk and jv to solve this issue ; ; KNOWN ISSUES ; ============ ; ; test of existence of fullfilename_msk not very efficient because ; MUST_EXIST keyword of :func:`isafile ` not yet implemented ; ; EVOLUTIONS ; ========== ; ; $Id: interp_olr_30n30s.pro 88 2011-08-19 15:40:14Z pinsard $ ; ; $URL$ ; ; - fplod 20120321 ; ; * add timerange in global attributes ; * change time origin 1950 -> 1957 to homogenize wih others fields ; ; - fplod 20120320 ; ; * taking project_overwrite into account ; * try to add compile_opt seems to be incompatible with ncdf_quickwrite ; * pro -> function ; ; - fplod 20110812T084449Z aedon.locean-ipsl.upmc.fr (Darwin) ; ; * remove new from filename ; * usage of $PROJECT_ID and $PROJECT_OD ; * add OUTMASK_IND and SET_OUTMSKVAL to call_interp2d call ; * complete description ; ; - fplod 20101217T140745Z aedon.locean-ipsl.upmc.fr (Darwin) ; ; * remove hard coded directory for mask_oaflux_30N30S.nc ; ; - fplod 20101215T113118Z aedon.locean-ipsl.upmc.fr (Darwin) ; ; * add graph in header ; ; - fplod 20101214T093615Z aedon.locean-ipsl.upmc.fr (Darwin) ; ; * minimal header ; ; - pbk 2008 ; ; * creation ; ;- function interp_olr_30n30s $ , yyyymmddb $ , yyyymmdde ; ;++compile_opt idl2, strictarrsubs, logical_predicate ; @cm_4cal @cm_4data @cm_4mesh @cm_4data @cm_project ; ; Return to caller if errors ON_ERROR, 2 ; result = -1 ; usage = 'result = interp_olr_30n30s(yyyymmddb, yyyymmdde)' nparam = N_PARAMS() IF (nparam NE 2) THEN BEGIN ras = report(['Incorrect number of arguments.' $ + '!C' $ + 'Usage : ' + usage]) return, result ENDIF ; ; check for input directory ; ; test if ${PROJECT_ID} defined CASE project_id_env OF '' : BEGIN msg = 'eee : ${PROJECT_ID} is not defined' ras = report(msg) return, result END ELSE : BEGIN msg = 'iii : ${PROJECT_ID} is ' + project_id_env ras = report(msg) END ENDCASE ; iodirin = isadirectory(project_id_env) ; ; existence and protection of ${PROJECT_ID} IF (FILE_TEST(iodirin, /DIRECTORY, /EXECUTABLE, /READ) EQ 0) THEN BEGIN msg = 'eee : the directory' + iodirin + ' is not accessible.' ras = report(msg) return, result ENDIF ; ; build mask filename filename_msk='mask_oaflux_30N30S.nc' ; ; check if this file exists msg='iii : looking for ' + filename_msk ras = report(msg) fullfilename_msk = isafile(iodirin + filename_msk, NEW=0, /MUST_EXIST) IF fullfilename_msk[0] EQ '' THEN BEGIN msg = 'eee : the file ' + fullfilename_msk + ' was not found.' ras = report(msg) return, result ENDIF ; ; build data filename filename='olr.day.mean.nc' ; ; check if this file exists msg='iii : looking for ' + filename ras = report(msg) fullfilename = isafile(iodirin + filename, NEW=0, /MUST_EXIST) IF fullfilename[0] EQ '' THEN BEGIN msg = 'eee : the file ' + fullfilename + ' was not found.' ras = report(msg) return, result ENDIF ; ; test if ${PROJECT_OD} defined CASE project_od_env OF '' : BEGIN msg = 'eee : ${PROJECT_OD} is not defined' ras = report(msg) return, result END ELSE : BEGIN msg = 'iii : ${PROJECT_OD} is ' + project_od_env ras = report(msg) END ENDCASE ; ; check if output data will be possible iodirout = isadirectory(project_od_env) ; ; existence and protection IF (FILE_TEST(iodirout, /DIRECTORY, /WRITE) EQ 0) THEN BEGIN msg = 'eee : the directory' + iodirout + ' was not found.' ras = report(msg) return, result ENDIF ; ; build output filename filename_out = 'olr_oafluxgrid_30n30s_' + string(yyyymmddb,format='(I8.8)') + '_' + string(yyyymmdde,format='(I8.8)') +'.nc' fullfilename_out = iodirout + filename_out ; in order to avoid unexpected overwritten IF ((FILE_TEST(fullfilename_out) EQ 1) AND (project_overwrite EQ 0)) THEN BEGIN msg = 'eee : the file ' + fullfilename_out + ' already exists.' ras = report(msg) return, result ENDIF ; initncdf, fullfilename domdef latin=reform(gphit[0,*]) lonin=reform(glamt[*,0]) print, 'lat grid ',min(latin),max(latin),latin[1]-latin[0] print, 'lon grid ',min(lonin),max(lonin),lonin[1]-lonin[0] olrin=read_ncdf("olr",yyyymmddb-.5d,yyyymmdde, file=fullfilename,/nostr) ; timein=24.d*(time-julday(1,1,1957,0,0,0)) jptin=n_elements(timein) da=jul2date(time[0]) cda0=string(da,format='(i8.8)') da=jul2date(time[jptin-1]) cda1=string(da,format='(i8.8)') print, 'olr first date ', cda0 print, 'olr last date ' , cda1 mskin=glamt*0.+1. ; initncdf, fullfilename_msk domdef latout=reform(gphit[0,*]) lonout=reform(glamt[*,0]) print, 'lat grid ',min(latout),max(latout),latout[1]-latout[0] print, 'lon grid ',min(lonout),max(lonout),lonout[1]-lonout[0] mskout=read_ncdf("msk", file=fullfilename_msk,/nostr) ; help, olrin,lonin,latin,mskin,lonout,latout,mskout ; olrout=fltarr(jpi,jpj,jptin) ; for jt=0,jptin-1 do begin ; print, 'Interpolation jt=',jt,' / ',jptin-1 tab_olr=reform(olrin[*,*,jt]) ; olrout[*,*,jt]=call_interp2d(tab_olr,lonin,latin,mskin $ , lonout,latout,method='bilinear' $ , OUTMASK_IND=mskout, SET_OUTMSKVAL=mskout) olrout[*,*,jt]=olrout[*,*,jt]*mskout+(1.-mskout)*1.e20 ; endfor ; lat=latout lon=lonout ncfile='!' + fullfilename_out lon_attr={units:'degrees_east',long_name:'Longitude'} lat_attr={units:'degrees_north',long_name:'Latitude'} time_attr={units:'days since 1957-01-01 00:00:00',long_name:'Time axis',time_origin:'1957-JAN-01 00:00:00'} globattr={source:'NOAA OLR, cf http://www.cdc.noaa.gov/cdc/data.interp_OLR.html, interpolated to 1x1 degree grid and with oaflux mask', timerange:cda0+' - '+cda1} olr_attr={units:'w/m^2',missing_value:1e20,long_name:'Outgoing Longwave Radiation',short_name:'olr',axis:'TYX'} ; ncfields = 'olr[longitude,latitude,time]=olrout:olr_attr; ' $ + 'longitude[]=lon:lon_attr; ' $ + 'latitude[]=lat:lat_attr; ' $ + 'time[*time]=timein:time_attr ' $ + ' @ globattr' ; @ncdf_quickwrite ; result = 0 return, result ; end