Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- clear; clc;
- % variables and data
- load('Drifter_dataset.mat')
- D = struct2table(D, 'AsArray', true);
- C = load('BCcstlne.mat');
- truelat = zeros(height(D),1);
- truelon = zeros(height(D),1);
- countA = 0;
- countB = 0;
- countC = 0;
- PlotEndDate = zeros(height(D),1);
- % plotting the land area on initial figure, defining the x and y tick
- % values (degrees N or W)
- figure(1);
- ylabel('Latitude');
- xlabel('Longitude');
- title('The Plot of Floating Current Trackers');
- xlim([-126 -122])
- for k = 1:length(C.k)-1
- ii = C.k(k)+1:C.k(k+1)-1;
- patch(C.ncst(ii,1),C.ncst(ii,2),[1 0.9 0.9],'edgecolor','none');
- end
- set(gca,'tickdir','out');
- set(gca,'box','on');
- yticklabels({'48^o N','48.5^o N','49^o N','49.5^o N','50^o N','50.5^o N',...
- '51^o N'});
- xticklabels({'126^o W','125.5^o W','125^o W','124.5^o W','124^o W',...
- '123.5^o W','123^o W','122.5^o W','122^o W'})
- hold on;
- % finding the the end date of each path - either the overall end date
- % or the first time the drifter washed ashore
- for i = 1:height(D)
- PlotEndDate(i) = D.endDate(i);
- if D.refloated == 1
- PlotEndDate(i) = D.firstGrndDate(i);
- else
- end
- end
- % using the location in the struct/table in column mtime to locate values
- % of latitude and longitude
- for j= 1:height(D)
- for l=1:length(D.mtime{j})
- if D.mtime{j}(l,1) == PlotEndDate(j,1)
- truelat(j) = D.lat{j}(l,1);
- truelon(j) = D.lon{j}(l,1);
- else
- end
- end
- end
- % plotting where the drifters travelled, with distinctions between
- % if/in which direction they exited the straight of georgia
- for h=1:height(D)
- if truelon(h) <= -125.19 && truelat(h) >= 50
- plot(D.lon{h}(:,1), D.lat{h}(:,1),'color',[.1 .7 .1 .5]);
- countA = countA + 1;
- elseif truelat(h) <= 48.78
- plot(D.lon{h}(:,1), D.lat{h}(:,1),'color',[.7 .1 .1 .5]);
- countB = countB + 1;
- else
- plot(D.lon{h}(:,1), D.lat{h}(:,1),'color',[.5 .5 .7 .5]);
- countC = countC + 1;
- end
- hold on;
- end
- % plotting the starting points in blue, and the ending points in either
- % red (land) or green (sea) depending on whether they end up on land
- % before the project was finished
- hold on;
- for p = 1:height(D)
- plot (D.lon{p}(1,1),D.lat{p}(1,1),'-o','MarkerFaceColor',[0 0 .75],'MarkerEdgeColor','k')
- if D.firstLifeTime(p)~=0
- plot (truelon(p),truelat(p),'-o','MarkerFaceColor',[0 .75 0],'MarkerEdgeColor','k')
- else
- plot (truelon(p),truelat(p),'-o','MarkerFaceColor',[.75 0 0],'MarkerEdgeColor','k')
- end
- end
- % adding text to the map relaying how many drifters went ashore, left the
- % straight of georgia to the north, and left the straight of georgia to the
- % south
- hold on;
- text(-124.5,50.75,{[num2str(countC) ' tracks ground'];
- [num2str(countB) ' tracks leave the SoG to the south'];
- [num2str(countA) ' tracks leave the SoG to the north']});
- % a legend defining which lines correspond to which data, and which dots
- % correspond with which starting or ending point
- hold on;
- lgnd = zeros(6, 1);
- lgnd(1) = plot(NaN,NaN,'o-','MarkerFaceColor',[0 0 .75],'MarkerEdgeColor','k');
- lgnd(2) = plot(NaN,NaN,'o-','MarkerFaceColor',[.75 0 0],'MarkerEdgeColor','k');
- lgnd(3) = plot(NaN,NaN,'o-','MarkerFaceColor',[0 .75 0],'MarkerEdgeColor','k');
- lgnd(4) = plot(NaN,NaN,'color',[.5 .5 .7]);
- lgnd(5) = plot(NaN,NaN,'color',[.7 .1 .1]);
- lgnd(6) = plot(NaN,NaN,'color',[.1 .7 .1]);
- legend(lgnd,'starting point','ends on land','ends at sea','SoG',...
- 'exit north','exit south','Location','southwest');
- legend('boxoff');
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement