;+ ; ; ====================== ; ws_correction_ncdf.pro ; ====================== ; ; .. function:: ws_correction_ncdf(yyyymmddb,yyyymmdde) ; ; DESCRIPTION ; =========== ; ; Correction of ws on OAFLUX grid ; ; :file:`${PROJECT_OD}/erai_ws_{yyyymmdd}_{yyyymmdd}_oafluxgrid.nc` ; containing ; ++ ; have been produced by ; :func:`interp_erai_ws`. ; ; Corrected ws on OAFLUX grid ; is written in ; :file:`${PROJECT_OD}/TropFlux_ws_{yyyymmdd}_{yyyymmdd}.nc` ; if this file not already exists. ; ; This output file ; :file:`${PROJECT_OD}/TropFlux_ws_{yyyymmdd}_{yyyymmdd}.nc` ; will be used by ; :func:`tropflux`. ; ; .. only:: man ; ; Figure is visible on PDF and HTML documents only. ; ; .. only:: html or latex ; ; .. graphviz:: ; ; digraph ws_correction_ncdf { ; ; file_in [shape=ellipse, ; fontname=Courier, ; label="${PROJECT_OD}/erai_ws_{yyyymmdd}_{yyyymmdd}_oafluxgrid.nc"]; ; file_out [shape=ellipse, ; fontname=Courier, ; label="${PROJECT_OD}/TropFlux_ws_{yyyymmdd}_{yyyymmdd}.nc"]; ; ; ws_correction_ncdf [shape=box, ; fontname=Courier, ; color=blue, ; URL="http://forge.ipsl.jussieu.fr/tropflux/browser/trunk/src/ws_correction_ncdf.pro", ; label="${PROJECT}/src/ws_correction_ncdf.pro"]; ; ; {file_in} -> {ws_correction_ncdf} -> {file_out} ; ; } ; ; SEE ALSO ; ======== ; ; :ref:`mooring_corrections` ; ; Used by :ref:`tropflux.sh` ; ; :ref:`project_profile.sh` ; ; :func:`interp_erai_ws` ; ; :func:`initncdf ` ; :func:`read_ncdf ` ; :func:`grossemoyenne ` ; :func:`julday ` ; :func:`caldat ` ; :func:`ncdf_quickwrite ` ; ; EXAMPLES ; ======== ; ; .. code-block:: idl ; ; yyyymmddb = 20000101L ; yyyymmdde = 20001231L ; result = ws_correction_ncdf(yyyymmddb, yyyymmdde) ; print, result ; ; TODO ; ==== ; ; coding rules ; ; hard coded correction ; ; KNOWN ISSUES ; ============ ; ; test of existence of fullfilename_in not very efficient because ; MUST_EXIST keyword of :func:`isafile ` not yet implemented ; ; EVOLUTIONS ; ========== ; ; $Id: ws_correction_ncdf.pro 88 2011-08-19 15:40:14Z pinsard $ ; ; $URL$ ; ; - fplod 20120322 ; ; * taking project_overwrite into account ; * try to add compile_opt seems to be incompatible with ncdf_quickwrite ; * pro -> function ; * hard coded da1 and da2 replaced by yyyymmddb and yyyymmdde parameters ; * get rid of timegen ; ; - fplod 20110808T131954Z aedon.locean-ipsl.upmc.fr (Darwin) ; ; * usage of ${PROJECT_OD} ; * complete description ; * remove v20 in output filename ; ; - fplod 20101215T115916Z aedon.locean-ipsl.upmc.fr (Darwin) ; ; * add graph in header ; ; - fplod 20101214T093615Z aedon.locean-ipsl.upmc.fr (Darwin) ; ; * minimal header ; ; - pbk 2008 ; ; * creation ; ;- function ws_correction_ncdf $ , yyyymmddb $ , yyyymmdde ; ;++compile_opt idl2, strictarrsubs, logical_predicate ; @cm_4data @cm_4mesh @cm_4data @cm_project ; ; Return to caller if errors ON_ERROR, 2 ; result = -1 ; usage = 'result = ws_correction_ncdf(yyyymmddb, yyyymmdde)' nparam = N_PARAMS() IF (nparam NE 2) THEN BEGIN ras = report(['Incorrect number of arguments.' $ + '!C' $ + 'Usage : ' + usage]) return, result ENDIF ; @cm_4cal ; 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 for reading IF (FILE_TEST(iodirout, /DIRECTORY, /EXECUTABLE, /READ) EQ 0) THEN BEGIN msg = 'eee : the directory' + iodirout + ' is not accessible.' ras = report(msg) return, result 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) return, result ENDIF ; ; build data filename filename='erai_ws_' $ + string(yyyymmddb,format='(i8.8)') $ + '_' $ + string(yyyymmdde,format='(i8.8)') $ + '_oafluxgrid.nc' ; ; check if this file exists msg='iii : looking for ' + filename ras = report(msg) 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) return, result ENDIF ; ; build output filename filename_out = 'TropFlux_ws_' $ + 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 u=read_ncdf('u10',yyyymmddb-.5d,yyyymmdde,file=fullfilename,/nostr) timein=24.d*(time-julday(1,1,1957,0,0,0)) jpt=n_elements(timein) da=jul2date(time[0]) cda0=string(da,format='(i8.8)') da=jul2date(time[jpt-1]) cda1=string(da,format='(i8.8)') print, 'u10 in ws_correction_ncdf first date ', cda0 print, 'u10 in ws_correction_ncdf last date ' , cda1 ; v=read_ncdf('v10',yyyymmddb-.5d,yyyymmdde,file=fullfilename,/nostr) timein=24.d*(time-julday(1,1,1957,0,0,0)) jpt=n_elements(timein) da=jul2date(time[0]) cda0=string(da,format='(i8.8)') da=jul2date(time[jpt-1]) cda1=string(da,format='(i8.8)') print, 'v10 in ws_correction_ncdf first date ', cda0 print, 'v10 in ws_correction_ncdf last date ' , cda1 ; w=sqrt(u*u+v*v) ; help, w ; w_mean=grossemoyenne(w,'t',/nan) help, w_mean ; jpt=n_elements(time) caldat, time,mon,day,yea w_m=w*0. ; for jt=0,jpt-1 do begin jtt=(time[jt]-julday(1,1,yea[jt])) < 364 q=reform(w_mean[*,*]) w_m[*,*,jt]=q endfor help, w_m ; w_ano=w-w_m ; ; correction for mean based on scatter ;w_m=w_m+0.282667 ; (2000-2008) w_m=w_m+0.276739 ; (2000-2009) ; help, w_ano ; ; applying the correction for variability based on the scatter ;w_ano=w_ano*(1/0.897667) ; (2000-2008) w_ano=w_ano*(1/0.903587) ; (2000-2009) ; w_new=w_m+w_ano help, w_new ; ;writing field lat=reform(gphit[0,0:jpj-1]) lon=reform(glamt[0:jpi-1,0]) ; 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'} globattr={source:'Basic data obtained from ERAI. Bias and variability correction are applied',timerange:cda0+' - '+cda1} w_attr={units:'m/s',missing_value:1.e20,long_name:'mean wind speed',short_name:'w',axis:'TYX'} ; ncfields = 'ws[longitude,latitude,*time]=w_new:w_attr; ' $ + 'longitude[]=lon:lon_attr; ' $ + 'latitude[]=lat:lat_attr; ' $ + 'time[]=timein:time_attr ' $ + ' @ globattr' ; @ncdf_quickwrite ; result = 0 return, result ; end