;+ ; ; .. _TropFlux_swr_NRT_19890101_20091231.pro: ; ; ====================================== ; TropFlux_swr_NRT_19890101_20091231.pro ; ====================================== ; ; DESCRITION ; ========== ; ; Correction of swr near real time on OAFLUX grid ; ; Corrected swr delay on OAFLUX grid ; has been produced by ; :file:`${PROJECT_OD}/TropFlux_swr_19890101_20071231_DT.nc` ; ; :file:`${PROJECT_OD}/olr_oafluxgrid_30n30s_19890101_20091231.nc` ; have been produced ++by pk ; ; Corrected swr near real time on OAFLUX grid ; ; is written in ; :file:`${PROJECT_OD}/TropFlux_swr_19890101_20091231_NRT.nc` ; if this file not already exists. ; ; This file will be used by :ref:`TropFlux_swr_BLND_19890101_20091231.pro`. ; ; .. graphviz:: ; ; digraph tropflux_swr_nrt_19890101_200912311 { ; ; file_swr_dt [shape=ellipse,fontname=Courier,label="${PROJECT_OD}/TropFlux_swr_19890101_20071231_DT.nc"]; ; file_olr [shape=ellipse,fontname=Courier,label="${PROJECT_OD}/olr_oafluxgrid_30n30s_19890101_20091231.nc"]; ; file_out [shape=ellipse,fontname=Courier,label="${PROJECT_OD}/TropFlux_swr_19890101_20091231_NRT.nc"]; ; ; tropflux_swr_nrt_19890101_200912311 [shape=box, ; fontname=Courier, ; color=blue, ; URL="http://forge.ipsl.jussieu.fr/tropflux/browser/trunk/src/TropFlux_swr_NRT_19890101_200912311.pro", ; label="${PROJECT}/src/TropFlux_swr_NRT_19890101_200912311.pro"]; ; ; {file_swr_dt file_olr}-> {tropflux_swr_nrt_19890101_200912311} -> {file_out} ; } ; ; SEE ALSO ; ======== ; ; :ref:`project_profile.sh` ; ; :ref:`mooring_corrections` ; ; :ref:`data_in_swr` ; :ref:`data_in_olr` ; ; :func:`initncdf ` ; :func:`read_ncdf ` ; :func:`julday ` ; :func:`ncdf_quickwrite ` ; ; EXAMPLES ; ======== ; ; :: ; ; IDL> .compile TropFlux_swr_NRT_19890101_20091231 ; IDL> tropflux_swr_nrt_19890101_20091231 ; ; TODO ; ==== ; ; remove NaNf values in ouptut file (may be not because of this module) ; ; why two sequence initcdf et read_ndcf on olr file ? ; ; coding rules ; ; why compile is needed ? uppercase in file name ; ; change the name to swr_nrt_correction_ncdf.pro ; to homogenize names of tools ; ; KNOWN ISSUES ; ============ ; ; test of existence of fullfilename not very efficient because ; MUST_EXIST keyword of :func:`isafile ` not yet implemented ; ; EVOLUTIONS ; ========== ; ; $Id$ ; ; $URL$ ; ; - fplod 20110812T075406Z aedon.locean-ipsl.upmc.fr (Darwin) ; ; * usage of ${PROJECT_OD} ; * complete description ; * remove v50 in filenames ; ; - fplod 20101215T092145Z aedon.locean-ipsl.upmc.fr (Darwin) ; ; * add graph in header ; ; - fplod 20101214T093615Z aedon.locean-ipsl.upmc.fr (Darwin) ; ; * minimal header ; ; - pbk 2008 ; ; * creation ; ;- pro TropFlux_swr_NRT_19890101_20091231 ; @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 swr dt data filename filename_swr_dt='TropFlux_swr_19890101_20071231_DT.nc' ; ; check if this file exists msg='iii : looking for ' + filename_swr_dt ras = report(msg) fullfilename_swr_dt = isafile(iodirout + filename_swr_dt, NEW=0, /MUST_EXIST) IF fullfilename_swr_dt[0] EQ '' THEN BEGIN msg = 'eee : the file ' + fullfilename_swr_dt + ' was not found.' ras = report(msg) STOP ENDIF ; ; build olr data filename filename_olr='olr_oafluxgrid_30n30s_19890101_20091231.nc' ; ; check if this file exists msg='iii : looking for ' + filename_olr ras = report(msg) fullfilename_olr = isafile(iodirout + filename_olr, NEW=0, /MUST_EXIST) IF fullfilename_olr[0] EQ '' THEN BEGIN msg = 'eee : the file ' + fullfilename_olr + ' was not found.' ras = report(msg) STOP ENDIF ; ; build output filename filename_out = 'TropFlux_swr_19890101_20091231_NRT.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_swr_dt sw=read_ncdf("swr", 19890101, 20071231, file=fullfilename_swr_dt,/nostr) swi=sw initncdf, fullfilename_olr olr=read_ncdf('olr',19890100, 20071231, file=fullfilename_olr,/nost) help, sw, olr ;;creating climatology ny=(2007-1989)+1 nt=365*ny olri=total(reform(olr(*,*,0:nt-1),nxt,nyt,365,ny),4)/ny swi=total(reform(swi(*,*,0:nt-1),nxt,nyt,365,ny),4)/ny help, olri, swi ;; applying smoothing nsmooth=45 swi=[[[swi]],[[swi]],[[swi]]] & olri=[[[olri]],[[olri]],[[olri]]] si=size(sw) & n1=si(1) & n2=si(2) for j=0,n2-1 do begin for i=0,n1-1 do begin x=reform(swi(i,j,*)) y=reform(olri(i,j,*)) swi(i,j,*)=smooth(x,nsmooth) olri(i,j,*)=smooth(y,nsmooth) endfor endfor swi=swi[*,*,365:365+364] & olri=olri[*,*,365:365+364] help, swi initncdf, fullfilename_olr olr=read_ncdf('olr', 19890100, 20091231, box=box, file=fullfilename_olr,/nostr) tt=time & jpt=n_elements(time) caldat, time,mon,day,yea swm=olr*0. & olrm=olr*0. for jt=0,jpt-1 do begin jtt=(time(jt)-julday(1,1,yea(jt))) < 364 swm(*,*,jt)=swi(*,*,jtt) olrm(*,*,jt)=olri(*,*,jtt) endfor help, swm, olrm olra=olr-olrm ; olr anomaly rec=swm+(olra/0.760364) ; reconstructed sw ;writing field time=julday(1,1,1989)+lindgen(7670) cda0=string(jul2date(tt(0)),format='(i8.8)') cda1=string(jul2date(tt(jpt-1)),format='(i8.8)') lat=reform(gphit(0,0:jpj-1)) lon=reform(glamt(0:jpi-1,0)) 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:''} sw_attr={units:'w/m^2',missing_value:1.e20,long_name:'Net Shortwave Radiation',short_name:'swr',axis:'TYX'} globattr={source:'Reconstructed from corrected OLR anomalies and TropFlux mean SWR climatology',timerange:cda0+' - '+cda1} ncfields = 'sw[longitude,latitude,time]=rec:sw_attr; ' $ + 'longitude[]=lon:lon_attr; ' $ + 'latitude[]=lat:lat_attr; ' $ + 'time[*time]=time:time_attr ' $ + ' @ globattr' @ncdf_quickwrite end