%carte_courant_choix.m
% trace les courants mesurés par l'ADCP de coque à une profondeur choisie le long
% de 2 transects choisis, sur une carte du GdL avec bathy et trajet GOLTS.

clear
ici=pwd;
path_mat='h:\golts\Survey\Survey110602\ADCPTethys\tronca';
%path_mat='e:\Gatti2\golts\Valor\Valor070405\ADCPTethys\transect';

%choix des transects à tracer
choix=input('combien de transects à représenter? choix= ');
for ii=1:choix
    eval(['[f_mat',int2str(ii),',p_mat',int2str(ii),']=uigetfile([path_mat,''\*.mat'']);'])
    eval(['path_mat_file',int2str(ii),'=[p_mat',int2str(ii),',f_mat',int2str(ii),'];'])
    eval(['load (path_mat_file',int2str(ii),')'])
    eval(['lon',int2str(ii),'=xyt(:,1);'])
    eval(['lat',int2str(ii),'=xyt(:,2);'])
    eval(['u',int2str(ii),'=uv(1:2:end-1,:);'])
    eval(['v',int2str(ii),'=uv(2:2:end,:);'])
end

% Liste de toutes les profondeurs :
for jj=8:4:244
    if jj<=9
        p(jj/4-1,1:3)=sprintf('00%d',jj);
    elseif jj>=10 & jj<=99
        p(jj/4-1,1:3)=sprintf('0%d',jj);
    elseif jj>=100 & jj<=999
        p(jj/4-1,1:3)=sprintf('%d',jj);
    end
end
p=cellstr(p);

