;+ ; ; .. _ws_tropflux_1d_to_1m_ncdf.pro: ; ; ============================= ; ws_tropflux_1d_to_1m_ncdf.pro ; ============================= ; ; DESCRIPTION ; =========== ; ; convert wind daily file to monthly file ; ; :file:`${PROJECT_OD}/ws_tropflux_1d_1989_2010.nc` ; containing daily ++ ; has been produced by ++ ; ; Monthly ++ ; is written in ; :file:`${PROJECT_OD}/ws_tropflux_1m_1989_2010.nc` ; if this file not already exists. ; ; .. graphviz:: ; ; digraph ws_tropflux_1d_to_1m_ncdf { ; ; file_1d [shape=ellipse,fontname=Courier,label="${PROJECT_OD}/ws_tropflux_1d_1989_2010.nc"]; ; file_1m [shape=ellipse,fontname=Courier,label="${PROJECT_OD}/ws_tropflux_1m_1989_2010.nc"]; ; ; ws_tropflux_1d_to_1m_ncdf [shape=box, ; fontname=Courier, ; color=blue, ; URL="http://forge.ipsl.jussieu.fr/tropflux/browser/trunk/src/ws_tropflux_1d_to_1m_ncdf.pro", ; label="${PROJECT}/src/ws_tropflux_1d_to_1m_ncdf.pro"]; ; ; {file_1d} -> {ws_tropflux_1d_to_1m_ncdf} -> {file_1m} ; ; } ; ; SEE ALSO ; ======== ; ; :ref:`project_profile.sh` ; ; EXAMPLES ; ======== ; ; .. code-block:: idl ; ; ws_tropflux_1d_to_1m_ncdf ; ; KNOWN ISSUES ; ============ ; ; test of existence of fullfilename_in not very efficient because ; MUST_EXIST keyword of :func:`isafile ` not yet implemented ; ; TODO ; ==== ; ; coding rules ; ; get rid of hard coded yyyymmdd and nb month ; ; include in the whole process ; ; any NCO or CDO equivalent ? ; ; EVOLUTIONS ; ========== ; ; $Id$ ; ; $URL$ ; ; - fplod 20110826T151225Z aedon.locean-ipsl.upmc.fr (Darwin) ; ; * remove hard coded creation date ; ; - fplod 20110817T084001Z aedon.locean-ipsl.upmc.fr (Darwin) ; ; * usage of ${PROJECT_OD} ; * header ; ; - pk 20110815 ; ; * provided to fp ; ;- pro ws_tropflux_1d_to_1m_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 ; ; build 1d filename filename="ws_tropflux_1d_1989_2010.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) STOP ENDIF ; ; build output filename filename_out = 'ws_tropflux_1m_1989_2010.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 st=19890101 en=20101231 ws=read_ncdf("ws", st, en, file=fullfilename,/nostr) ; help, ws ; ; Monthly data ; jpt=22*12. time=timegen(jpt, start=julday(1,15,1989,0), units='Months') caldat, time, m, d, y caldat, time, mon, day, yea ; wsm=fltarr(nxt,nyt,jpt) ; for jt=0,jpt-1 do begin ; ind=where((m eq mon(jt)) and (y eq yea(jt))) wsm(*,*,jt)=total(ws(*,*,ind),3)/n_elements(ind) ; endfor ; ;----------------------------------------------------------------------------- cda0=string(jul2date(time(0)),format='(i8.8)') cda1=string(jul2date(time(jpt-1)),format='(i8.8)') time=time-julday(1,1,1950,00,00,00) xlon=reform(glamt(firstxt:lastxt,0)) ylat=reform(gphit(0,firstyt:lastyt)) ; 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'} ws_attr={units:'m/s',missing_value:1.e20,long_name:'Mean wind speed at 10m height',short_name:'ws',axis:'TYX'} ; creation_date=string(jul2date(SYSTIME( /JULIAN , /UTC )), format='(I8)') ; globattr={Source:'TropFlux - Air-Sea Fluxes for the Global Tropics' $ , Methodology:'Praveen Kumar et al., Clim. Dyn 2011' $ , Producer_Agency:'Joint research collaboration between IPSL, Paris and NIO, India' $ , Time_range:cda0+' - '+cda1 $ , Creation_date:creation_date $ , Website:'http://www.locean-ipsl.upmc.fr/tropflux/'} ; ncfields = 'ws[longitude,latitude,time]=wsm:ws_attr; ' $ + 'longitude[]=xlon:lon_attr; ' $ + 'latitude[]=ylat:lat_attr; ' $ + 'time[*time]=time:time_attr ' $ + ' @ globattr' ; @ncdf_quickwrite ; end