NCCOOS Trac Projects: Top | Web | Platforms | Processing | Viz | Sprints | Sandbox | (Wind)

root/gliderproc/trunk/gliderCTD_3DPlots.m

Revision 498 (checked in by cbc, 11 years ago)

Initial Calloway revisions to Seim revisions.

Line 
1 %
2 %  gliderCTD_3DPlots.m
3 %
4 %  Purpose: Generate set of 3D plots of glider CTD data with bathymetry
5 %
6 %  Author:  William Stark
7 %           Marine Sciences Department
8 %           UNC-Chapel Hill
9 %
10 %  Created: 11 June 2012
11 %
12 %////////////////////////////////////////////////////////////////////////////////////
13
14 function gliderCTD_3DPlots(config, nLegEndPoints, strLegEndPoints,...
15                            strDeploymentNumber, strLegNumber, legNumber, lonlim, latlim,...
16                            ztop, zbottom, gpsLat, gpsLon, depth, pres,...
17                            salinCorrected, salinBounds, densCorrected, densBounds,...
18                            temp, tempBounds,...
19                            plotFlag_Temperature3D, plotFlag_Salinity3D,...
20                            plotFlag_Density3D,...
21                            plotFlag_AllGliderTracks)
22
23                        
24     % get start/end points strings and indices for this leg...
25     nLegStart = nLegEndPoints(legNumber+1, 1);
26     nLegEnd = nLegEndPoints(legNumber+1, 2);
27     strLegStart = char(strLegEndPoints(legNumber+1, 1));
28     strLegEnd = char(strLegEndPoints(legNumber+1, 2));
29                                              
30     % select data corresponding to the passed-in leg endpoints...
31     gpsLat = gpsLat(nLegStart:nLegEnd);
32     gpsLon = gpsLon(nLegStart:nLegEnd);
33     pres = pres(nLegStart:nLegEnd);
34     depth = depth(nLegStart:nLegEnd);
35     temp = temp(nLegStart:nLegEnd);
36     salinCorrected = salinCorrected(nLegStart:nLegEnd);
37     densCorrected = densCorrected(nLegStart:nLegEnd);
38     % chlor = chlor(nLegStart:nLegEnd);
39    
40     % set strings for plot titles...
41     strGliderName = config.glider_name;
42     strDeployment = ['Deployment ', strDeploymentNumber];
43     if (strcmp(strLegNumber, '0'))
44         strLeg = 'Complete';
45     else
46         strLeg = ['Leg ', strLegNumber, '   ( ', strLegStart, ' to ', strLegEnd, ' )'];
47     end
48    
49    
50    
51     % mooring locations LB1, LB2 and LB3...
52     % LB1  (shelf):         33 10.172 N   78 20.007 W
53     % LB2  (shelf break):   32 56.419 N   78 05.926 W
54     % LB2  (upper slope):   32 51.142 N   78 00.793 W
55     lb1Lat = 3300 + 10.172;   lb1Lon = -7800 - 20.007;
56     lb2Lat = 3200 + 56.419;   lb2Lon = -7800 - 5.926;
57     lb3Lat = 3200 + 51.142;   lb3Lon = -7800 - 0.793;
58    
59     % convert lats and lons to digital degrees...
60     lb1Lat = ddmm2decdeg(lb1Lat);   lb1Lon = ddmm2decdeg(lb1Lon);
61     lb2Lat = ddmm2decdeg(lb2Lat);   lb2Lon = ddmm2decdeg(lb2Lon);
62     lb3Lat = ddmm2decdeg(lb3Lat);   lb3Lon = ddmm2decdeg(lb3Lon);
63
64     % arrays for drawing vertical marker lines...
65     LB1_X = [lb1Lon lb1Lon];   LB1_Y = [lb1Lat lb1Lat];   LB1_Z = [0 zbottom];
66     LB2_X = [lb2Lon lb2Lon];   LB2_Y = [lb2Lat lb2Lat];   LB2_Z = [0 zbottom];
67     LB3_X = [lb3Lon lb3Lon];   LB3_Y = [lb3Lat lb3Lat];   LB3_Z = [0 zbottom];
68    
69    
70     % LOAD ETOPO1 BATHYMETRY ////////////////////////////////////////////////////////////
71     % load etopo1 dataset...
72     % etopo usage:  [map,maplegend] = etopo(dirname, scalefactor, latlim, lonlim)
73     [Z,refvec] = etopo('BATHYMETRY/DATA/etopo/etopo1_bed_c.flt', 1, latlim, lonlim);
74     % mask above sea-level (land) or below the passed-in depth (zbottom)
75     idx = find(Z>0 | Z<zbottom);
76     Z(idx) = NaN;
77     [Nrows, Ncols]= size(Z);
78     Xspace = linspace(lonlim(1), lonlim(2), Ncols);
79     Yspace = linspace(latlim(1), latlim(2), Nrows);
80     [XI, YI] = meshgrid(Xspace, Yspace);
81     %////////////////////////////////////////////////////////////////////////////////////
82
83     % OR...
84    
85     % LOAD COASTAL RELIEF MODEL (CRM) Vol 2 BATHYMETRY //////////////////////////////////
86 %     % load crm dataset...
87 %     samplefactor = 1;
88 %     [Z,refvec] = crmBinaryRead('BATHYMETRY/DATA/crm/se_atl_crm_v1.flt', samplefactor, latlim, lonlim);
89 %     % mask above sea-level (land) or below the passed-in depth (zbottom)
90 %     idx = find(Z>0 | Z<zbottom);
91 %     Z(idx) = NaN;
92 %     [Nrows, Ncols]= size(Z);
93 %     Xspace = linspace(lonlim(1), lonlim(2), Ncols);
94 %     Yspace = linspace(latlim(1), latlim(2), Nrows);
95 %     [XI, YI] = meshgrid(Xspace, Yspace);
96     %////////////////////////////////////////////////////////////////////////////////////
97
98    
99    
100     % load East coast border data set...
101     load('BATHYMETRY/DATA/world/eastUS.mat');
102     whichLAT = find(cillat<latlim(1) | cillat>latlim(2));
103     cillat(whichLAT) = NaN*ones(size(whichLAT));
104     clear whichLAT;
105     whichLON = find(cillong<lonlim(1) | cillong>lonlim(2));
106     cillong(whichLON) = NaN*ones(size(whichLON));
107     clear whichLON;
108
109    
110    
111     %***** DRAW 3D TEMPERATURE PLOT *****************************************************
112     if (plotFlag_Temperature3D==1)
113         % 3D color plot of temperature (with bathymetry surface)...
114         figure('Position', [10,10,1600,900]);
115         % plot the coastline...
116         plot3(cillong, cillat, 0*ones(size(cillong)), 'k-', 'linewidth', [3]);
117         hold on;       
118         % plot the bathymetry surface...
119         HndlBATH = surf(XI, YI, Z);
120         %set(HndlBATH, 'facecolor', [0.75 0.75 0.75], 'edgecolor', [0.5 0.5 0.5]);
121         set(HndlBATH, 'facecolor', [0.75 0.75 0.75], 'edgecolor', 'none');
122         set(gca, 'box', 'on', 'position', [0.1227 0.2024 0.7727 0.6235]);   
123         % lighting and shading bath...
124         camlight right;
125         lighting phong;
126         material dull;
127         set(HndlBATH, 'edgecolor', 'none');   
128         hold on;
129         % vertical marker lines at mooring locations
130         plot3(LB1_X, LB1_Y, LB1_Z, 'k', 'linewidth', 5);
131         hold on;
132         plot3(LB2_X, LB2_Y, LB2_Z, 'k', 'linewidth', 5);
133         hold on;
134         plot3(LB3_X, LB3_Y, LB3_Z, 'k', 'linewidth', 5);
135         hold on;
136         % surface marker symbol at mooring locations
137         plot3(lb1Lon, lb1Lat, 0, 'ko', 'LineWidth', 3, 'MarkerEdgeColor','k', 'MarkerFaceColor','k', 'MarkerSize', 12);
138         hold on;
139         plot3(lb2Lon, lb2Lat, 0, 'ko', 'LineWidth', 3, 'MarkerEdgeColor','k', 'MarkerFaceColor','k', 'MarkerSize', 12);
140         hold on;
141         plot3(lb3Lon, lb3Lat, 0, 'ko', 'LineWidth', 3, 'MarkerEdgeColor','k', 'MarkerFaceColor','k', 'MarkerSize', 12);
142         hold on;
143         % plot temperature profile
144         hc = ccplot3(gpsLon, gpsLat, -depth, temp, tempBounds, '.', 10);
145         grid on;
146         axis([lonlim latlim zbottom ztop]);
147         hc = colorbar;
148         set(hc, 'fontsize', 12);
149         xlabel('Longitude', 'fontsize', 18);
150         ylabel('Latitude', 'fontsize', 18);
151         zlabel('Depth (m)', 'fontsize', 18);
152         title(['TEMPERATURE (°C)  -  ', strGliderName, ' , ', strDeployment, ' , ', strLeg, '  '], 'fontsize', 20, 'fontweight', 'bold');
153
154         % SAVE FILE and SAVE VIEW buttons
155 %         global prefilename pixcount HndlSAVE
156 %         pixcount = 1;
157 %         prefilename = 'etopo1_example';
158 %         HndlSAVE = uicontrol( ...
159 %             'Style','pushbutton', ...
160 %             'Units','normalized', ...
161 %             'Position',[.75 .05 .20 .05], ...
162 %             'String',['SAVE ' prefilename '_' sprintf('%02d', pixcount)], ...
163 %             'Callback',['save_fig;']);
164 %
165 %         HndlVIEW = uicontrol( ...
166 %             'Style','pushbutton', ...
167 %             'Units','normalized', ...
168 %             'Position',[.75 .00 .20 .05], ...
169 %             'String',['SAVE VIEW'], ...
170 %             'Callback',['[AZ, EL] = view; viewdata = [AZ, EL]; save(''./viewdata.mat'', ''viewdata'')']);
171     end
172
173
174     %***** DRAW 3D SALINITY PLOT *****************************************************
175     if (plotFlag_Salinity3D==1)
176         % 3D color plot of salinity (with bathymetry surface)...
177         figure('Position', [10,10,1600,900]);
178         % plot the coastline...
179         plot3(cillong, cillat, 0*ones(size(cillong)), 'k-', 'linewidth', [3]);
180         hold on;
181         % plot the bathymetry surface...
182         HndlBATH = surf(XI, YI, Z);
183         %set(HndlBATH, 'facecolor', [0.75 0.75 0.75], 'edgecolor', [0.5 0.5 0.5]);
184         set(HndlBATH, 'facecolor', [0.75 0.75 0.75], 'edgecolor', 'none');
185         set(gca, 'box', 'on', 'position', [0.1227 0.2024 0.7727 0.6235]);
186         % lighting and shading bath...
187         camlight right;
188         lighting phong;
189         material dull;
190         set(HndlBATH, 'edgecolor', 'none');
191         hold on;
192         % vertical marker lines at mooring locations
193         plot3(LB1_X, LB1_Y, LB1_Z, 'k', 'linewidth', 5);
194         hold on;
195         plot3(LB2_X, LB2_Y, LB2_Z, 'k', 'linewidth', 5);
196         hold on;
197         plot3(LB3_X, LB3_Y, LB3_Z, 'k', 'linewidth', 5);
198         hold on;
199         % surface marker symbol at mooring locations
200         plot3(lb1Lon, lb1Lat, 0, 'ko', 'LineWidth', 3, 'MarkerEdgeColor','k', 'MarkerFaceColor','k', 'MarkerSize', 12);
201         hold on;
202         plot3(lb2Lon, lb2Lat, 0, 'ko', 'LineWidth', 3, 'MarkerEdgeColor','k', 'MarkerFaceColor','k', 'MarkerSize', 12);
203         hold on;
204         plot3(lb3Lon, lb3Lat, 0, 'ko', 'LineWidth', 3, 'MarkerEdgeColor','k', 'MarkerFaceColor','k', 'MarkerSize', 12);
205         hold on;
206         % plot salinity profile
207         hc = ccplot3(gpsLon, gpsLat, -depth, salinCorrected, salinBounds, '.', 10);
208         grid on;
209         axis([lonlim latlim zbottom ztop]);
210         hc = colorbar;
211         set(hc, 'fontsize', 12);
212         xlabel('Longitude', 'fontsize', 18);
213         ylabel('Latitude', 'fontsize', 18);
214         zlabel('Depth (m)', 'fontsize', 18);
215         title(['SALINITY (psu)  -  ', strGliderName, ' , ', strDeployment, ' , ', strLeg, '  '], 'fontsize', 20, 'fontweight', 'bold');
216     end
217
218    
219     %***** DRAW 3D DENSITY PLOT *****************************************************
220     if (plotFlag_Density3D==1)
221         % 3D color plot of density (with bathymetry surface)...
222         figure('Position', [10,10,1600,900]);
223         % plot the coastline...
224         plot3(cillong, cillat, 0*ones(size(cillong)), 'k-', 'linewidth', [3]);
225         hold on;
226         % plot the bathymetry surface...
227         HndlBATH = surf(XI, YI, Z);
228         %set(HndlBATH, 'facecolor', [0.75 0.75 0.75], 'edgecolor', [0.5 0.5 0.5]);
229         set(HndlBATH, 'facecolor', [0.75 0.75 0.75], 'edgecolor', 'none');
230         set(gca, 'box', 'on', 'position', [0.1227 0.2024 0.7727 0.6235]);
231         % lighting and shading bath...
232         camlight right;
233         lighting phong;
234         material dull;
235         set(HndlBATH, 'edgecolor', 'none');
236         hold on;
237         % vertical marker lines at mooring locations
238         plot3(LB1_X, LB1_Y, LB1_Z, 'k', 'linewidth', 5);
239         hold on;
240         plot3(LB2_X, LB2_Y, LB2_Z, 'k', 'linewidth', 5);
241         hold on;
242         plot3(LB3_X, LB3_Y, LB3_Z, 'k', 'linewidth', 5);
243         hold on;
244         % surface marker symbol at mooring locations
245         plot3(lb1Lon, lb1Lat, 0, 'ko', 'LineWidth', 3, 'MarkerEdgeColor','k', 'MarkerFaceColor','k', 'MarkerSize', 12);
246         hold on;
247         plot3(lb2Lon, lb2Lat, 0, 'ko', 'LineWidth', 3, 'MarkerEdgeColor','k', 'MarkerFaceColor','k', 'MarkerSize', 12);
248         hold on;
249         plot3(lb3Lon, lb3Lat, 0, 'ko', 'LineWidth', 3, 'MarkerEdgeColor','k', 'MarkerFaceColor','k', 'MarkerSize', 12);
250         hold on;
251         % plot density profile
252         hc = ccplot3(gpsLon, gpsLat, -depth, densCorrected, densBounds, '.', 10);
253         grid on;
254         axis([lonlim latlim zbottom ztop]);
255         hc = colorbar;
256         set(hc, 'fontsize', 12);
257         xlabel('Longitude', 'fontsize', 18);
258         ylabel('Latitude', 'fontsize', 18);
259         zlabel('Depth (m)', 'fontsize', 18);
260         title(['DENSITY (kg m-3)  -  ', strGliderName, ' , ', strDeployment, ' , ', strLeg, '  '], 'fontsize', 20, 'fontweight', 'bold');
261     end
262    
263    
264     %***** DRAW 3D CHLOROPHYLL PLOT *****************************************************
265     % if (plotFlag_Chlorophyll3D==1)
266     %     % 3D color plot of chlorophyll (with bathymetry surface)...
267     %     figure('Position', [10,10,1600,900]);
268     %     % plot the coastline...
269     %     plot3(cillong, cillat, 0*ones(size(cillong)), 'k-', 'linewidth', [3]);
270     %     hold on;
271     %     % plot the bathymetry surface...
272     %     HndlBATH = surf(XI, YI, Z);
273     %     %set(HndlBATH, 'facecolor', [0.75 0.75 0.75], 'edgecolor', [0.5 0.5 0.5]);
274     %     set(HndlBATH, 'facecolor', [0.75 0.75 0.75], 'edgecolor', 'none');
275     %     set(gca, 'box', 'on', 'position', [0.1227 0.2024 0.7727 0.6235]);
276     %     % lighting and shading bath...
277     %     camlight right;
278     %     lighting phong;
279     %     material dull;
280     %     set(HndlBATH, 'edgecolor', 'none');
281     %     hold on;
282     %     % vertical marker lines at mooring locations
283     %     plot3(LB1_X, LB1_Y, LB1_Z, 'k', 'linewidth', 5);
284     %     hold on;
285     %     plot3(LB2_X, LB2_Y, LB2_Z, 'k', 'linewidth', 5);
286     %     hold on;
287     %     plot3(LB3_X, LB3_Y, LB3_Z, 'k', 'linewidth', 5);
288     %     hold on;
289     %     % surface marker symbol at mooring locations
290     %     plot3(lb1Lon, lb1Lat, 0, 'ko', 'LineWidth', 3, 'MarkerEdgeColor','k', 'MarkerFaceColor','k', 'MarkerSize', 12);
291     %     hold on;
292     %     plot3(lb2Lon, lb2Lat, 0, 'ko', 'LineWidth', 3, 'MarkerEdgeColor','k', 'MarkerFaceColor','k', 'MarkerSize', 12);
293     %     hold on;
294     %     plot3(lb3Lon, lb3Lat, 0, 'ko', 'LineWidth', 3, 'MarkerEdgeColor','k', 'MarkerFaceColor','k', 'MarkerSize', 12);
295     %     hold on;
296     %     % plot chlorophyll profile
297     %     hc = ccplot3(gpsLon, gpsLat, -depth, chlor, chlorBounds, '.', 10);
298     %     grid on;
299     %     axis([lonlim latlim zbottom ztop]);
300     %     hc = colorbar;
301     %     set(hc, 'fontsize', 12);
302     %     xlabel('Longitude', 'fontsize', 18);
303     %     ylabel('Latitude', 'fontsize', 18);
304     %     zlabel('Depth (m)', 'fontsize', 18);
305     %     title(['CHLOROPHYLL (ug/l)  -  ', strGliderName, ' , ', strDeployment, ' , ', strLeg, '  '], 'fontsize', 20, 'fontweight', 'bold');
306     % end
307    
308    
309     %***** DRAW PLOT OF COMPLETE GLIDER TRACKS *****************************************************
310     if (plotFlag_AllGliderTracks==1)
311         % LOAD AND CONCATONATE ALL DATA FOR PELAGIA ///////////////////////////////   
312         gpsLat_TOTAL_PELAGIA = [];
313         gpsLon_TOTAL_PELAGIA = [];
314         for i=1:3
315             % mat file path string...
316             strMatFilePath = strcat('GLIDER_DATA_LEVEL1/Pelagia_Deployment', num2str(i), '_CTD_L1.mat');
317             % load glider sensor data from mat file...
318             load(strMatFilePath);
319             % concatonate data into a single vector...
320             gpsLat_TOTAL_PELAGIA = [gpsLat_TOTAL_PELAGIA; gpsLat];
321             gpsLon_TOTAL_PELAGIA = [gpsLon_TOTAL_PELAGIA; gpsLon];
322         end
323
324         % LOAD AND CONCATONATE ALL DATA FOR RAMSES ////////////////////////////////   
325         gpsLat_TOTAL_RAMSES = [];
326         gpsLon_TOTAL_RAMSES = [];
327         for i=1:3
328             % mat file path string...
329             strMatFilePath = strcat('GLIDER_DATA_LEVEL1/Ramses_Deployment', num2str(i), '_CTD_L1.mat');
330             % load glider sensor data from mat file...
331             load(strMatFilePath);
332             % concatonate data into a single vector...
333             gpsLat_TOTAL_RAMSES = [gpsLat_TOTAL_RAMSES; gpsLat];
334             gpsLon_TOTAL_RAMSES = [gpsLon_TOTAL_RAMSES; gpsLon];       
335         end
336
337         % set new lat/lon and sea bottom bounds for the 2D glider track plot...
338         lonlim = [-79 -77];  latlim = [32 34];
339         zbottom = -1100;  % 1100m depth encompasses all bathymetry data bounded by
340                           % the above lat/lon limits
341
342 %         % load etopo1 dataset...
343 %         % etopo usage:  [map,maplegend] = etopo(dirname, scalefactor, latlim, lonlim)
344 %         [Z,refvec] = etopo('BATHYMETRY/DATA/etopo/etopo1_bed_c.flt', 1, latlim, lonlim);
345 %         % mask above sea-level (land) or below the passed-in depth (zbottom)
346 %         idx = find(Z>0 | Z<zbottom);
347 %         Z(idx) = NaN;
348 %         [Nrows, Ncols]= size(Z);
349 %         Xspace = linspace(lonlim(1), lonlim(2), Ncols);
350 %         Yspace = linspace(latlim(1), latlim(2), Nrows);
351 %         [XI, YI] = meshgrid(Xspace, Yspace);
352 %
353 %         % load East coast border data set...
354 %         load('BATHYMETRY/DATA/world/eastUS.mat');
355 %         whichLAT = find(cillat<latlim(1) | cillat>latlim(2));
356 %         cillat(whichLAT) = NaN*ones(size(whichLAT));
357 %         clear whichLAT;
358 %         whichLON = find(cillong<lonlim(1) | cillong>lonlim(2));
359 %         cillong(whichLON) = NaN*ones(size(whichLON));
360 %         clear whichLON;   
361
362         % plot of complete glider tracks (all 3 deployments) with contour lines...
363         figure('Position', [10,10,1200,1200]);
364         % plot the coastline...
365         plot(cillong, cillat, 'k-', 'linewidth', [5]);
366         hold on;
367         % plot the bathymetry contours (black lines) and labels...
368         [C,h] = contour(XI, YI, -Z, [20 30 60 120 200 300 400 500 600 700 800 900 1000], 'LineColor', [0 0 0]);
369         clabel(C, h, 'FontSize', 14);
370         hold on;
371         % plot the complete tracks for Pelagia...
372         plot(gpsLon_TOTAL_PELAGIA, gpsLat_TOTAL_PELAGIA, 'b.', 'MarkerSize', 15);
373         hold on;
374         % plot the complete tracks for Ramses...
375         plot(gpsLon_TOTAL_RAMSES, gpsLat_TOTAL_RAMSES, 'r.', 'MarkerSize', 15);
376         hold on;
377         % draw symbol at each mooring location
378         plot(lb1Lon, lb1Lat, 'ko', 'LineWidth', 3, 'MarkerEdgeColor','k', 'MarkerFaceColor','g', 'MarkerSize', 15);
379         hold on;
380         plot(lb2Lon, lb2Lat, 'ko', 'LineWidth', 3, 'MarkerEdgeColor','k', 'MarkerFaceColor','g', 'MarkerSize', 15);
381         hold on;
382         plot(lb3Lon, lb3Lat, 'ko', 'LineWidth', 3, 'MarkerEdgeColor','k', 'MarkerFaceColor','g', 'MarkerSize', 15);
383         axis([lonlim latlim]);
384         xlabel('Longitude', 'fontsize', 18);
385         ylabel('Latitude', 'fontsize', 18);
386         title(['Pelagia (Blue) and Ramses (Red) - Complete Glider Tracks    '], 'fontsize', 20, 'fontweight', 'bold');
387     end
388
389
390 end
Note: See TracBrowser for help on using the browser.