% choix de la profondeur à choisir
boucle=0;
kk=1;
while(boucle==0)
    bin=menu('Quelle profondeur ?',p);
    eval(['bin',int2str(kk),'=bin;'])
    eval(['prof',int2str(kk),'=(bin',int2str(kk),'+1)*4;'])
    
    %figure
    axis([4.8 6.1 42.2 43.45]);
    %asp=[0.3 0.3 1];
    asp=[1 cos(43*pi/180) 1];
    set(gca,'DataAspectRatioMode','manual','DataAspectRatio',asp);
    hold on
    % TRACER DU TRAIT DE COTE
    % masque terre
    cd h:\Maryse
    load line0.txt
    poly=zeros(length(line0)+2,2);
    poly(1:length(line0),1)=line0(:,2);  % longitude
    poly(1:length(line0),2)=line0(:,1);  % latitude
    poly(length(line0)+1:length(line0)+2,:)=[line0(1,2),line0(end,1);line0(1,2),line0(1,1)];
    patch(poly(1:end,1),poly(1:end,2),[0.6,0.6,0.6])
    % ajout des iles
    cd h:\cluster\matlab\anna
    load porque
    load porcro
    load levant
    fill(porque(:,1),porque(:,2),[.6 .6 .6])
    fill(porcro(:,1),porcro(:,2),[.6 .6 .6])
    fill(levant(:,1),levant(:,2),[.6 .6 .6])
    
    % AJOUT DE LA BATHYMETRIE
    %isobathes à partir de la bathymétrie réaliste
    cd h:\Maryse
    load line100.txt
    load line200.txt
    load line500.txt
    load line1000.txt
    load line1500.txt
    load line2000.txt
    load line2500.txt
    
    h1=plot(line100(:,2),line100(:,1),'k');
    set(h1,'color',[0.6 0.6 0.6])
    h2=plot(line200(:,2),line200(:,1),'k');
    set(h2,'color',[0.2 0.2 0.2],'linewidth',2)
    h3=plot(line500(:,2),line500(:,1),'k');
    set(h3,'color',[0.6 0.6 0.6])
    h4=plot(line1000(:,2),line1000(:,1),'k');
    set(h4,'color',[0.6 0.6 0.6])
    h5=plot(line1500(:,2),line1500(:,1),'k');
    set(h5,'color',[0.6 0.6 0.6])
    h6=plot(line2000(:,2),line2000(:,1),'k');
    set(h6,'color',[0.6 0.6 0.6])
    h7=plot(line2500(:,2),line2500(:,1),'k');
    set(h7,'color',[0.6 0.6 0.6])
    
    
    %TRACER DE LA CAMPAGNE GOLTS
    %Stations sur la route externe
    stat=[
        5.13	43.25
        5.13	43.07
        5.13	42.9275
        5.13	42.785
        5.13	42.6425
        5.13	42.5
        5.813	43.04
        5.6764	43.082
        5.5398	43.124
        5.4032	43.166
        5.2666	43.208
        5.13	43.25
        5.35     43.29     %marseille
    ];
    
    t1=plot([stat(2,1),stat(11,1)],[stat(2,2),stat(11,2)],'--k')
    %set(t1,'linewidth',3)
    t2=plot([stat(1,1),stat(6,1)],[stat(1,2),stat(6,2)],'--k')
    %set(t2,'linewidth',3)
    t3=plot([stat(2,1),stat(9,1)],[stat(2,2),stat(9,2)],'--k')
    %set(t3,'linewidth',3)
    t4=plot([stat(4,1),stat(9,1)],[stat(4,2),stat(9,2)],'--k')
    %set(t4,'linewidth',3)
    t5=plot([stat(6,1),stat(7,1)],[stat(6,2),stat(7,2)],'--k')
    %set(t5,'linewidth',3)
    t6=plot([stat(1,1),stat(7,1)],[stat(1,2),stat(7,2)],'--k')
    %set(t6,'linewidth',2)
    
    p1=plot(stat(2,1),stat(2,2),'ko')
    set(p1,'markersize',8,'markerfacecolor',[0.753 0.753 0.753])
    set(gca,'fontsize',12)
    
    p2=plot(stat(1,1),stat(1,2),'ko')
    set(p2,'markersize',8,'markerfacecolor','w')
    p3=plot(stat(4:2:6,1),stat(4:2:6,2),'ko')
    set(p3,'markersize',8,'markerfacecolor','w')
    p4=plot(stat(7:2:11,1),stat(7:2:11,2),'ko')
    set(p4,'markersize',8,'markerfacecolor','w')
    
    % TRACER DES COURANTS
    % rajout de l'échelle de courant
    [i,j]=size(u1);
    eval(['u1(bin',int2str(kk),',j+1)=0.5;'])
    eval(['v1(bin',int2str(kk),',j+1)=0;'])
    lon1(j+1)=5.6;
    lat1(j+1)=43.24;
    eval(['u1(bin',int2str(kk),',j+3)=0;'])
    eval(['v1(bin',int2str(kk),',j+3)=0.5;'])
    lon1(j+3)=5.6;
    lat1(j+3)=43.24;
    
    hold on
    fact=0.4;
    for ii=1:choix
        eval(['quiver(lon',int2str(ii),'(1:2:end),lat',int2str(ii),'(1:2:end),u',int2str(ii),'(bin',int2str(kk),',1:2:end)*asp(1)*fact,v',int2str(ii),'(bin',int2str(kk),',1:2:end)*asp(2)*fact,0,''.k'')'])
        %eval(['quiver(lon',int2str(ii),'(300),lat',int2str(ii),'(300),u',int2str(ii),'(bin',int2str(kk),',300)*asp(1),v',int2str(ii),'(bin',int2str(kk),',300)*asp(2),0,''.r'')'])
        eval(['text(6.2,43.2-0.1*',int2str(ii),',''',eval(['f_mat',int2str(ii)']),''')'])
    end
    %hold off
    
    eval(['title([''GOLTS Juin 2002 - bin ',eval(['int2str(bin',int2str(kk),')']),' ( ',eval(['int2str(prof',int2str(kk),')']),' m)''])'])
    text(5.65,43.35,'0.5 ms^{-1}')
    
    choix5=menu('voulez vous visualiser une autre profondeur?','non','oui');
    if choix5==1
        boucle=1;
    elseif choix5==2
        kk=kk+1;
    end   
end % boucle while pour tracer à différentes profondeurs

cd (ici)