;+ ; ; .. _TropFlux_19890101_20091231.pro: ; ; ============================== ; TropFlux_19890101_20091231.pro ; ============================== ; ; This program computes net heat flux components on the 1° oaflux grid. ; ; all input variables are corrected for mean bias and variability. ; ; gustiness correction is applied for wind speed based on cronin's climatological ; gustiness values. ; ; :file:`${PROJECT_ID}/mask_oaflux_30N30S.nc` containing OAFLUX grid have been produced by :ref:`oaflux_mask_30N30S.pro`. ; ; :file:`${PROJECT_OD}/TropFlux_sst_19890101_20091231.nc` containing sst corrected on OAFLUX grid have been produced by :ref:`sst_correction_ncdf.pro`. ; ; :file:`${PROJECT_OD}/TropFlux_ws_19890101_20091231.nc` containing ws corrected on OAFLUX grid have been produced by :ref:`ws_correction_ncdf.pro`. ; ; :file:`${PROJECT_OD}/TropFlux_gustiness_19890101_20091231.nc` containing ++ ; have been produced by :ref:`cronin_gustiness_ncdf.pro`. ; ; :file:`${PROJECT_OD}/TropFlux_swr_19890101_20091231_BLND.nc` containing ws corrected on OAFLUX grid ; have been produced by :ref:`TropFlux_swr_BLND_19890101_20091231.pro`. ; ; :file:`${PROJECT_OD}/TropFlux_lwr_19890101_20091231.nc` containing lwr corrected on OAFLUX grid have been produced by :ref:`lwr_correction_ncdf.pro`. ; ; :file:`${PROJECT_OD}/TropFlux_t2m_19890101_20091231.nc` containing t2m corrected on OAFLUX grid have been produced by :ref:`t2m_correction_ncdf.pro`. ; ; :file:`${PROJECT_OD}/TropFlux_q2m_19890101_20091231.nc` containing q2m corrected on OAFLUX grid have been produced by :ref:`d2m_to_q2m_erai.pro`. ; ; net heat flux components are written ; in :file:`${PROJECT_OD}/TropFlux_19890101_20091231.nc` ; if this file not already exists. ; ; .. graphviz:: ; ; digraph tropflux_19890101_20091231 { ; graph [ ; rankdir="LR", ; ] ; ; mask [shape=ellipse,fontname=Courier,label="${PROJECT_ID}/mask_oaflux_30N30S.nc"]; ; file_sst [shape=ellipse,fontname=Courier,label="${PROJECT_OD}/TropFlux_sst_19890101_20091231.nc"]; ; file_ws [shape=ellipse,fontname=Courier,label="${PROJECT_OD}/TropFlux_ws_19890101_20091231.nc"]; ; file_wg [shape=ellipse,fontname=Courier,label="${PROJECT_OD}/TropFlux_gustiness_19890101_20091231.nc"]; ; file_swr [shape=ellipse,fontname=Courier,label="${PROJECT_OD}/TropFlux_swr_19890101_20091231_BLND.nc"]; ; file_lwr [shape=ellipse,fontname=Courier,label="${PROJECT_OD}/TropFlux_lwr_19890101_20091231.nc"]; ; file_t2m [shape=ellipse,fontname=Courier,label="${PROJECT_OD}/TropFlux_t2m_19890101_20091231.nc"]; ; file_q2m [shape=ellipse,fontname=Courier,label="${PROJECT_OD}/TropFlux_q2m_19890101_20091231.nc"]; ; ; file_out[shape=ellipse,fontname=Courier,label="${PROJECT_OD}/TropFlux_19890101_20091231.nc"]; ; ; tropflux_19890101_20091231 [shape=box, ; fontname=Courier, ; color=blue, ; URL="http://forge.ipsl.jussieu.fr/tropflux/browser/trunk/src/TropFlux_19890101_20091231.pro", ; label="${PROJECT}/src/TropFlux_19890101_20091231.pro"]; ; ; {mask file_sst file_ws file_wg file_swr file_lwr file_t2m file_q2m} -> {tropflux_19890101_20091231} -> {file_out} ; ; } ; ; SEE ALSO ; ======== ; ; :ref:`project_profile.sh` ; ; :func:`report ` ; :func:`isadirectory ` ; :func:`isafile ` ; :func:`initncdf ` ; :func:`ncdf_lec ` ; :func:`read_ncdf ` ; :func:`caldat ` ; :func:`julday ` ; :func:`ncdf_quickwrite ` ; ; :func:`cor30a` ; ; EXAMPLES ; ======== ; ; :: ; ; IDL> .compile TropFlux_19890101_20091231 ; IDL> tropflux_19890101_20091231 ; ; TODO ; ==== ; ; no ${PROJECT_OD}/TropFlux_swr_19890101_20091231_BLND.nc yet because of pb in ; TropFlux_swr_BLND_19890101_20091231.pro ; ; avoid mix lower/uppercase in pro name to avoid compile ; ; coding rules ; ; KNOWN ISSUES ; ============ ; ; test of existence of fullfilename_msk not very efficient because ; MUST_EXIST keyword of :func:`isafile ` not yet implemented ; ; EVOLUTIONS ; ========== ; ; $Id ; ; $URL$ ; ; - fplod 20110809T110911Z aedon.locean-ipsl.upmc.fr (Darwin) ; ; * complete descritption ; * remove v* from filenames (in and out) ; * usage of ${PROJECT_OD} ; * remove return statement ; * add test on IO files ; ; - fplod 20101217T140745Z aedon.locean-ipsl.upmc.fr (Darwin) ; ; * remove hard coded directory for mask_oaflux_30N30S.nc ; ; - fplod 20101214T112131Z aedon.locean-ipsl.upmc.fr (Darwin) ; ; * add graph ; ; - fplod 20101214T093615Z aedon.locean-ipsl.upmc.fr (Darwin) ; ; * minimal header ; ; - pbk 2008 ; ; * creation ; ;- ; pro TropFlux_19890101_20091231 ; @cm_4cal @cm_4data @cm_4mesh @cm_4data @cm_project ; ; check for input directory ; ; test if ${PROJECT_ID} defined CASE project_id_env OF '' : BEGIN msg = 'eee : ${PROJECT_ID} is not defined' ras = report(msg) STOP END ELSE: BEGIN msg = 'iii : ${PROJECT_ID} is ' + project_id_env ras = report(msg) END ENDCASE ; iodirin = isadirectory(project_id_env) ; ; existence and protection of ${PROJECT_ID} IF (FILE_TEST(iodirin, /DIRECTORY, /EXECUTABLE, /READ) EQ 0) THEN BEGIN msg = 'eee : the directory' + iodirin + ' is not accessible.' ras = report(msg) STOP ENDIF ; ; build mask filename filename_msk='mask_oaflux_30N30S.nc' ; ; check if this file exists msg='iii : looking for ' + filename_msk ras = report(msg) fullfilename_msk = isafile(iodirin + filename_msk, NEW=0, /MUST_EXIST) IF fullfilename_msk[0] EQ '' THEN BEGIN msg = 'eee : the file ' + fullfilename_msk + ' was not found.' ras = report(msg) STOP ENDIF ; ; 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 sst data filename filename_sst='TropFlux_sst_19890101_20091231.nc' ; ; check if this file exists msg='iii : looking for ' + filename_sst ras = report(msg) fullfilename_sst = isafile(iodirout + filename_sst, NEW=0, /MUST_EXIST) IF fullfilename_sst[0] EQ '' THEN BEGIN msg = 'eee : the file ' + fullfilename_sst + ' was not found.' ras = report(msg) STOP ENDIF ; ; build ws data filename filename_ws='TropFlux_ws_19890101_20091231.nc' ; ; check if this file exists msg='iii : looking for ' + filename_ws ras = report(msg) fullfilename_ws = isafile(iodirout + filename_ws, NEW=0, /MUST_EXIST) IF fullfilename_ws[0] EQ '' THEN BEGIN msg = 'eee : the file ' + fullfilename_ws + ' was not found.' ras = report(msg) STOP ENDIF ; ; build swr data filename filename_swr='TropFlux_swr_19890101_20091231_BLND.nc' ; ; check if this file exists msg='iii : looking for ' + filename_swr ras = report(msg) fullfilename_swr = isafile(iodirout + filename_swr, NEW=0, /MUST_EXIST) IF fullfilename_swr[0] EQ '' THEN BEGIN msg = 'eee : the file ' + fullfilename_swr + ' was not found.' ras = report(msg) STOP ENDIF ; ; build lwr data filename filename_lwr='TropFlux_lwr_19890101_20091231.nc' ; ; check if this file exists msg='iii : looking for ' + filename_lwr ras = report(msg) fullfilename_lwr = isafile(iodirout + filename_lwr, NEW=0, /MUST_EXIST) IF fullfilename_lwr[0] EQ '' THEN BEGIN msg = 'eee : the file ' + fullfilename_lwr + ' was not found.' ras = report(msg) STOP ENDIF ; ; build t2m data filename filename_t2m='TropFlux_t2m_19890101_20091231.nc' ; ; check if this file exists msg='iii : looking for ' + filename_t2m ras = report(msg) fullfilename_t2m = isafile(iodirout + filename_t2m, NEW=0, /MUST_EXIST) IF fullfilename_t2m[0] EQ '' THEN BEGIN msg = 'eee : the file ' + fullfilename_t2m + ' was not found.' ras = report(msg) STOP ENDIF ; ; build q2m data filename filename_q2m='TropFlux_q2m_19890101_20091231.nc' ; ; check if this file exists msg='iii : looking for ' + filename_q2m ras = report(msg) fullfilename_q2m = isafile(iodirout + filename_q2m, NEW=0, /MUST_EXIST) IF fullfilename_q2m[0] EQ '' THEN BEGIN msg = 'eee : the file ' + fullfilename_q2m + ' was not found.' ras = report(msg) STOP ENDIF ; ; build wg data filename filename_wg='TropFlux_gustiness_19890101_20091231.nc' ; ; check if this file exists msg='iii : looking for ' + filename_wg ras = report(msg) fullfilename_wg = isafile(iodirout + filename_wg, NEW=0, /MUST_EXIST) IF fullfilename_wg[0] EQ '' THEN BEGIN msg = 'eee : the file ' + fullfilename_wg + ' was not found.' ras = report(msg) STOP ENDIF ; da1=19880101 & da2=20101231 ; initncdf, fullfilename_msk msk=ncdf_lec(fullfilename_msk,var='msk') initncdf, fullfilename_sst ws=read_ncdf('ws',da1,da2,file=fullfilename_ws,/nostr) wg=read_ncdf('wg',da1-1,da2,file=fullfilename_wg,/nostr) tt=time & jpt=n_elements(time) sst=read_ncdf('sst',da1,da2,file=fullfilename_sst,/nostr) sst=reform(sst-273.15) swd=read_ncdf('swr',da1,da2,file=fullfilename_swr,/nostr) lw=read_ncdf('lwr',da1,da2,file=fullfilename_lwr,/nostr) swd=swd/0.94 ;; converting from net swr to downward swr t2m=read_ncdf('t2m',da1,da2,file=fullfilename_t2m,/nostr)-273.15 ; in C q2m=read_ncdf('q2m',da1,da2,file=fullfilename_q2m,/nostr) ; in g/kg w=sqrt(ws*ws+wg*wg) ;; wind corrected for gustiness w=ws tmask=msk help, ws,w,wg,u,sst,swd,t2m,q2m ocean=where(msk eq 1,compl=land) valmask=1.e20 time=tt & jpt=n_elements(time) ; ;; Constants for flux computation ; zu=10. ; height of wind speed measurement (m) us=0. ; surf current (m/s) zt=2. ; Height of air T measurement (m) zq=2. ; height of humidity measurement (m) P=1008. ; Pressure zi=600. ; Inversion height (m) jcool=0 ; Compute cool-skin jwave=0 ; No waves twave=5. hwave=1. caldat, time,mon,day,yea swr=fltarr(jpi,jpj,jpt)+1.e20 lwr=fltarr(jpi,jpj,jpt)+1.e20 lat=fltarr(jpi,jpj,jpt)+1.e20 sen=fltarr(jpi,jpj,jpt)+1.e20 lwnet_clrk=fltarr(jpi,jpj,jpt)+1.e20 ;Ch=fltarr(jpi,jpj,jpt)+1.e20 ;Ce=fltarr(jpi,jpj,jpt)+1.e20 junk=fltarr(jpi,jpj,jpt)+1.e20 for jt=0,jpt-1 do begin jday=time(jt)-julday(1,1,yea(jt)) print, 'Computing Fluxes ',jt,' / ',jpt-1 ; ; P=msl(*,*,jt) & P=P(ocean) wn=w(*,*,jt) & wn=wn(ocean) ; wind speed (m/s) ts=sst(*,*,jt) & ts=ts(ocean) ; Bulk sst (°C) t=t2m(*,*,jt) & t=t(ocean) ; 2m Air T (°C) qs=qsee(ts,P) ; Sea surface sat. spec. humidity (g/kg) q=q2m(*,*,jt) & q=q(ocean) ; 2m AIr specific humidity (g/kg) Rs=swd(*,*,jt) & Rs=Rs(ocean) ; Downward solar flux (W/m2) ylat=gphit(ocean) ; cld=calc_cloud(jday,Rs,ylat) cld=calc_cloud_vlat(jday,Rs,ylat) ; Rl=lwdown_clark(ts,q,cld,t,P) ; Downward IR flux (W/m2) Rl=lw(*,*,jt) & Rl=Rl(ocean) rain=0. lw_clrk=-lwnet_clark(ts,q,cld,t,P) ; junk(*,*,jt)=lw_clrk ; ;stop y=cor30a(wn,us,ts,t,Qs,Q,Rs,Rl,rain,zi,P,zu,zt,zq,ylat,jcool,jwave,twave,hwave) ; ; A few punctual missing values (coare does not converge): filled by spatial extrapolation tab=fltarr(jpi,jpj)+!values.f_nan & x=reform(y(*,0)) & tab(ocean)=x & m=finite(tab) & tab=extrapolate(tab,m) & swr(*,*,jt)=tab*msk+valmask*(1-msk) tab=fltarr(jpi,jpj)+!values.f_nan & x=reform(y(*,1)) & tab(ocean)=x & m=finite(tab) & tab=extrapolate(tab,m) & lwr(*,*,jt)=tab*msk+valmask*(1-msk) tab=fltarr(jpi,jpj)+!values.f_nan & x=reform(y(*,2)) & tab(ocean)=x & m=finite(tab) & tab=extrapolate(tab,m) & lat(*,*,jt)=tab*msk+valmask*(1-msk) tab=fltarr(jpi,jpj)+!values.f_nan & x=reform(y(*,3)) & tab(ocean)=x & m=finite(tab) & tab=extrapolate(tab,m) & sen(*,*,jt)=tab*msk+valmask*(1-msk) ; tab=fltarr(jpi,jpj)+!values.f_nan & x=reform(lw_clrk) & tab(ocean)=x & m=finite(tab) & tab=extrapolate(tab,m) & lwnet_clrk(*,*,jt)=tab*msk+valmask*(1-msk) ; tab=fltarr(jpi,jpj)+!values.f_nan & x=reform(y(*,6)) & tab(ocean)=x & m=finite(tab) & tab=extrapolate(tab,m) & Ch(*,*,jt)=tab*msk+valmask*(1-msk) ; tab=fltarr(jpi,jpj)+!values.f_nan & x=reform(y(*,7)) & tab(ocean)=x & m=finite(tab) & tab=extrapolate(tab,m) & Ce(*,*,jt)=tab*msk+valmask*(1-msk) endfor tt=time 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)') tt=time-julday(1,1,1950,00,00,00) xlon=reform(glamt(*,0) ) & ylat=reform(gphit(0,*)) ncfile='!${PROJECT_OD}/TropFlux_19890101_20091231.nc' lon_attr={units:'degrees_east',long_name:'Longitude'} lat_attr={units:'degrees_north',long_name:'Latitude'} swr_attr={units:'W/m2',missing_value:valmask,long_name:'Surface net shortwave radiation',short_name:'swr',axis:'TYX'} lwr_attr={units:'W/m2',missing_value:valmask,long_name:'Surface net longwave radiation',short_name:'lwr',axis:'TYX'} lwr_clrk_attr={units:'W/m2',missing_value:valmask,long_name:'Surface net longwave radiation from clark',short_name:'lwr',axis:'TYX'} lhf_attr={units:'W/m2',missing_value:valmask,long_name:'Surface latent flux',short_name:'lhf',axis:'TYX'} shf_attr={units:'W/m2',missing_value:valmask,long_name:'Surface sensible flux',short_name:'shf',axis:'TYX'} time_attr={units:'days since 1950-01-01 00:00:00',long_name:'Time axis',time_origin:' 1950-JAN-01 00:00:00'} Ch_attr={units:'',missing_value:valmask,long_name:'heat transfer coefficient at zt',short_name:'Ch',axis:'TYX'} Ce_attr={units:'',missing_value:valmask,long_name:'moisture transfer coefficient at zq',short_name:'Ce',axis:'TYX'} globattr={source:'Fluxes for the Global Tropical Ocean - TropFlux',timerange:cda0+' - '+cda1} help, swr,lwr,lat,sen,tt,xlon,ylat ncfields = 'swr[longitude,latitude,time]=swr:swr_attr; ' $ ; +'lwr_coare[longitude,latitude,time]=lwr:lwr_attr; ' $ +'lwr[longitude,latitude,time]=lwnet_clrk:lwr_clrk_attr; ' $ +'lhf[longitude,latitude,time]=lat:lhf_attr; ' $ +'shf[longitude,latitude,time]=sen:shf_attr; ' $ ; +'Ch[longitude,latitude,time]=Ch:Ch_attr; ' $ ; +'Ce[longitude,latitude,time]=Ce:Ce_attr; ' $ + 'longitude[]=xlon:lon_attr; ' $ + 'latitude[]=ylat:lat_attr; ' $ + 'tt[*time]=tt:time_attr ' $ + ' @ globattr' @ncdf_quickwrite end