function data_available(theYears, dataDirectory, plotDirectory, siteA, siteB); % % data_available(theYears, dataDirectory, plotDirectory, siteA, siteB); % %Function to create the data available plot for the MBLT report for %theYears specified. Uses the concatenated data sets. %Soupy Alexander, 10/28/03 %Set up the order of the plots plotVars = {'current'; 'temperature'; 'salinity'; 'attenuation'; 'pressure'}; plotVarNames = {'Current'; 'Temperature'; 'Salinity'; 'Attenuation'; 'Pressure'; ... 'Sediment'; 'Traps'}; plotLocs = [51 45 40 35 30]; theDepths = [5 10 1]; theColors = {'b'; 'r'; 'g'}; t = []; for indexYear = 1:length(theYears) targetYear = theYears(indexYear); figure, orient landscape, hold on for indexVar = 1:length(plotVars) moorHit = {}; targetVar = plotVars{indexVar}; %Site A for indexFile = 1:length(siteA) fileName = siteA(indexFile).fileList; fileMoor = fileName(1:4); startTime = siteA(indexFile).startTime; gregStart = gregorian(startTime); endTime = siteA(indexFile).endTime; gregEnd = gregorian(endTime); inYears = gregStart(1):1:gregEnd(1); theVars = siteA(indexFile).dataTypes; %If the data file doesn't have any years of interest, skip it if ~ismember(targetYear, inYears) | ismember(fileMoor, moorHit) | ... ~ismember(targetVar, theVars) continue end moorHit = [moorHit(:); {fileMoor}]; matStart = julian2datenum(startTime); matEnd = julian2datenum(endTime); if findstr('adc', fileName) %ADCP stuff plot([matStart matEnd], [plotLocs(1)-4 plotLocs(1)-4], ... 'linewidth', 7, 'color', 'y') t(length(t)+1) = text(mean([max([matStart datenum(targetYear, 1, 1)]) ... min([matEnd datenum(targetYear, 12, 31)])]), plotLocs(1) - 4, ... fileName(1:4)); set(t(length(t)), 'fontsize', 8, 'color', 'k', 'clipping', 'on', ... 'horiz', 'center'); continue end theDepth = siteA(indexFile).instDepth; waterDepth = siteA(indexFile).waterDepth; if isnan(waterDepth) waterDepth = 34; end distFrom = waterDepth - theDepth; targDepths = [24 10 1]; targDepthDist = abs(targDepths - distFrom); [junk, hitDepth] = min(targDepthDist); plot([matStart matEnd], [plotLocs(indexVar)-hitDepth plotLocs(indexVar)-hitDepth], ... 'linewidth', 7, 'color', theColors{hitDepth}) t(length(t)+1) = text(mean([max([matStart datenum(targetYear, 1, 1)]) ... min([matEnd datenum(targetYear, 12, 31)])]), plotLocs(indexVar)-hitDepth, ... fileName(1:4)); set(t(length(t)), 'fontsize', 8, 'color', 'k', 'clipping', 'on', ... 'horiz', 'center'); end end %Sediment trap data [theNums, theText] = xlsread(fullfile(dataDirectory, 'all_traps.xls'), ... 'LNB Traps'); theNums = [repmat(NaN, 1, size(theText, 2)); theNums]; trapType = theText(:,19); for index = 1:length(trapType) if isempty(trapType{index}) trapType(index) = {' '}; end end theHonjos = strmatch('honjo', lower(trapType)); theTubes = strmatch('tube', lower(trapType)); honjoA_deploy = theNums(theHonjos,4) + datenum('30-Dec-1899'); honjoA_recover = theNums(theHonjos,6) + datenum('30-Dec-1899'); plot([honjoA_deploy honjoA_recover], [24 24], 'linewidth', 7, 'color', 'm'); tubeA_deploy = theNums(theTubes,4) + datenum('30-Dec-1899'); tubeA_recover = theNums(theTubes,6) + datenum('30-Dec-1899'); plot([tubeA_deploy tubeA_recover], [23 23], 'linewidth', 7, 'color', 'c'); %Plot parameters axis([datenum(targetYear, 1, 1) datenum(targetYear, 12, 31) 20 52]) theTicks = []; for index = 1:12 theTicks = [theTicks(:); datenum(targetYear, index, 1)]; end set(gca, 'xtick', theTicks) datetick('x', 3, 'keeplimits', 'keepticks') plotLocs = plotLocs(:); set(gca, 'ytick', flipud([plotLocs - 1.5; [24; 23]]), 'yticklabel', flipud(plotVarNames)) box('on') bigAx = gca; axPosition = get(bigAx, 'Position'); axPositionNew = axPosition; axPositionNew(2) = axPosition(2) + 0.25*axPosition(4); axPositionNew(4) = axPosition(4)*0.75; axPositionNew(1) = axPosition(1) + axPosition(1)*0.05; set(bigAx, 'Position', axPositionNew) axPosition(4) = axPosition(4)*0.2; lilAx = subplot('position', axPosition); hold on plot([4 5], [6 6], 'b', 'linewidth', 7); text(5.5, 6, '= 5 meters deep'); plot([4 5], [5 5], 'r', 'linewidth', 7); text(5.5, 5, '= 10 meters above bottom'); plot([4 5], [4 4], 'g', 'linewidth', 7); text(5.5, 4, '= 1 meter above the bottom'); plot([4 5], [3 3], 'y', 'linewidth', 7); text(5.5, 3, '= ADCP measurement'); plot([4 5], [2 2], 'm', 'linewidth', 7); text(5.5, 2, '= Honjo Trap measurement'); plot([4 5], [1 1], 'c', 'linewidth', 7); text(5.5, 1, '= Tube Trap measurement'); axis([0 12 0 7]) axis('off') printTitle = ['a_dcov_' num2str(targetYear, '%.0f')]; axisTitle = ['Site A Data Coverage, ' num2str(targetYear, '%.0f')]; suptitle(axisTitle) print(gcf, '-dpdf', fullfile(plotDirectory, printTitle)); close %%%%%%%%%%%%%%%%%%%%Site B%%%%%%%%%%%%%%%%%%%%%%%%%% if targetYear < 1997 continue end figure, orient landscape, hold on for indexVar = 1:length(plotVars) moorHit = {}; targetVar = plotVars{indexVar}; %Site B for indexFile = 1:length(siteB) fileName = siteB(indexFile).fileList; fileMoor = fileName(1:4); startTime = siteB(indexFile).startTime; gregStart = gregorian(startTime); endTime = siteB(indexFile).endTime; gregEnd = gregorian(endTime); inYears = gregStart(1):1:gregEnd(1); theVars = siteB(indexFile).dataTypes; %If the data file doesn't have any years of interest, skip it if ~ismember(targetYear, inYears) | ismember(fileMoor, moorHit) | ... ~ismember(targetVar, theVars) continue end moorHit = [moorHit(:); {fileMoor}]; matStart = julian2datenum(startTime); matEnd = julian2datenum(endTime); if findstr('adc', fileName) %ADCP stuff plot([matStart matEnd], [plotLocs(1)-4 plotLocs(1)-4], ... 'linewidth', 7, 'color', 'y') t(length(t)+1) = text(mean([max([matStart datenum(targetYear, 1, 1)]) ... min([matEnd datenum(targetYear, 12, 31)])]), plotLocs(1) - 4, ... fileName(1:4)); set(t(length(t)), 'fontsize', 8, 'color', 'k', 'clipping', 'on', ... 'horiz', 'center'); continue end theDepth = siteB(indexFile).instDepth; waterDepth = siteB(indexFile).waterDepth; if isnan(waterDepth) waterDepth = 23; end distFrom = waterDepth - theDepth; targDepths = [22 11 1]; targDepthDist = abs(targDepths - distFrom); [junk, hitDepth] = min(targDepthDist); plot([matStart matEnd], [plotLocs(indexVar)-hitDepth plotLocs(indexVar)-hitDepth], ... 'linewidth', 7, 'color', theColors{hitDepth}) t(length(t)+1) = text(mean([max([matStart datenum(targetYear, 1, 1)]) ... min([matEnd datenum(targetYear, 12, 31)])]), plotLocs(indexVar)-hitDepth, ... fileName(1:4)); set(t(length(t)), 'fontsize', 8, 'color', 'k', 'clipping', 'on', ... 'horiz', 'center'); end end %Sediment trap data [theNums, theText] = xlsread(fullfile(dataDirectory, 'all_traps.xls'), ... 'Scituate Traps'); theNums = [repmat(NaN, 1, size(theNums, 2)); theNums]; trapType = theText(:,19); for index = 1:length(trapType) if isempty(trapType{index}) trapType(index) = {' '}; end end theHonjos = strmatch('honjo', lower(trapType)); theTubes = strmatch('tube', lower(trapType)); honjoA_deploy = theNums(theHonjos,1) + datenum('30-Dec-1899'); honjoA_recover = theNums(theHonjos,3) + datenum('30-Dec-1899'); plot([honjoA_deploy honjoA_recover], [24 24], 'linewidth', 7, 'color', 'm'); tubeA_deploy = theNums(theTubes,1) + datenum('30-Dec-1899'); tubeA_recover = theNums(theTubes,3) + datenum('30-Dec-1899'); plot([tubeA_deploy tubeA_recover], [23 23], 'linewidth', 7, 'color', 'c'); %Plot parameters axis([datenum(targetYear, 1, 1) datenum(targetYear, 12, 31) 20 52]) theTicks = []; for index = 1:12 theTicks = [theTicks(:); datenum(targetYear, index, 1)]; end set(gca, 'xtick', theTicks) datetick('x', 3, 'keeplimits', 'keepticks') plotLocs = plotLocs(:); set(gca, 'ytick', flipud([plotLocs - 1.5; [24; 23]]), 'yticklabel', flipud(plotVarNames)) box('on') bigAx = gca; axPosition = get(bigAx, 'Position'); axPositionNew = axPosition; axPositionNew(2) = axPosition(2) + 0.25*axPosition(4); axPositionNew(4) = axPosition(4)*0.75; axPositionNew(1) = axPosition(1) + axPosition(1)*0.05; set(bigAx, 'Position', axPositionNew) axPosition(4) = axPosition(4)*0.2; lilAx = subplot('position', axPosition); hold on plot([4 5], [6 6], 'b', 'linewidth', 7); text(5.5, 6, '= 5 meters deep'); plot([4 5], [5 5], 'r', 'linewidth', 7); text(5.5, 5, '= 10 meters above bottom'); plot([4 5], [4 4], 'g', 'linewidth', 7); text(5.5, 4, '= 1 meter above the bottom'); plot([4 5], [3 3], 'y', 'linewidth', 7); text(5.5, 3, '= ADCP measurement'); plot([4 5], [2 2], 'm', 'linewidth', 7); text(5.5, 2, '= Honjo Trap measurement'); plot([4 5], [1 1], 'c', 'linewidth', 7); text(5.5, 1, '= Tube Trap measurement'); axis([0 12 0 7]) axis('off') printTitle = ['b_dcov_' num2str(targetYear, '%.0f')]; axisTitle = ['Site B Data Coverage, ' num2str(targetYear, '%.0f')]; suptitle(axisTitle) print(gcf, '-dpdf', fullfile(plotDirectory, printTitle)); close end