;+ ; ; .. _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 ; has been produced by ; :func:`oaflux_mask_30n30s`. ; ; :file:`${PROJECT_OD}/TropFlux_sst_19890101_20091231.nc` ; containing ; sst corrected on OAFLUX grid ; has been produced by ; :ref:`sst_correction_ncdf.pro`. ; ; :file:`${PROJECT_OD}/TropFlux_ws_19890101_20091231.nc` ; containing ; ws corrected on OAFLUX grid ; has been produced by ; :ref:`ws_correction_ncdf.pro`. ; ; :file:`${PROJECT_OD}/TropFlux_gustiness_19890101_20091231.nc` ; containing ; ++ ; has been produced by ; :ref:`cronin_gustiness_ncdf.pro`. ; ; :file:`${PROJECT_OD}/TropFlux_swr_19890101_20091231_BLND.nc` ; containing ; ws corrected on OAFLUX grid ; has been produced by ; :ref:`TropFlux_swr_BLND_19890101_20091231.pro`. ; ; :file:`${PROJECT_OD}/TropFlux_lwr_19890101_20091231.nc` ; containing ; lwr corrected on OAFLUX grid ; has been produced by ; :ref:`lwr_correction_ncdf.pro`. ; ; containing ; t2m corrected on OAFLUX grid ; has been produced by ; :ref:`t2m_correction_ncdf.pro`. ; ; :file:`${PROJECT_OD}/TropFlux_q2m_19890101_20091231.nc` ; containing ; q2m corrected on OAFLUX grid ; has been produced by ; :ref:`d2m_to_q2m_erai.pro`. ; ; net heat flux components are written ; in :file:`${PROJECT_OD}/TropFlux_19890101_20091231_coarev3.nc` ; if this file not already exists. ; ; This output file ; :file:`${PROJECT_OD}/TropFlux_19890101_20091231_coarev3.nc` ; will be used by ; :ref:`TropFlux_NRT_ncdf.pro`. ; ; .. graphviz:: ; ; digraph tropflux_19890101_20091231 { ; ; 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_coarev3.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:`qsee` ; :func:`lwnet_clark` ; :func:`calc_claud_vlat` ; :func:`cor30a` ; ; .. note:: ; ; :func:`lwdown_clark` is not used here but available. ; ; EXAMPLES ; ======== ; ; :: ; ; IDL> .compile TropFlux_19890101_20091231 ; IDL> tropflux_19890101_20091231 ; ; TODO ; ==== ; ; describe usage of tau ; ; make it work :: ; ; % Compiled module: EXTRAPOLATE. ; % Attempt to subscript LAND with OK is out of range. ; % Execution halted at: EXTRAPOLATE 176 ; /usr/home/fplod/SAXO_DIR/SRC/Interpolation/extrapolate.pro ; % TROPFLUX_19890101_20091231 450 ; /usr/home/fplod/incas/tropflux/tropflux_ws/src/TropFlux_19890101_20091231.p ; ro ; % $MAIN$ ; % Program caused arithmetic error: Floating overflow ; % Program caused arithmetic error: Floating illegal operand ; ; the incriminated line is :: ; ; tab=fltarr(jpi,jpj)+!values.f_nan & x=reform(y(*,1)) & tab(ocean)=x & m=fi nite(tab) & tab=extrapolate(tab,m) & lwr(*,*,jt)=tab*msk+valmask*(1-msk) ; ; to make progress I DO NOT extrapolate anymore lwr, sen and lat ; !!!!! must be reactivated ; ; when I DO NOT extrapolate lwr, sen and lat , program end with :: ; ; Written to ; !/usr/work/incas/fplod/tropflux_d/TropFlux_19890101_20091231_coarev3.nc ; ------------------------- ; % Program caused arithmetic error: Floating divide by 0 ; % Program caused arithmetic error: Floating underflow ; % Program caused arithmetic error: Floating overflow ; % Program caused arithmetic error: Floating illegal operand ; ; explain why :func:`lwdown_clark` is not used ; ; check if K or °C in input ; ; get rid of:: ; ; % date 1: 19880101 is not found in the time axis. ; ; why :: ; ; da1=19880101 ; ; 1st date 19890101 no ? ; ; why da1-1 (with da1=19880101) when reading gustiness file :: ; ; wg=read_ncdf('wg',da1-1,da2,file=fullfilename_wg,/nostr) ; ; 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 20110830T135832Z cratos (Linux) ; ; * replace tt by time ; ; - fplod 20110830T084129Z aedon.locean-ipsl.upmc.fr (Darwin) ; ; * add tau in ouptut file ; ; - fplod 20110822T090838Z aedon.locean-ipsl.upmc.fr (Darwin) ; ; * split some multiple lines statement to investigate ; pb of extropalation for lwr ; ; - fplod 20110819T144332Z aedon.locean-ipsl.upmc.fr (Darwin) ; ; * add _coarev3 to filename output ; * check if filename output exists ; ; - 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 ; ; build output filename filename_out = 'TropFlux_19890101_20091231_coarev3.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 ; 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) ; ; wind speed (m/s) wn=w(*,*,jt) wn=wn(ocean) ; Bulk sst (°C) ts=sst(*,*,jt) ts=ts(ocean) ; 2m Air T (°C) t=t2m(*,*,jt) t=t(ocean) ; Sea surface sat. spec. humidity (g/kg) qs=qsee(ts,P) ; 2m AIr specific humidity (g/kg) q=q2m(*,*,jt) q=q(ocean) ; Downward solar flux (W/m2) Rs=swd(*,*,jt) Rs=Rs(ocean) ylat=gphit(ocean) ; cld=calc_cloud(jday,Rs,ylat) cld=calc_cloud_vlat(jday,Rs,ylat) ; Downward IR flux (W/m2) ; Rl=lwdown_clark(ts,q,cld,t,P) 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) help, tab, m, swr 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) help, tab, m, lwr ;!!!!!!!!!!!!+++++++++++++++ tab=extrapolate(tab,m) print, 'www : extrapolation for lwr is not done' tab=tab lwr(*,*,jt)=tab*msk+valmask*(1-msk) ; tab=fltarr(jpi,jpj)+!values.f_nan x=reform(y(*,2)) tab(ocean)=x m=finite(tab) help, tab, m, lat ;!!!!!!!!!!!!+++++++++++++++ tab=extrapolate(tab,m) print, 'www : extrapolation for lat is not done' tab=tab lat(*,*,jt)=tab*msk+valmask*(1-msk) tab=fltarr(jpi,jpj)+!values.f_nan x=reform(y(*,3)) tab(ocean)=x m=finite(tab) help, tab, m, sen ;!!!!!!!!!!!!+++++++++++++++ tab=extrapolate(tab,m) print, 'www : extrapolation for sen is not done' tab=tab 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(*,5)) & tab(ocean)=x & m=finite(tab) & tab=extrapolate(tab,m) & tau(*,*,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) tab=fltarr(jpi,jpj)+!values.f_nan & x=reform(y(*,8)) & tab(ocean)=x & m=finite(tab) & tab=extrapolate(tab,m) & wg(*,*,jt)=tab*msk+valmask*(1-msk) endfor 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'} globattr={source:'Fluxes for the Global Tropical Ocean - TropFlux',timerange:cda0+' - '+cda1} 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'} wg_attr={units:'m/s',missing_value:valmask,long_name:'COARE convective gustiness',short_name:'wg',axis:'TYX'} tau_attr={units:'N/m2',missing_value:valmask,long_name:'Wind stress magnitude',short_name:'tau',axis:'TYX'} ; help, swr,lwr,lat,sen,time,xlon,ylat ; ncfields = 'tau[longitude,latitude,time]=tau:tau_attr; ' $ + 'wg[longitude,latitude,time]=wg:wg_attr; ' $ + '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; ' $ + 'time[*time]=time:time_attr ' $ + ' @ globattr' ; @ncdf_quickwrite ; end