Advertisement
Guest User

Untitled

a guest
Oct 22nd, 2018
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.76 KB | None | 0 0
  1. clear; clc;
  2.  
  3. % variables and data
  4.  
  5. load('Drifter_dataset.mat')
  6.  
  7. D = struct2table(D, 'AsArray', true);
  8. C = load('BCcstlne.mat');
  9.  
  10. truelat = zeros(height(D),1);
  11. truelon = zeros(height(D),1);
  12.  
  13. countA = 0;
  14. countB = 0;
  15. countC = 0;
  16.  
  17. PlotEndDate = zeros(height(D),1);
  18.  
  19. % plotting the land area on initial figure, defining the x and y tick
  20. % values (degrees N or W)
  21.  
  22. figure(1);
  23. ylabel('Latitude');
  24. xlabel('Longitude');
  25. title('The Plot of Floating Current Trackers');
  26. xlim([-126 -122])
  27.  
  28. for k = 1:length(C.k)-1
  29.  
  30. ii = C.k(k)+1:C.k(k+1)-1;
  31.  
  32. patch(C.ncst(ii,1),C.ncst(ii,2),[1 0.9 0.9],'edgecolor','none');
  33.  
  34. end
  35.  
  36. set(gca,'tickdir','out');
  37. set(gca,'box','on');
  38.  
  39. yticklabels({'48^o N','48.5^o N','49^o N','49.5^o N','50^o N','50.5^o N',...
  40. '51^o N'});
  41.  
  42. xticklabels({'126^o W','125.5^o W','125^o W','124.5^o W','124^o W',...
  43. '123.5^o W','123^o W','122.5^o W','122^o W'})
  44.  
  45. hold on;
  46.  
  47. % finding the the end date of each path - either the overall end date
  48. % or the first time the drifter washed ashore
  49.  
  50. for i = 1:height(D)
  51.  
  52. PlotEndDate(i) = D.endDate(i);
  53.  
  54. if D.refloated == 1
  55. PlotEndDate(i) = D.firstGrndDate(i);
  56. else
  57. end
  58.  
  59. end
  60.  
  61. % using the location in the struct/table in column mtime to locate values
  62. % of latitude and longitude
  63.  
  64. for j= 1:height(D)
  65.  
  66. for l=1:length(D.mtime{j})
  67.  
  68. if D.mtime{j}(l,1) == PlotEndDate(j,1)
  69. truelat(j) = D.lat{j}(l,1);
  70. truelon(j) = D.lon{j}(l,1);
  71. else
  72. end
  73.  
  74. end
  75.  
  76. end
  77.  
  78.  
  79. % plotting where the drifters travelled, with distinctions between
  80. % if/in which direction they exited the straight of georgia
  81.  
  82. for h=1:height(D)
  83.  
  84. if truelon(h) <= -125.19 && truelat(h) >= 50
  85. plot(D.lon{h}(:,1), D.lat{h}(:,1),'color',[.1 .7 .1 .5]);
  86. countA = countA + 1;
  87.  
  88. elseif truelat(h) <= 48.78
  89. plot(D.lon{h}(:,1), D.lat{h}(:,1),'color',[.7 .1 .1 .5]);
  90. countB = countB + 1;
  91.  
  92. else
  93. plot(D.lon{h}(:,1), D.lat{h}(:,1),'color',[.5 .5 .7 .5]);
  94. countC = countC + 1;
  95. end
  96. hold on;
  97.  
  98. end
  99.  
  100. % plotting the starting points in blue, and the ending points in either
  101. % red (land) or green (sea) depending on whether they end up on land
  102. % before the project was finished
  103.  
  104. hold on;
  105.  
  106. for p = 1:height(D)
  107.  
  108. plot (D.lon{p}(1,1),D.lat{p}(1,1),'-o','MarkerFaceColor',[0 0 .75],'MarkerEdgeColor','k')
  109.  
  110. if D.firstLifeTime(p)~=0
  111. plot (truelon(p),truelat(p),'-o','MarkerFaceColor',[0 .75 0],'MarkerEdgeColor','k')
  112. else
  113. plot (truelon(p),truelat(p),'-o','MarkerFaceColor',[.75 0 0],'MarkerEdgeColor','k')
  114. end
  115.  
  116. end
  117.  
  118. % adding text to the map relaying how many drifters went ashore, left the
  119. % straight of georgia to the north, and left the straight of georgia to the
  120. % south
  121.  
  122. hold on;
  123.  
  124. text(-124.5,50.75,{[num2str(countC) ' tracks ground'];
  125.  
  126. [num2str(countB) ' tracks leave the SoG to the south'];
  127.  
  128. [num2str(countA) ' tracks leave the SoG to the north']});
  129.  
  130. % a legend defining which lines correspond to which data, and which dots
  131. % correspond with which starting or ending point
  132.  
  133. hold on;
  134.  
  135. lgnd = zeros(6, 1);
  136.  
  137. lgnd(1) = plot(NaN,NaN,'o-','MarkerFaceColor',[0 0 .75],'MarkerEdgeColor','k');
  138.  
  139. lgnd(2) = plot(NaN,NaN,'o-','MarkerFaceColor',[.75 0 0],'MarkerEdgeColor','k');
  140.  
  141. lgnd(3) = plot(NaN,NaN,'o-','MarkerFaceColor',[0 .75 0],'MarkerEdgeColor','k');
  142.  
  143. lgnd(4) = plot(NaN,NaN,'color',[.5 .5 .7]);
  144.  
  145. lgnd(5) = plot(NaN,NaN,'color',[.7 .1 .1]);
  146.  
  147. lgnd(6) = plot(NaN,NaN,'color',[.1 .7 .1]);
  148.  
  149. legend(lgnd,'starting point','ends on land','ends at sea','SoG',...
  150. 'exit north','exit south','Location','southwest');
  151.  
  152. legend('boxoff');
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement