;+ ; ; .. _lwr_correction_ncdf.pro: ; ; ======================= ; lwr_correction_ncdf.pro ; ======================= ; ; Correction of lwr on OAFLUX grid ; ; :file:`${PROJECT_OD}/erai_lwr_19890101_20091231_oafluxgrid.nc` have been ; produced by :ref:`interp_erai_lwr_1989_2009.pro`. ; ; Corrected lwr on OAFLUX grid is written in ; :file:`${PROJECT_OD}/TropFlux_lwr_19890101_20091231.nc` ; if this file not already exists. ; ; This file will be used by :ref:`TropFlux_19890101_20091231.pro`. ; ; .. graphviz:: ; ; digraph lwr_correction_ncdf { ; graph [ ; rankdir="LR", ; ] ; ; file_in [shape=ellipse,fontname=Courier,label="${PROJECT_OD}/erai_lwr_19890101_20091231_oafluxgrid.nc"]; ; file_out [shape=ellipse,fontname=Courier,label="${PROJECT_OD}/TropFlux_lwr_19890101_20091231.nc"]; ; ; lwr_correction_ncdf [shape=box, ; fontname=Courier, ; color=blue, ; URL="http://forge.ipsl.jussieu.fr/tropflux/browser/trunk/src/lwr_correction_ncdf.pro", ; label="${PROJECT}/src/lwr_correction_ncdf.pro"]; ; ; {file_in} -> {lwr_correction_ncdf} -> {file_out} ; ; } ; ; SEE ALSO ; ======== ; ; :ref:`project_profile.sh` ; ; :ref:`mooring_corrections` ; ; :ref:`interp_erai_lwr_1989_2009.pro` ; ; :func:`initncdf ` ; :func:`read_ncdf ` ; :func:`grossemoyenne ` ; :func:`julday ` ; :func:`caldat ` ; :func:`ncdf_quickwrite ` ; ; EXAMPLES ; ======== ; ; :: ; ; IDL> lwr_correction_ncdf ; ; TODO ; ==== ; ; coding rules ; ; lwr long name 'Air Temperature at 2m" : ??? ; ; 19890101 is not provided in ERA-Intermim file str : a possible workaround is ; to copy 19890102 ; dataset to 19890101 using nco before processing. ; ; here is the sequence used by pk wher erai_lwr_19890102_20091231_oafluxgrid.nc is the regridded (interpolated output) ; ; $ ncks -d time,0,0 erai_lwr_19890102_20091231_oafluxgrid.nc erai_lwr_step0.nc ; ; This will combine the two files :: ; ; $ ncrcat erai_lwr_step0.nc erai_lwr_19890102_20091231_oafluxgrid.nc erai_lwr_19890101_20091231_oafluxgrid.nc. ; ; must be put in a shell script or find IDL equivalent ; ; here I (fp) replace hard coded date 19890102 by 19890101. must check ; consistency with this module and interp_erai_lwr_1989_2009.pro. ; ; KNOWN ISSUES ; ============ ; ; test of existence of fullfilename_in not very efficient because ; MUST_EXIST keyword of :func:`isafile ` not yet implemented ; ; EVOLUTIONS ; ========== ; ; $Id$ ; ; $URL$ ; ; - fplod 20110808T120234Z cratos (Linux) ; ; * usage of ${PROJECT_OD} ; * complete description ; * replace erai_lwr_19890102_20091231_oafluxgrid.nc by erai_lwr_19890101_20091231 ; * remove v1 in output filename ; ; - fplod 20101215T113707Z aedon.locean-ipsl.upmc.fr (Darwin) ; ; * add graph in header ; ; - fplod 20101214T093615Z aedon.locean-ipsl.upmc.fr (Darwin) ; ; * minimal header ; ; - pbk 2008 ; ; * creation ; ;- pro lwr_correction_ncdf ; @cm_4cal @cm_4data @cm_4mesh @cm_4data @cm_project ; ; 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 for reading IF (FILE_TEST(iodirout, /DIRECTORY, /EXECUTABLE, /READ) EQ 0) THEN BEGIN msg = 'eee : the directory' + iodirout + ' is not accessible.' ras = report(msg) STOP ENDIF ; ; existence and protection for writing IF (FILE_TEST(iodirout, /DIRECTORY, /WRITE) EQ 0) THEN BEGIN msg = 'eee : the directory' + iodirout + ' was not found.' ras = report(msg) STOP ENDIF ; da1=19880101 & da2=20091231 ; ; build data filename filename='erai_lwr_19890101_20091231_oafluxgrid.nc' ; ; check if this file exists fullfilename = isafile(iodirout + filename, NEW=0, /MUST_EXIST) IF fullfilename[0] EQ '' THEN BEGIN msg = 'eee : the file ' + fullfilename + ' was not found.' ras = report(msg) STOP ENDIF ; ; build output filename filename_out = 'TropFlux_lwr_19890101_20091231.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 lwr=read_ncdf('lwr',da1,da2,file=fullfilename,/nostr) help, lwr ; lwr_mean=grossemoyenne(lwr,'t',/nan) help,lwr_mean tt=time & jpt=n_elements(time) caldat, time,mon,day,yea lwr_m=lwr*0. for jt=0,jpt-1 do begin jtt=(time(jt)-julday(1,1,yea(jt))) < 364 t=reform(lwr_mean(*,*)) lwr_m(*,*,jt)=t endfor help, lwr_m lwr_ano=lwr-lwr_m ;; correction for mean based on scatter lwr_m=lwr_m+4.61667 help, lwr_ano ;; applying the correction for varyability based on the scatter lwr_ano=lwr_ano*(1/0.760667) ;; applying the correction for varyability based on the scatter lwr_new=lwr_m+lwr_ano help, lwr_new ;writing field lat=reform(gphit(0,0:jpj-1)) lon=reform(glamt(0:jpi-1,0)) time=timegen(7669, units='days', start=julday(1,2,1989)) & jpt=n_elements(time) cda0=string(jul2date(time(0)),format='(i8.8)') cda1=string(jul2date(time(jpt-1)),format='(i8.8)') time=time-julday(1,1,1950) & jpt=n_elements(time) 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:'degK',missing_value:1.e20,long_name:'Air Temperature at 2m',short_name:'lwr',axis:'TYX'} globattr={source:'Basic data obtained from ERAI. Mean correction for bias and correction for variability are applied',timerange:cda0+' - '+cda1} ncfields = 'lwr[longitude,latitude,time]=lwr_new:lwr_attr; ' $ + 'longitude[]=lon:lon_attr; ' $ + 'latitude[]=lat:lat_attr; ' $ + 'time[*time]=time:time_attr ' $ + ' @ globattr' @ncdf_quickwrite end