;+ ; ; .. _q2m_correction_ncdf.pro: ; ; ======================= ; q2m_correction_ncdf.pro ; ======================= ; ; DESCRIPTION ; =========== ; ; Correction of q2m on OAFLUX grid ; ; :file:`${PROJECT_OD}/erai_q2m_19890101_20091231_oafluxgrid.nc` have been ; produced by :ref:`d2m_to_q2m_erai.pro`. ; ; Corrected q2m on OAFLUX grid is written in ; :file:`${PROJECT_OD}/TropFlux_q2m_19890101_20091231.nc` ; if this file not already exists. ; ; This file will be used by :ref:`TropFlux_19890101_20091231.pro`. ; ; .. graphviz:: ; ; digraph q2m_correction_ncdf { ; ; file_in [shape=ellipse,fontname=Courier,label="${PROJECT_OD}/erai_q2m_19890101_20091231_oafluxgrid.nc"]; ; file_out [shape=ellipse,fontname=Courier,label="${PROJECT_OD}/TropFlux_q2m_19890101_20091231.nc"]; ; ; q2m_correction_ncdf [shape=box, ; fontname=Courier, ; color=blue, ; URL="http://forge.ipsl.jussieu.fr/tropflux/browser/trunk/src/q2m_correction_ncdf.pro", ; label="${PROJECT}/src/q2m_correction_ncdf.pro"]; ; ; {file_in} -> {q2m_correction_ncdf} -> {file_out} ; ; } ; ; SEE ALSO ; ======== ; ; :ref:`project_profile.sh` ; ; :ref:`mooring_corrections` ; ; :ref:`d2m_to_q2m_erai.pro` ; ; :func:`initncdf ` ; :func:`read_ncdf ` ; :func:`grossemoyenne ` ; :func:`julday ` ; :func:`ncdf_quickwrite ` ; ; EXAMPLES ; ======== ; ; :: ; ; IDL> q2m_correction_ncdf ; ; TODO ; ==== ; ; work on cratos idl7 even if NaNf values in erai_q2m_19890101_20091231_oafluxgrid.nc written by ; d2m_to_q2m.pro. ; ; No way ... NaNf also in this output !! ; ; coding rules ; ; EVOLUTIONS ; ========== ; ; $Id$ ; ; $URL$ ; ; - fplod 20110808T143129Z aedon.locean-ipsl.upmc.fr (Darwin) ; ; * usage of ${PROJECT_OD} ; * remove v20 in output filename ; ; - fplod 20101215T113945Z aedon.locean-ipsl.upmc.fr (Darwin) ; ; * add graph in header ; ; - fplod 20101214T093615Z aedon.locean-ipsl.upmc.fr (Darwin) ; ; * minimal header ; ; - pbk 2008 ; ; * creation ; ;- pro q2m_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=20101231 ; ; build data filename filename='erai_q2m_19890101_20091231_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) STOP ENDIF ; ; build output filename filename_out = 'TropFlux_q2m_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 q2m=read_ncdf('q2m',da1,da2,file=fullfilename,/nostr) help, q2m q2m_mean=grossemoyenne(q2m,'t',/nan) help, q2m_mean tt=time & jpt=n_elements(time) caldat, time,mon,day,yea q2m_m=q2m*0. for jt=0,jpt-1 do begin jtt=(time(jt)-julday(1,1,yea(jt))) < 364 q=reform(q2m_mean(*,*)) q2m_m(*,*,jt)=q endfor help, q2m_m q2m_ano=q2m-q2m_m ;; correction for mean based on scatter ;q2m_m=q2m_m+0.815445 ;; (2000-2008) q2m_m=q2m_m+0.792717 ;; (2000-2009) help, q2m_ano ;; applying the correction for variability based on the scatter ;q2m_ano=q2m_ano*(1/0.919333) ;; (2000-2008) q2m_ano=q2m_ano*(1/0.924674) ;; (2000-2009) q2m_new=q2m_m+q2m_ano help, q2m_new ;writing field lat=reform(gphit(0,0:jpj-1)) lon=reform(glamt(0:jpi-1,0)) time=timegen(7670, units='days', start=julday(1,1,1989,0)) & 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'} q2m_attr={units:'g/kg',missing_value:1.e20,long_name:'Specific humidity at 2m height',short_name:'q2m',axis:'TYX'} globattr={source:'Basic data obtained from ERAI. Mean correction for bias and correction for variability are applied',timerange:cda0+' - '+cda1} ncfields = 'q2m[longitude,latitude,time]=q2m_new:q2m_attr; ' $ + 'longitude[]=lon:lon_attr; ' $ + 'latitude[]=lat:lat_attr; ' $ + 'time[*time]=time:time_attr ' $ + ' @ globattr' @ncdf_quickwrite end