PRO it_pp_wopt_01, tfile, ofile=ofile ;; does a ropp pp WOPT test ;; ;; 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 1a var = 'dtime' & ncdf_getvar, id, var, odtime, error=error if error then print,'IDL it_wopt_01 Error: (1) Variable not found: '+var var = 'snr_L1ca' & ncdf_getvar, id, var, osnr, error=error if error then print,'IDL it_wopt_01 Error: (2) Variable not found: '+var var = 'phase_L1' & ncdf_getvar, id, var, ophase, error=error if error then print,'IDL it_wopt_01 Error: (3) Variable not found: '+var ncdf_close, id ;; read the output file print,'Reading output file '+tfile id = ncdf_open(tfile) ; Level 1a var = 'dtime' & ncdf_getvar, id, var, tdtime, error=error if error then print,'IDL it_wopt_01 Error: (1) Variable not found: '+var var = 'snr_L1ca' & ncdf_getvar, id, var, tsnr, error=error if error then print,'IDL it_wopt_01 Error: (2) Variable not found: '+var var = 'phase_L1' & ncdf_getvar, id, var, tphase, error=error if error then print,'IDL it_wopt_01 Error: (3) Variable not found: '+var ncdf_close, id ifail=0 no1a=n_elements(odtime) nt1a=n_elements(tdtime) print,'No. Level 1a levels:',no1a,nt1a ;;; Interpolate data onto common levels grid1a = min(odtime)+findgen(1500)*(1.0*(max(odtime) - min(odtime)))/1500.0 tsnr = interpol(tsnr, tdtime, grid1a) tphase = interpol(tphase, tdtime, grid1a) tdtime = interpol(tdtime, tdtime, grid1a) osnr = interpol(osnr, odtime, grid1a) ophase = interpol(ophase, odtime, grid1a) odtime = interpol(odtime, odtime, grid1a) ;;; Compute maximum differences between data diff = max( (odtime - tdtime) ) if ( diff gt 0.05 ) then begin print, 'dtime parameters differ by ', diff, ' sec - TEST FAILED' ifail = 1 endif else begin print, 'dtime parameters differ by ', diff, ' sec - TEST PASSED' endelse diff = max( (ophase - tphase)) if ( diff gt 0.05) then begin print, 'Excess phases differ by ', diff, ' m - TEST FAILED' ifail = 1 endif else begin print, 'Excess phases differ by ', diff, ' m - TEST PASSED' endelse diff = max( (osnr - tsnr)) if ( diff gt 0.05) then begin print, 'SNRs differ by ', diff, ' V/V - TEST FAILED' ifail = 1 endif else begin print, 'SNRs differ by ', diff, ' V/V - TEST PASSED' endelse jpgfile = 'ropp_pp_comp.jpg' resolution= [1000, 1000] open_jpgfile, jpgfile, resolution, thisDevice !P.multi=[0,1,2] ; Plot phase and the diff !p.region = [0, 0.475, 0.9, 0.95] plot, (grid1a-min(grid1a)), ophase, /nodata, xrange=[0, 100], yrange=[0,4.e3], ytitle="Excess phase (m)", xtitle="dtime (s)", ystyle=9, $ title='Ref file = '+ofile+'!CTest file = '+tfile+'!C' oplot, (grid1a-min(grid1a)), ophase, line=0 oplot, ((grid1a-min(grid1a)))(25*indgen(60)), tphase(25*indgen(60)), psym=1 oplot, [5, 15], [3.75e3, 3.75e3], line=0 & xyouts, 20, 3.75e3, /data, 'ref' oplot, [5, 15], [3.50e3, 3.50e3], psym=1 & xyouts, 20, 3.50e3, /data, 'test' oplot, [5, 15], [3.25e3, 3.25e3], line=2 & xyouts, 20, 3.25e3, /data, 'test-ref' xyouts, 20, 3.00e3, /data, '('+string(min(tphase - ophase),'(f7.1)')+' to '+string(max(tphase - ophase),'(f7.1)')+') axis, yaxis=1, yrange=[-1,1]*(max(abs(tphase-ophase)) > 1), ystyle=1, ytit="Excess phase difference (m)", /save oplot, (grid1a-min(grid1a)), (tphase - ophase), line=2 ; Plot SNR and the diff !p.region = [0, 0, 0.9, 0.475] plot, (grid1a-min(grid1a)), osnr, /nodata, ylog=0, xrange=[0, 100], yrange=[0, 2.0], ytitle="SNR (V/V)", xtitle="dtime (s)", ystyle=9 oplot, (grid1a-min(grid1a)), osnr, line=0 oplot, ((grid1a-min(grid1a)))(25*indgen(60)), tsnr(25*indgen(60)), psym=1 oplot, [5, 15], [1.875, 1.875], line=0 & xyouts, 20, 1.875, /data, 'ref' oplot, [5, 15], [1.750, 1.750], psym=1 & xyouts, 20, 1.750, /data, 'test' oplot, [5, 15], [1.625, 1.625], line=2 & xyouts, 20, 1.625, /data, 'test-ref' xyouts, 20, 1.500, /data, '('+string(min(tsnr - osnr),'(f7.3)')+' to '+string(max(tsnr - osnr),'(f7.3)')+') axis, yaxis=1, yrange=[-1,1]*(max(abs(tsnr-osnr)) > 0.01), ylog=0, ystyle=1, ytit="SNR difference (V/V)", /save oplot, (grid1a-min(grid1a)), (tsnr - osnr), 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