;+ ; ; .. _interp_erai_lwr_1989_2009.pro: ; ; ============================= ; interp_erai_lwr_1989_2009.pro ; ============================= ; ; DESCRIPTION ; =========== ; ; Interpolation of str from ERA-I grid to OAFLUX grid ; ; :file:`${PROJECT_ID}/20c3m_erai_str_TROP_1989_2009.nc` containing str from ERA-I have been produced ; by :ref:`compute_erai_daily_region_2d.sh`. ; ; :file:`${PROJECT_ID}/mask_oaflux_30N30S.nc` containing OAFLUX grid have been produced by :ref:`oaflux_mask_30N30S.pro`. ; ; Interpolated str is written in ; :file:`${PROJECT_OD}/erai_lwr_19890101_20091231_oafluxgrid.nc` if this file not already exists. ; ; This output file :file:`${PROJECT_OD}/erai_lwr_19890101_20091231_oafluxgrid.nc` must be processed after by :ref:`lwr_correction_ncdf.pro`. ; ; .. graphviz:: ; ; digraph interp_erai_lwr_1989_2009 { ; graph [ ; rankdir="LR", ; ] ; ; file_in [shape=ellipse,fontname=Courier,label="${PROJECT_ID}/20c3m_erai_str_TROP_1989_2009.nc"]; ; mask [shape=ellipse,fontname=Courier,label="${PROJECT_ID}/mask_oaflux_30N30S.nc"]; ; file_out [shape=ellipse,fontname=Courier,label="${PROJECT_OD}/erai_lwr_19890102_20091231_oafluxgrid.nc"]; ; ; interp_erai_lwr_1989_2009 [shape=box, ; fontname=Courier, ; color=blue, ; URL="http://forge.ipsl.jussieu.fr/tropflux/browser/trunk/src/interp_erai_lwr_1989_2009.pro", ; label="${PROJECT}/src/interp_erai_lwr_1989_2009.pro"]; ; ; {file_in mask} -> {interp_erai_lwr_1989_2009} -> {file_out} ; ; } ; ; SEE ALSO ; ======== ; ; :ref:`project_profile.sh` ; ; :func:`report ` ; :func:`isadirectory ` ; :func:`isafile ` ; :func:`initncdf ` ; :func:`read_ncdf ` ; :func:`domdef ` ; :func:`call_interp2d ` ; :func:`ncdf_quickwrite ` ; ; :ref:`lwr_correction_ncdf.pro` ; ; EXAMPLES ; ======== ; ; :: ; ; IDL> .compile file_interp ; IDL> interp_erai_lwr_1989_2009 ; ; TODO ; ==== ; ; make it work : pb on loholt1 idl8:: ; ; OUTMASK_IND UNDEFINED = ; SET_OUTMSKVAL UNDEFINED = ; ; lwr[longitude,latitude,time]=lwrout:lwr_attr; longitude[]=xlon:lon_attr; latitude[]=ylat:lat_attr; tt[*time]=tt:time_attr @ globattr ; % NCDF_DIMDEF: 0 is not a valid cdfid. ; % Stop encountered: INTERP_ERAI_LWR_1989_2009 1 ; /home/pinsard/tropflux_ws/src/interp_erai_lwr_1989_2009.pro ; ; make it work : pb on loholt1 idl6:: ; ; OUTMASK_IND UNDEFINED = ; SET_OUTMSKVAL UNDEFINED = ; lwr[longitude,latitude,time]=lwrout:lwr_attr; longitude[]=xlon:lon_attr; latitude[]=ylat:lat_attr; tt[*time]=tt:time_attr @ globattr ; % NCDF_VARPUT: Operation Failed, bad file (4) or variable (0) id ? ; (NC_ERROR=-31) ; % Stop encountered: INTERP_ERAI_LWR_1989_2009 1 ; /home/pinsard/tropflux_ws/src/interp_erai_lwr_1989_2009.pro ; ; check OUTMASK_IND and SET_OUTMSKVAL added to call_interp2d call ; ; use real output of :ref:`compute_erai_daily_region_2d.sh`. ; ; 19890101 is not provided in ERA-Intermim file str : a possible workaround is to copy 19890102 ; dataset to 19890101 using nco after this processing. see :ref:`compute_erai_daily_region_2d.sh` ; ; coding rules ; ; KNOWN ISSUES ; ============ ; ; test of existence of fullfilename_msk not very efficient because ; MUST_EXIST keyword of :func:`isafile ` not yet implemented ; ; EVOLUTIONS ; ========== ; ; $Id$ ; ; $URL$ ; ; - pinsard 2011-08-08T16:03:48Z loholt1.ipsl.polytechnique.fr (Linux) ; ; * remove return statement ; ; - fplod 20110808T094156Z cratos (Linux) ; ; * add OUTMASK_IND and SET_OUTMSKVAL to call_interp2d call ; * fix typo ; .. note:: ; ; IDL do not warn when asking size of an undefined array:: ; ; IDL> must_crash=size(ginette) ; ; - pinsard 2011-07-05T07:33:36Z loholt1.ipsl.polytechnique.fr (Linux) ; ; * usage of $PROJECT_ID and $PROJECT_OD ; ; - fplod 20101217T140745Z aedon.locean-ipsl.upmc.fr (Darwin) ; ; * remove hard coded directory for mask_oaflux_30N30S.nc ; ; - fplod 20101215T094137Z aedon.locean-ipsl.upmc.fr (Darwin) ; ; * add graph in header ; ; - fplod 20101214T093615Z aedon.locean-ipsl.upmc.fr (Darwin) ; ; * minimal header ; ; - pbk 2008 ; ; * creation ; ;- pro interp_erai_lwr_1989_2009 ; @cm_4cal @cm_4data @cm_4mesh @cm_4data @cm_project ; ; 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) STOP 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) STOP ENDIF ; ; build mask filename filename_msk='mask_oaflux_30N30S.nc' ; ; check if this file exists 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) STOP ENDIF st=19890101 & en=20090801 ; build data filename filename='20c3m_erai_str_TROP_1989_2009.nc' ; ; check if this file exists 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) STOP ENDIF ; ; test if ${PROJECT_OD} defined CASE project_od_env OF '' : BEGIN msg = 'eee : ${PROJECT_OD} is not defined' ras = report(msg) STOP 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) STOP ENDIF ; ; build output filename filename_out = 'erai_lwr_19890101_20091231_oafluxgrid.nc' fullfilename_out = iodirout + filename_out ; in order to avoid unexpected overwritten IF (FILE_TEST(fullfilename_out) EQ 1) THEN BEGIN msg = 'eee : the file ' + fullfilename_out + ' already exists.' ras = report(msg) STOP ENDIF ; initncdf, fullfilename lwrin=read_ncdf("str",0,7668,/timestep,file=fullfilename,/nostr) lwrin=-1*lwrin 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) timein=time & jptin=jpt tab=lwrin(*,*,0) 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) si=size(lwrin) lwrout=fltarr(jpi,jpj,jptin) for jt=0,jptin-1 do begin print, 'Interpolation jt=',jt,' / ',jptin-1 tab=reform(lwrin(*,*,jt)) lwrout(*,*,jt)=call_interp2d(tab,lonin,latin,mskin $ , lonout,latout,method='bilinear' $ , OUTMASK_IND=mskout, SET_OUTMSKVAL=mskout) help, OUTMASK_IND help, SET_OUTMSKVAL lwrout(*,*,jt)=lwrout(*,*,jt)*mskout+(1.-mskout)*1.e20 endfor time=timegen(7669, start=julday(1,2,1989,0), units='days') & jpt=n_elements(time) tt=time & jptin=jpt cda0=string(jul2date(tt(0)),format='(i8.8)') cda1=string(jul2date(tt(jpt-1)),format='(i8.8)') tt=tt-julday(1,1,1950,00,00,00) xlon=reform(glamt(*,0) ) & ylat=reform(gphit(0,*)) initncdf, fullfilename_msk valmask=1.e20 ylat=latout xlon=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 1950-01-01 00:00:00',long_name:'Time axis',time_origin:' 1950-JAN-01 00:00:00'} lwr_attr={units:'W/m2',missing_value:valmask,long_name:'Surface net longwave radiation ',short_name:'lwr',axis:'TYX'} time_attr={units:'days since 1950-01-01 00:00:00',long_name:'Time axis',time_origin:' 1950-JAN-01 00:00:00'} globattr={source:'Tropical ocean fluxes obtained from ERA Interim',timerange:cda0+' - '+cda1} ncfields = 'lwr[longitude,latitude,time]=lwrout:lwr_attr; ' $ + 'longitude[]=xlon:lon_attr; ' $ + 'latitude[]=ylat:lat_attr; ' $ + 'tt[*time]=tt:time_attr ' $ + ' @ globattr' @ncdf_quickwrite end