function attn_temp_curr(theSite) % attn_temp_curr(theSite) % %Program to create time series plots of beam attenuation, temperature, and %current for theSite. %Soupy Alexander, 4/2004 %This Matlab m-file was used to create portions of U.S. Geological Survey %Data Series 85. Although this program has been used by the USGS, no %warranty, expressed or implied, is made by the USGS or the United States %Government as to the accuracy and functioning of the program and related %program material nor shall the fact of distribution constitute any such %warranty, and no responsibility is assumed by the USGS in connection %therewith. %Citation: Butman, Bradford, Alexander, P. Soupy, Anderson, S.P., %Lightsom, F.L., Scotti, Alberto, and Beardsley, R.C., 2004, The %Massachusetts Bay Internal Wave Experiment, August 1998: Data Report: %U.S. Geological Survey Data Series 85, 1 DVD-ROM. theDir = 'C:\SCHTUFF\MASS_BAY\MBAY_IWAVE\REPORT\DATAFILES'; printDir = 'C:\SCHTUFF\MASS_BAY\MBAY_IWAVE\REPORT\'; thePlotTypes = {'all'; '0819_0824'; '0822'}; for indexType = 3%1:length(thePlotTypes) plotType = thePlotTypes{indexType}; if strcmp(plotType, 'all') %Full Record theTimeFrame = [datenum(1998, 07, 29, 00, 00, 00) datenum(1998, 09, 02, 00, 00, 00)]; theTicks = min(theTimeFrame):5:max(theTimeFrame); theCode = 6; theExt = '-a1h'; elseif strcmp(plotType, '0819_0824') %August 19-24 theTimeFrame = [datenum(1998, 8, 19, 00, 00, 00) datenum(1998, 08, 25, 00, 00, 00)]; theTicks = min(theTimeFrame):1:max(theTimeFrame); theCode = 6; theExt = '-a'; elseif strcmp(plotType, '0822') % August 22 theTimeFrame = [datenum(1998, 8, 22, 00, 00, 00) datenum(1998, 08, 23, 00, 00, 00)]; theTicks = min(theTimeFrame):2/24:max(theTimeFrame); theCode = 15; theExt = '-a'; end if strcmp(upper(theSite), 'B') files1 = {['5383att' theExt '.cdf']; ['5371tcp' theExt '.nc']}; files2 = {['5383sc' theExt '.cdf']; ['5371tcp' theExt '.nc']}; files3 = {['5371v' theExt '_d1.nc']; ['5371v' theExt '_d2.nc']}; if ~strcmp(plotType, 'all') theLimits = {[0 4]; [4.5 5.5]; [0 50]}; else theLimits = {[0 4]; [4.5 5.5]; [0 20]}; end waterDepth = 85; elseif strcmp(upper(theSite), 'C') files1 = {['5343att' theExt '.cdf']; ['5351tcp' theExt '.nc']}; files2 = {['5343sc' theExt '.cdf']; ['5351tcp' theExt '.nc']}; files3 = {['5344' theExt '.nc']}; if ~strcmp(plotType, 'all') theLimits = {[0 4]; [5 15]; [0 70]}; else theLimits = {[0 4]; [5 10]; [0 50]}; end waterDepth = 51; end theMult = [1 1 1]; plotTitles = {'Beam Attenuation'; 'Temperature'; 'Current Speed'}; colList = {'r'; 'b'; 'g'; 'm'; 'c'; 'k'}; figure, orient landscape for indexPlot = 1:3 eval(['targFiles = files' num2str(indexPlot)' ';']); subplot(3,1,indexPlot), hold on clear thePlots theDepths theTitles for indexFile = 1:length(targFiles) ncID = netcdf(fullfile(theDir, targFiles{indexFile}), 'nowrite'); theTime = singlejd(ncID{'time'}(:), ncID{'time2'}(:)); %if strcmp(targFiles{indexFile}, 'vmcm0009.epic') % waterDepth = 85; %else % waterDepth = ncID.water_depth{:}; %end if indexPlot == 1 theData = ncID{'ATTN_55'}(:); if isempty(theData) theData = ncID{'att_1'}(:); end theDepths(indexFile) = ncID{'depth'}(:); theTitles{indexFile} = [num2str(waterDepth - theDepths(indexFile), ... '%.1f') ' mab']; thePlots(indexFile) = plot(julian2datenum(theTime), theData, colList{indexFile}); ylabel('Attn (m^-^1)') elseif indexPlot == 2 theData = ncID{'T_20'}(:); if isempty(theData) theData = ncID{'temperature'}(:); end if isempty(theData) theData = ncID{'temp'}(:); end theDepths(indexFile) = ncID{'depth'}(:); theTitles{indexFile} = [num2str(waterDepth - theDepths(indexFile), ... '%.1f') ' mab']; thePlots(indexFile) = plot(julian2datenum(theTime), theData, colList{indexFile}); ylabel('Temp (^oC)') else theU = ncID{'u_1205'}(:); theV = ncID{'v_1206'}(:); if isempty(theU) theU = ncID{'east'}(:); theV = ncID{'north'}(:); end [theTheta, theMag] = cart2pol(theU, theV); newTheta = 20*(pi/180)-theTheta; %theData = theMag.*cos(newTheta) * theMult(indexPlot); theData = sqrt(theU.^2 + theV.^2); theDepths(indexFile) = ncID{'depth'}(:); theTitles{indexFile} = [num2str(waterDepth - theDepths(indexFile), ... '%.1f') ' mab']; thePlots(indexFile) = plot(julian2datenum(theTime), theData, colList{indexFile}); ylabel('Current (cm/s)') l = line([min(theTimeFrame) max(theTimeFrame)], [0 0]); set(l, 'color', 'k') end end ylim(theLimits{indexPlot}) xlim(theTimeFrame) set(gca, 'xtick', theTicks) datetick('x', theCode, 'keepticks', 'keeplimits') box('on') l = legend(thePlots, theTitles); set(l, 'fontsize', 8) title(['Site ' upper(theSite) ', ' plotTitles{indexPlot}]) end printTitle = ['atc_' lower(theSite) '_' plotType '.pdf']; print(gcf, '-dpdf', fullfile(printDir, printTitle)) close end