PRO it_pp_wopt_02, tfile, ofile=ofile ;; Compares input refrac and occ(wopt(refrac)), assuming the former ;; is in ofile and the latter is in tfile. ;; ;; INPUT: ;; ;; KEYWORDS: ;; ;;; OUTPUT: ;; error 1 [error] 0 [all fine] ;; ;; file settings if n_elements(ofile) eq 0 then ofile = '../data/ropp_pp_wopt_tool.nc' ;; observations if n_elements(tfile) eq 0 then tfile = 'ropp_pp_wopt_tool_out.nc' ;; output ;; read the original file print,'Reading original file '+ofile id = ncdf_open(ofile) ; Level 2a var = 'alt_refrac' & ncdf_getvar, id, var, oalt_refrac, error=error if error then print,'IDL it_wopt_02 Error: (1) Variable not found: '+var var = 'refrac' & ncdf_getvar, id, var, orefrac, error=error if error then print,'IDL it_wopt_02 Error: (2) Variable not found: '+var ncdf_close, id ;; read the output file print,'Reading output file '+tfile id = ncdf_open(tfile) ; Level 2a var = 'alt_refrac' & ncdf_getvar, id, var, talt_refrac, error=error if error then print,'IDL it_wopt_02 Error: (1) Variable not found: '+var var = 'refrac' & ncdf_getvar, id, var, trefrac, error=error if error then print,'IDL it_wopt_02 Error: (2) Variable not found: '+var ncdf_close, id ifail=0 no2a=n_elements(oalt_refrac) nt2a=n_elements(talt_refrac) print,'No. Level 2a levels:',no2a,nt2a ;;; Interpolate data onto common levels grid2a = min(oalt_refrac)+findgen(1501)*(1.0*(max(oalt_refrac) - min(oalt_refrac)))/1500.0 trefrac = interpol(trefrac, talt_refrac, grid2a) talt_refrac = interpol(talt_refrac, talt_refrac, grid2a) orefrac = interpol(orefrac, oalt_refrac, grid2a) oalt_refrac = interpol(oalt_refrac, oalt_refrac, grid2a) ;;; Compute maximum differences between data diff = max( (oalt_refrac - talt_refrac) ) if ( diff gt 0.05 ) then begin print, 'alt_refracs differ by ', diff, ' m - TEST FAILED' ifail = 1 endif else begin print, 'alt_refracs differ by ', diff, ' m - TEST PASSED' endelse diff = max( (orefrac - trefrac)) if ( diff gt 0.05) then begin print, 'refracs differ by ', diff, ' N_units - TEST FAILED' ifail = 1 endif else begin print, 'refracs differ by ', diff, ' N-units - TEST PASSED' endelse jpgfile = 'ropp_pp_comp.jpg' resolution= [750, 1000] open_jpgfile, jpgfile, resolution, thisDevice !P.multi=[0,1,1] ; Plot refracs and the diff !p.region = [0, 0, 0.95, 0.925] plot, trefrac, (grid2a-min(grid2a)), /nodata, xrange=[1.e-4, 1.e3]*0.5, yrange=[0.0, 9e4], ystyle=1, xlog=1, ytitle="alt refrac (m)", xtitle="refrac (N-units)", xstyle=9, $ tit='Ref file = '+ofile+'!CTest file = '+tfile+'!C!C' oplot, orefrac, (grid2a-min(grid2a)) oplot, trefrac(25*indgen(60)), ((grid2a-min(grid2a)))(25*indgen(60)), psym=1 oplot, [1, 5], [8.5e4, 8.5e4], line=0 & xyouts, 10, 8.5e4, /data, 'ref' oplot, [1, 5], [8.0e4, 8.0e4], psym=1 & xyouts, 10, 8.0e4, /data, 'test' oplot, [1, 5], [7.5e4, 7.5e4], line=2 & xyouts, 10, 7.5e4, /data, 'test-ref' xyouts, 10, 7.25e4, /data, '('+string(min(trefrac - orefrac),'(f7.1)')+' to '+string(max(trefrac - orefrac),'(f7.1)')+') axis, xlog=0, xaxis=1, xrange=[-1, 1]*10, xstyle=1, xtit="refrac difference (N-units)", /save oplot, (trefrac - orefrac)*0, [0, 1]*1e6, line=0 oplot, (trefrac - orefrac), (grid2a-min(grid2a)), line=2 close_jpgfile, jpgfile, resolution, thisDevice if(ifail eq 1)then print, 'At least one test failed.....TEST FAILED!' if(ifail eq 0)then print, 'All tests successful.....TEST PASSED!' end