;+ ; ; ========================= ; cronin_gustiness_ncdf.pro ; ========================= ; ; .. function:: cronin_gustiness_ncdf(yyyymmddb,yyyymmdde) ; ; DESCRIPTION ; =========== ; ; Cronin gustiness correction on corrected sst on OAFLUX grid ; ; :file:`${PROJECT_OD}/TropFlux_sst_19890101_20091231.nc` have been produced by ; :func:`sst_correction_ncdf`. ; ; Cronin gustiness corrected ++ on corrected sst on OAFLUX grid ; is written in ; :file:`${PROJECT_OD}/TropFlux_gustiness_{yyyymmdd}_{yyyymmdd}.nc` ; if this file not already exists. ; ; This file will be used by ; :func:`tropflux_swr_blnd` ; and ; :func:`tropflux`. ; ; .. graphviz:: ; ; digraph cronin_gustiness_ncdf { ; ; file_in [shape=ellipse, ; fontname=Courier, ; label="${PROJECT_OD}/TropFlux_sst_19890101_20091231.nc"]; ; file_out [shape=ellipse,fontname=Courier,label="${PROJECT_OD}/TropFlux_gustiness_{yyyymmdd}_{yyyymmdd}.nc"]; ; ; cronin_gustiness_ncdf [shape=box, ; fontname=Courier, ; color=blue, ; URL="http://forge.ipsl.jussieu.fr/tropflux/browser/trunk/src/cronin_gustiness_ncdf.pro", ; label="${PROJECT}/src/cronin_gustiness_ncdf.pro"]; ; ; {file_in} -> {cronin_gustiness_ncdf} -> {file_out} ; } ; ; EXAMPLES ; ======== ; ; .. code-block:: idl ; ; yyyymmddb = 20000101L ; yyyymmdde = 20001231L ; result = cronin_gustiness_ncdf(yyyymmddb, yyyymmdde) ; print, result ; ; SEE ALSO ; ======== ; ; :ref:`project_profile.sh` ; ; :ref:`mooring_corrections` ; ; :func:`sst_correction_ncdf`. ; ; :func:`initncdf ` ; :func:`julday ` ; :func:`ncdf_quickwrite ` ; ; TODO ; ==== ; ; going on time parametrization ; ; coding rules ; ; why da1=19880101 and da2=20101231 ? should be 19890101 and 20091231 or better ; deduce from reading sst ; ; 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 20120321 ; ; * pro -> func ; * taking project_overwrite into account ; ; - fplod 20110830T140029Z cratos (Linux) ; ; * replace tt by time ; ; - fplod 20110808T144208Z aedon.locean-ipsl.upmc.fr (Darwin) ; ; * usage of ${PROJECT_OD} ; * complete description ; * remove v50 in output filename ; * remove return statement ; ; - fplod 20101215T092619Z aedon.locean-ipsl.upmc.fr (Darwin) ; ; * add graph in header ; ; - fplod 20101214T093615Z aedon.locean-ipsl.upmc.fr (Darwin) ; ; * minimal header ; ; - pbk 2008 ; ; * creation ; ;- function cronin_gustiness_ncdf $ , 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 = tropflux_swr_nrt(yyyymmddb, yyyymmdde)' nparam = N_PARAMS() IF (nparam NE 2) THEN BEGIN ras = report(['Incorrect number of arguments.' $ + '!C' $ + 'Usage : ' + usage]) 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 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 ; da1=19880101 da2=20101231 ; ; build data filename filename='TropFlux_sst_19890101_20091231.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) return, result ENDIF ; ; build output filename filename_out = 'TropFlux_gustiness' + 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 sst=read_ncdf('sst',da1,da2,file=fullfilename,/nostr) sst=reform(sst-273.15) help, sst ; sst_clim=grossemoyenne(sst, 't',/nan) ;wg=0.175*sst_clim-3.17 ; line fit obtained from the scatter (Cronin gustiness Vs ERAI SST) ;help, wg ; jpt=n_elements(time) ; wg_tot=sst*0. for jt=0, jpt-1 do begin wg_tot(*,*,jt)=(((sst_clim(*,*)-23.7)*2.1/(29.8-23.7)) > 1.) <2.1 endfor help, wg_tot ; ; writing field time=timegen(7670, start=julday(1,1,1989,0), units='days') 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,00,00,00) xlon=reform(glamt(*,0) ) ylat=reform(gphit(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'} gust_attr={units:'m/s',missing_value:valmask,long_name:'Climatological gustiness',short_name:'wg',axis:'TYX'} globattr={source:'Climatological wind gustiness obtained by fitting cronins gustiness values against sst ',timerange:cda0+' - '+cda1} ; ncfields = 'wg[longitude,latitude,time]=wg_tot:gust_attr; ' $ + 'longitude[]=xlon:lon_attr; ' $ + 'latitude[]=ylat:lat_attr; ' $ + 'time[*time]=time:time_attr ' $ + ' @ globattr' ; @ncdf_quickwrite ; result = 0 return, result ; end