%GPS_plot
%Gwyneth Hughes Jan. 28, 2008

%Produces a graphic showing the dates for which GPS stations on Bezymianny were operating 
%%%%%Input:
    %sites: Contains names of stations
    %GPS_dates_all.txt = text file of size stns x years*4.  Dates of operation for each station, 
	%in terms of day numbers, i.e. days after Jan. 1 2005.  Stations are in
        %order given below.  For each year there are four columns.  The
        %first two are the begin/end dates of operation at each site.  The second two are
        %the begin/end survey dates for those sites visited a second time during that year.
	%0 entries signify that the station did not operate during that time interval
    %eruptions: dates of eruptions
    %eruptions_nms: dates of eruptions in string form
    %num_recs=Number of years for which data was collected.
    %num_st=Total number of campaign and continuous sites
    %Note: Use day_calc_Kam to generate day numbers from dates. Day 1 is Jan. 1st 2005.

close all; clear all;

%Input
sites={'BZ00'; 'BZ01';'BZ02';'BZ03';'BZ04';'BZ05';'BZ06';'BZ07';'BZ08';'BZ09';'BEZH';'BEZD';'BEZR';'KAMD'};
load GPS_dates_all.txt
eruptions=[333 494 723 862 1017];
eruptions_nms={'Nov 29','May 9','Dec 24','May 12','Oct 14'} 
num_recs=3;
num_st=14;

%Establish variables
stn_num=1:num_st;
line1=1:1095;
m=length(line1);

%Plot the figure background
figure; hold on; axis([182,1095,0.5,14.5]);
for i=1:num_st
     plot(line1,stn_num(i)*ones(1,m),'k-');
end

%For each time period, plot GPS dates of operation     
for j=1:num_recs
  if j==num_recs
      symb='go';%Green indicates ongoing continuous data collection
  else
      symb='bo'; %Blue indicates downloaded continuous data
  end
    temp1=GPS_dates_all(:,(4*j-3):(4*j-2)); %Dates for each station
    temp2=GPS_dates_all(:,(4*j-1):4*j); %Repeat campaigns during single field season
    
    for i=1:num_st 
        days=temp1(i,2)-temp1(i,1);
        %Plot continuous data
        if days>20 %continuous (rather than campaign) data collection = >20 days
            cont_days=temp1(i,1):temp1(i,2);
            plot(cont_days,stn_num(i)*ones(1,length(cont_days)),symb);
            camp_days=temp2(i,1):temp2(i,2);
            plot(camp_days,stn_num(i)*ones(1,length(camp_days)),symb);
        %Plot campaign data
        else
            camp_days=[temp1(i,1):temp1(i,2) temp2(i,1):temp2(i,2)];
            plot(camp_days,stn_num(i)*ones(1,length(camp_days)),'o','MarkerFaceColor',[.8 0 .8],'MarkerEdgeColor',[.8 0 .8]);
        end
    end
end

%Plot the eruptions as vertical lines
for i=1:length(eruptions) 
    plot(eruptions(i)*ones(1,16),0:15,'r-','LineWidth',1.5);
end

%Label axes
set(gca,'XTick',[182 244 305 366 425 486 547 609 670  731  790 851 912 974 1035]);
set(gca,'XTickLabel',{'Jul';'Sep';'Nov';'Jan';'Mar';'May';'Jul';'Sep';'Nov';'Jan';'Mar';'May';'Jul';'Sep';'Nov'},'FontSize',12)
set(gca,'YTick',[1 2 3 4 5 6 7 8 9 10 11 12 13 14]);
set(gca,'YTickLabel',sites,'FontSize',12)
text(182, -0.3,'2005','FontSize',12,'HorizontalAlignment','center');
text(366, -0.3,'2006','FontSize',12,'HorizontalAlignment','center');
text(731, -0.3,'2007','FontSize',12,'HorizontalAlignment','center');

%Label eruptions
for i=1:length(eruptions)
text(eruptions(i), 14.7,eruptions_nms(i),'FontSize',11,'HorizontalAlignment','center');
end


    
    