%function Figure_gain_GOES
% comparison between wave gain vs GOES
clear all
close all
t0=24;
t1=t0+15.5;
t2=t0+18.25;
t3=t0+19;
t4=t0+21.667;
t5=t0+23+25/60;
tsel=[t1 t3 t4 t5];
rtg=load('gain_bimax.mat');
load FromMaria/fuv_all.mat
itarr=[1 4 6 7];
nt=length(itarr);
figure(1)
 clf
msp=1;
nsp=nt;
setfigpos(gcf,[1 1 nsp*2 msp*2])
setfigpos(gcf,[1 1 8,4])
hb=blockplot(2,nsp,'xmargin',[0.05,0.25],'ymargin',[0.2,0.1]);
%hb=hb';
 hold on
for i=1:nt
it=itarr(i);
gfac=2;
mlt=rtg.mltarr;
        xeq2=cos((rtg.mltarr-0.5)*pi/12)'*(rtg.rarr-0.05);
        yeq2=sin((rtg.mltarr-0.5)*pi/12)'*(rtg.rarr-0.05);
        xeq3=cos((rtg.mltarr)*pi/12)'*([2.45,rtg.rarr,6.55]);
        yeq3=sin((rtg.mltarr)*pi/12)'*([2.45,rtg.rarr,6.55]);
maxgain_all=squeeze(max(rtg.gains{it}(:,:,:)))*gfac;
maxgain_all=squeeze(max(rtg.gains{it}(:,:,:)))*gfac;
fac=0.02;
	
	axes(hb(1,i))
        if ~isempty(fuvs{it})
	  pcolor(fuvs{it}.image)
	  axis equal
	  caxis([10,35])
	  shading flat
	  xlim([1,128])
	  ylim([1,128])
	  set(gca,'xtick',[])
	  set(gca,'ytick',[])
	  end

    %tstrs={'15:30','19:00','21:40','23:25'}	  
    %title(tstrs{i})	  
	 axes(hb(2,i))
	  %fill([-7 -7 7 7 -7]*1.5,[-7 7 7 -7 -7]*1.5,'k')
	  hold on
        if ~isempty(fuvs{it})
            pcolor(-fuvs{it}.xsm_eq, -fuvs{it}.ysm_eq, fuvs{it}.image);
	  end 	
            shading interp;
            %set(gca, 'YDir', 'reverse', 'XDir', 'reverse');
            set(gca, 'Color', 'k');
            colormap('gray');
            caxis([10 35]);

	theta = ([90:0.5:270])*pi/180;
    h_n = patch( cos(theta), sin(theta), 'w', 'EdgeColor', 'w' );

	theta = ([-90:0.5:90])*pi/180;
	h_d = patch( cos(theta), sin(theta), 'k', 'EdgeColor', 'w' );

	for( r = [2:2:10]);
        th=linspace(0,2*pi,180);
		plot(r.*cos(th), r.*sin(th), 'k--', 'Color', [0.5 0.5 0.5]); 
	end;
    
        axis equal;
		xlim([-7 7])
		ylim([-7 7])
	  set(gca,'xtick',[])
	  set(gca,'ytick',[])
      	plot([1 10], [0 0], 'k--', 'Color', [0.5 0.5 0.5]);
	plot([-10 -1], [0 0], 'k--', 'Color', [0.5 0.5 0.5]);
	plot([0,0], [1 10], 'k--', 'Color', [0.5 0.5 0.5]);
	plot([0,0], [-10 -1], 'k--', 'Color', [0.5 0.5 0.5]);  
      	plot([1 10], [1 10], 'k--', 'Color', [0.5 0.5 0.5]);
	plot([-10 -1], [-10 -1], 'k--', 'Color', [0.5 0.5 0.5]);
	plot([-1,-10], [1 10], 'k--', 'Color', [0.5 0.5 0.5]);
	plot([10,1], [-10 -1], 'k--', 'Color', [0.5 0.5 0.5]);  
            gctr=[5:10:10:80];
            gctr=5:5:80;
            ng=length(gctr);
            clcarr2=idlcolormap(ng+2);
		sz=size(maxgain_all);
		maxg=zeros([sz(1),sz(2)+2]);
		maxg2=maxgain_all*0;
		maxg2(maxgain_all>20)=1;
		maxg(:,2:42)=maxg2;
            contour(xeq3,yeq3,maxg,[0.5],'r')

            %for ig=[1:ng]
            %contour(xeq2,yeq2,maxgain_all,[1 1]*gctr(ig),'color',clcarr2(ig+2,:))
            %end
	%axis off

            
%plot(maxgain_all([1:25,1],end)*fac+tsel(i),mlt([1:25,1]))
%fill(maxgain_all([1:25,1],end)*fac+tsel(i),mlt([1:25,1]),'k')
end
saveeps('_')
%return
saveeps('Figure_gain_fuv.pdf_')


