function [fig1]=confplot(EMEP,rangeE,radialE,spec,sysinfo) %set up the wavesmon data in a structure %what is the magnetic variation to nearest degree magvar=10; %first change to m^2/Hz/deg wmon.S=spec/(360*1000*1000); %what is the start angle heading=sysinfo(18,:); heading=heading/100; sangle=heading+magvar; %what is the frequency and dir resolution for those generated in DIWASP freqres=0.01; freqs=[0.01:0.01:.4]; dirres=2; dirs=[-180:2:180]; %set up the directions adj_angle=90-sangle+360+180; wmon.dirs=[adj_angle:-4:-(356-adj_angle)]; wmondirres=4; wmon.xaxisdir=90; wmon.freqs=[0.00781250:0.00781250:1]; wmonfreqres=0.00781250; %calculate just the frequency energy spectrum EMEPfreq=sum(EMEP.S')*dirres; EMEPrangefreq=sum(rangeE.S')*dirres; EMEPradialfreq=sum(real(radialE.S)')*dirres; wmonfreq=sum(wmon.S')*wmondirres; %Compute the coefficient for the upper and lower error bounds for the power %spectrum assuming 95% confidence. Added on 9/17/08 degF=radialE.degF; chiUp=chi2inv(.975,degF); chiLow=chi2inv(.025,degF); coeffUp=degF/chiLow; coeffLow=degF/chiUp; logCoeffUp=log10(coeffUp); logCoeffLow=log10(coeffLow); %calculate the conf limits throughout the frequency spectrum EMEPradialfreqUP=EMEPradialfreq*coeffUp; EMEPradialfreqLOW=EMEPradialfreq*coeffLow; %same thing for the Puvw and range degF2=25; chiUp2=chi2inv(.975,degF2); chiLow2=chi2inv(.025,degF2); coeffUp2=degF2/chiLow2; coeffLow2=degF2/chiUp2; logCoeffUp2=log10(coeffUp2) logCoeffLow2=log10(coeffLow2) %calculate the conf limits throughout the frequency spectrum EMEPfreqUP=EMEPfreq*coeffUp2; EMEPfreqLOW=EMEPfreq*coeffLow2; EMEPrangefreqUP=EMEPrangefreq*coeffUp2; EMEPrangefreqLOW=EMEPrangefreq*coeffLow2; scrsz = get(0,'ScreenSize'); fig1=figure('Position',[scrsz]); %plot the frequency energy spectrum h1=semilogy(freqs,EMEPfreq,'b'); hold on plot([0.1,0.1],[10^logCoeffLow2,10^logCoeffUp2],'b.-'); %plot(freqs,EMEPfreqUP,'b--'); %plot(freqs,EMEPfreqLOW,'b--'); h2=semilogy(freqs,EMEPrangefreq,'r'); plot([0.11,0.11],[10^logCoeffLow2,10^logCoeffUp2],'r.-'); %plot(freqs,EMEPrangefreqUP,'r--'); %plot(freqs,EMEPrangefreqLOW,'r--'); h3=semilogy(freqs,EMEPradialfreq,'g'); plot([0.12,0.12],[10^logCoeffLow,10^logCoeffUp],'g.-'); %plot(freqs,EMEPradialfreqUP,'g--'); %plot(freqs,EMEPradialfreqLOW,'g--'); ylim([10^-2,10^1]); %set(gca,'ytick',[-4 -3 -2 -1 0 1]); axis(axis); h4=semilogy(wmon.freqs,wmonfreq,'k'); legend([h1,h2,h3,h4],'EMEP uvw','EMEP range','EMEP radial','wavesmon','location','best'); title('directional wave spectrum integrated over direction'); xlabel('frequency in Hz'); ylabel('m^2 / hz');