Advertisement
Guest User

Untitled

a guest
Nov 16th, 2018
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.31 KB | None | 0 0
  1. % Code to load some oceanograhic data, display data as scatter plots,
  2. % compute a smoothed contour for 200m depth. This version shows the casts
  3. % at their actual distance taken rather than a pretty contour plot. This is
  4. % in preparation for the week 11 lab in which we will interpolate these
  5. % data onto an even perpendicular distance spacing and compute some
  6. % statistics.
  7. %
  8. % Updated CLJ 11/2018
  9.  
  10. clear;
  11. close all;
  12.  
  13. % Southern Vancouver Island (SVI) Grid of lats/lons
  14. load SouthVI.mat
  15.  
  16. % Put South VI grid into easier variables
  17. lonMap = SouthVI.lon; % longitude vector for the SVI map
  18. latMap = SouthVI.lat; % latitude vector for the SVI mapscta
  19. zMap = -SouthVI.depth; % 2D array of depths:
  20. % d=0 is the coastline, we will be interested in d=200m
  21. clear SouthVI; % don't need this any more
  22.  
  23. %% Temperature, salinity, density, and pressure for first half of
  24. % % leg E of FK009A cruise, August 2013
  25.  
  26. load FK009A_demo.mat
  27.  
  28. %% Do some preliminary calcs and make a nice plot
  29.  
  30. % Calculate a smooth version of the 200 m contour.
  31. [lon200 lat200] = calc200contour(lonMap, latMap, zMap);
  32.  
  33. % Make a basic map showing the track and a few depth contours
  34. figure(1); hold on;
  35. % Plot all contours - does this in function for tidiness of main script.
  36. southVImap(lonMap, latMap, zMap);
  37. % Now the "smoothed" 200m contour - pink
  38. plot(lon200, lat200, 'm', 'linewidth', 2);
  39. % Plot ship track - blue
  40. plot(lon, lat, 'b.', 'markersize', 10);
  41.  
  42. % Compute shortest distance of each ship point with data from the smoothed 200m depth contour
  43. dist200 = shortest_dist(lon, lat, lon200, lat200);
  44.  
  45. % Get the indices for individual tracks. Output variable is a cell array.
  46. inds=setupInds;
  47.  
  48.  
  49. %% Make scatter plots to show temperature as function of distance and depth
  50.  
  51. % -----------------------
  52. % MAKE SURE YOU UNDERSTAND WHAT meshgrid AND scatter do. We saw meshgrid
  53. % earlier in the term
  54. % -----------------------
  55. % just extract the shallowest 90m of depth and salinity arrays because
  56. % there are measurements at these depths on all tracks
  57. saln=saln(1:91,:);
  58. depths=depths(1:91);
  59.  
  60. % now make a plot that has profiles only where there are data to show
  61. % uneven distribution of casts
  62. figure(2); clf; k=0;
  63.  
  64.  
  65. for j=10:-1:1
  66. %pause;
  67.  
  68. % extract temps and distances
  69. ii=inds{j};
  70. subsal=saln(:,ii);
  71. xx=dist200(ii);
  72.  
  73. % we want to have a (dist,depth) pair for every temp measurement
  74. [mx,my]=meshgrid(xx,depths);
  75.  
  76. %This is where we do the actual plotting - this uses the built-in function scatter
  77. % scatter needs to be passed 1D arrays as arguments so we must flatten mx, my
  78. k=k+1;
  79. figure(2); %ADD TO LOOP TO CHOOSE CORRECT FIGURE ACTIVE - not essential here but important in lab
  80. makeScatterPlot(mx(:),my(:),subsal(:),j,k);
  81. colorbar;
  82. caxis([31 34]); % add after plotting once to see range of salinities
  83. xlim([-20 45]);
  84. ylabel('Depth (z)'); title(['Track' num2str(j) ' Temperature'])
  85.  
  86. %We only want the xlabel on the bottom row of subplots
  87. if k==9 | k==10
  88. xlabel('Distance from Shelf Break (km)')
  89. else
  90. set(gca,'xticklabel', [])
  91. end
  92.  
  93. end
  94.  
  95. %% save this to a file for lab 11
  96.  
  97. save lab11_data.mat lon lat dist200 depths saln inds
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement