% DEVELOPED BY: % _ _ _ _ _ __ % /\/\ (_) | __| |__ __ _(_) | \ \ ___ _ __ ___ ___ % / \| | |/ /| '_ \ / _` | | | \ \/ _ \| '_ \ / _ | __| % / /\/\ \ | < | | | | (_| | | | /\_/ / (_) | | | | __|__ \ % \/ \/_|_|\_\|_| |_|\__,_|_|_| \___/ \___/|_| |_|\___|___/ % % DESCRIPTION: This tool imports .csv data from the NSRDB, perfroms a % statistical analysis of the data, and produces publication quality plots. % % INSTRUCTIONS: % 1) Find the station ID that most closely matches the location of the % facility from the NSRDB. % (http://rredc.nrel.gov/solar/old_data/nsrdb/1991-2005/NSRDB_StationsMeta.csv) % 2) Download approriate solar data from the NSRDB % (ftp://ftp3.ncdc.noaa.gov/pub/data/nsrdb) % 2) Unzip the both archives and extract the folder into the same directory % as this file. % 3) Run Matlab code. % 4) When prompted enter the station ID. % 5) Images will be exported to the same directory as this file. %% INITIALIZE % Clear command window clc; % Remove all items from workspace memory clear all; % Deletes all figures whose handles are not hidden close all; % Set default text interpreter to latex set(0, 'defaulttextinterpreter', 'tex'); % Create the waitbar handle h_bar = waitbar(0, 'Initializing...', 'Name', 'Progress Bar'); %% IMPORT 1991-2005 NRSDB DATA % Define data set by NRSDB station ID station.id = input('Input NSRDB Station ID number: ', 's'); % Define years in NRSDB data set (1991-2005) years = 1991 : 2005; % Loop to load multiple years of data for yr = 1 : length(years) % Import the data, extracting spreadsheet dates in MATLAB datenum format [~, ~, raw, dateNums] = xlsread([num2str(station.id) '\' num2str(station.id) '_' num2str(years(yr)) '.csv'], ... [num2str(station.id) '_' num2str(years(yr))], ... '', '', @convertSpreadsheetDates); raw = raw(2 : end, :); dateNums = dateNums(2 : end, :); % Replace date strings by MATLAB datenums R = ~cellfun(@isequalwithequalnans, dateNums, raw) & cellfun('isclass', raw, 'char'); raw(R) = dateNums(R); % Create output variable nsrdb{yr} = cell2mat(raw); % Update wait bar perc = ((yr-1)/length(years))*100; waitbar(perc/100, h_bar, sprintf('%3.1f Percent Complete...', perc)) end % Close waitbar waitbar(100, h_bar, 'Completed!') close(h_bar) % Clear temporary variables clearvars raw dateNums R; %% VARIABILITY ANALYSIS % Loop through years for yr = 1 : length(years) % Extract and separate date and time components [y, m, d, h] = datevec(nsrdb{yr}(:, 1) + nsrdb{yr}(:, 2)); % Loop through months for mo = 1 : 12 % Loop though hours for hr = 0 : 23 % Extract and find mean hourly values for each month % Global horizontal irradiance diurnalglo(yr, mo, hr + 1) = mean(nsrdb{yr}((m == mo & h == hr), 7)); % Direct normal irradiance diurnaldir(yr, mo, hr + 1) = mean(nsrdb{yr}((m == mo & h == hr), 10)); % Diffuse horizontal irradiance diurnaldif(yr, mo, hr + 1) = mean(nsrdb{yr}((m == mo & h == hr), 13)); % Dry bulb temperature diurnaldrybulb(yr, mo, hr + 1) = mean(nsrdb{yr}((m == mo & h == hr), 26)); % Wind speed diurnalwindspd(yr, mo, hr + 1) = mean(nsrdb{yr}((m == mo & h == hr), 34)); % Wind direction diurnalwinddir(yr, mo, hr + 1) = mean(nsrdb{yr}((m == mo & h == hr), 36)); end % Extract and find mean monthly values for each year % Global horizontal irradiance monthlyglo(yr, mo) = mean(nsrdb{yr}((m == mo), 7)); % Direct normal irradiance monthlydir(yr, mo) = mean(nsrdb{yr}((m == mo), 10)); % Diffuse horizontal irradiance monthlydif(yr, mo) = mean(nsrdb{yr}((m == mo), 13)); % Dry bulb temperature monthlydrybulb(yr, mo) = mean(nsrdb{yr}((m == mo), 26)); % Wind speed monthlywindspd(yr, mo) = mean(nsrdb{yr}((m == mo), 34)); % Wind direction monthlywinddir(yr, mo) = mean(nsrdb{yr}((m == mo), 36)); end % Extract and find mean annual values % Global horizontal irradiance annualmeanglo(yr) = mean(nsrdb{yr}(:, 7)); % Direct normal irradiance annualmeandir(yr) = mean(nsrdb{yr}(:, 10)); % Diffuse horizontal irradiance annualmeandif(yr) = mean(nsrdb{yr}(:, 13)); % Dry bulb temperature annualmeandrybulb(yr) = mean(nsrdb{yr}(:, 26)); % Wind speed annualmeanwindspd(yr) = mean(nsrdb{yr}(:, 34)); % Wind direction annualmeanwinddir(yr) = mean(nsrdb{yr}(:, 36)); end % Averages data from all years diurnalmeanglo = squeeze(mean(diurnalglo, 1)); diurnalmeandir = squeeze(mean(diurnaldir, 1)); diurnalmeandif = squeeze(mean(diurnaldif, 1)); diurnalmeandrybulb = squeeze(mean(diurnaldrybulb, 1)); diurnalmeanwindspd = squeeze(mean(diurnalwindspd, 1)); diurnalmeanwinddir = squeeze(mean(diurnalwinddir, 1)); monthlymeanglo = squeeze(mean(monthlyglo, 1)); monthlymeandir = squeeze(mean(monthlydir, 1)); monthlymeandif = squeeze(mean(monthlydif, 1)); monthlymeandrybulb = squeeze(mean(monthlydrybulb, 1)); monthlymeanwindspd = squeeze(mean(monthlywindspd, 1)); monthlymeanwinddir = squeeze(mean(monthlywinddir, 1)); monthlystdglo = std(monthlyglo, 1); monthlystddir = std(monthlydir, 1); monthlystddif = std(monthlydif, 1); monthlystddrybulb = std(monthlydrybulb, 1); monthlystdwindspd = std(monthlywindspd, 1); monthlystdwinddir = std(monthlywinddir, 1); %% SOLAR IRRADIANCE %% ANNUAL VARIABILITY PLOT data = {annualmeanglo, annualmeandir, annualmeandif}; titlestrings = {'Global Horizontal Irradiance', ... 'Direct Normal Irradiance', ... 'Diffuse Horizontal Irradiance'}; rmap = {107/255, 179/255, 216/255}; gmap = {128/255, 186/255, 90/255}; bmap = {158/255, 53/255, 26/255}; filename = '1 - Annual Variability of Solar Irradiance.tif'; % Initialize figure figure1 = figure(1); set(figure1, ... 'PaperUnits' , 'inches' , ... 'PaperSize' , [8.5 11] , ... 'Units' , 'inches' , ... 'Position' , [0 0 6 8] ); hold on; for i = 1 : 3 % Intialize subplot subplot(3, 1, i); hold on; % Line plot of mean annual means plot([0 100], [mean(data{i}) mean(data{i})], ... 'LineStyle' , '--' , ... 'LineWidth' , 1 , ... 'Color' , 'k' ); % Line plot of annual means plot(data{i}, ... 'LineStyle' , '-' , ... 'Color' , [rmap{i} gmap{i} bmap{i}] , ... 'LineWidth' , 2.5 , ... 'Marker' , 'o' , ... 'MarkerSize' , 6 , ... 'MarkerEdgeColor' , [.3 .3 .3] , ... 'MarkerFaceColor' , [rmap{i} gmap{i} bmap{i}] ); % Define plot properties set(gca, ... 'Box' , 'off' , ... 'FontSize' , 6 , ... 'GridLineStyle' , ':' , ... 'LineWidth' , 1 , ... 'PlotBoxAspectRatio', [3 1 1] , ... 'TickDir' , 'out' , ... 'TickLength' , [.01 .01] , ... 'XTickLabel' , 1991 : 2005 , ... 'XColor' , [.3 .3 .3] , ... 'YColor' , [.3 .3 .3] , ... 'XGrid' , 'on' , ... 'YGrid' , 'on' , ... 'XLim' , [1 15] , ... 'YMinorTick' , 'on' , ... 'XTick' , 1 : 15 ); title(titlestrings{i}, 'FontSize', 10); xlabel('Year', 'FontSize', 8); ylabel('Irradiance (W/{m^2})', 'FontSize', 8); end % Export and close figure set(gcf, 'PaperPositionMode', 'auto'); print('-dtiff', '-r500', filename); close; %% MONTHLY MEAN VARIABILITY PLOT data = {monthlymeanglo, monthlymeandir, monthlymeandif}; datastd = {monthlystdglo, monthlystddir, monthlystddif}; titlestrings = {'Global Horizontal Irradiance', ... 'Direct Normal Irradiance', ... 'Diffuse Horizontal Irradiance'}; xtickstrings = {'Jan' 'Feb' 'Mar' 'Apr' 'May' 'Jun' 'Jul' 'Aug' 'Sep' 'Oct' 'Nov' 'Dec'}; rmap = {107/255, 179/255, 216/255}; gmap = {128/255, 186/255, 90/255}; bmap = {158/255, 53/255, 26/255}; filename = '2 - Monthly Variability of Solar Irradiance.tif'; % Initialize figure figure2 = figure(2); set(figure2, ... 'PaperUnits' , 'inches' , ... 'PaperSize' , [8.5 11] , ... 'Units' , 'inches' , ... 'Position' , [0 0 6 8] ); hold on; for i = 1 : 3 % Intialize subplot subplot(3, 1, i); hold on; % Fill plot of standard deviation fill([1:12 12:-1:1],[data{i}+datastd{i} fliplr(data{i}-datastd{i})], [.9 .9 .9], ... 'EdgeColor' , [.9 .9 .9] ); % Line plot of annual means plot(data{i}, ... 'LineStyle' , '-' , ... 'Color' , [rmap{i} gmap{i} bmap{i}] , ... 'LineWidth' , 2.5 , ... 'Marker' , 'o' , ... 'MarkerSize' , 6 , ... 'MarkerEdgeColor' , [.3 .3 .3] , ... 'MarkerFaceColor' , [rmap{i} gmap{i} bmap{i}] ); % Define plot properties set(gca, ... 'Box' , 'off' , ... 'FontSize' , 6 , ... 'GridLineStyle' , ':' , ... 'LineWidth' , 1 , ... 'PlotBoxAspectRatio', [3 1 1] , ... 'TickDir' , 'out' , ... 'TickLength' , [.01 .01] , ... 'XTickLabel' , xtickstrings , ... 'XColor' , [.3 .3 .3] , ... 'YColor' , [.3 .3 .3] , ... 'XGrid' , 'on' , ... 'YGrid' , 'on' , ... 'XLim' , [1 12] , ... 'YMinorTick' , 'on' , ... 'XTick' , 1 : 12 ); title(titlestrings{i}, 'FontSize', 10); xlabel('Month', 'FontSize', 8); ylabel('Irradiance (W/{m^2})', 'FontSize', 8); end % Export and close figure set(gcf, 'PaperPositionMode', 'auto'); print('-dtiff', '-r500', filename); close; %% DIURNAL VARIABILITY PLOT % Define strings in month vector for plot titles monthstrings = {'January' 'February' 'March' 'April' 'May' 'June' 'July' 'August' 'September' 'October' 'November' 'December'}; % Initialize figure figure3 = figure(3); set(figure3, ... 'PaperUnits' , 'inches' , ... 'PaperSize' , [8.5 11] , ... 'Units' , 'inches' , ... 'Position' , [0 0 6 8] ); hold on; % Create a 3x4 grid of plots for i = 1 : 4 for j = 1 : 3 % Intialize subplot subplot(4, 3, (i - 1) * 3 + j); % Define plot properties set(gca, ... 'Box' , 'on' , ... 'FontSize' , 6 , ... 'GridLineStyle' , ':' , ... 'LineWidth' , 1 , ... 'PlotBoxAspectRatio', [1 1 1] , ... 'TickDir' , 'out' , ... 'TickLength' , [.02 .02] , ... 'XColor' , [.3 .3 .3] , ... 'YColor' , [.3 .3 .3] , ... 'XGrid' , 'on' , ... 'YGrid' , 'on' , ... 'XLim' , [0 24] , ... 'YLim' , [0 1200] , ... 'XMinorTick' , 'on' , ... 'YMinorTick' , 'on' , ... 'XTick' , 0 : 4 : 24 , ... 'YTick' , 0 : 200 : 1200); % Add title from month vector title(monthstrings((i - 1) * 3 + j), 'FontSize', 8); % Plot the three components of irradiance on same plot hold on; plot(diurnalmeanglo((i - 1) * 3 + j, :), ... 'Color' , [107/255 133/255 158/255] , ... 'LineWidth' , 1.5); plot(diurnalmeandir((i - 1) * 3 + j, :), ... 'Color' , [179/255 186/255 53/255] , ... 'LineWidth' , 1.5); plot(diurnalmeandif((i - 1) * 3 + j, :), ... 'Color' , [216/255 90/255 26/255] , ... 'LineWidth' , 1.5); % Add y-label to left plots if (j == 1) ylabel('Irradiance (W/{m^2})', 'FontSize', 8); end % Add x-label to bottom plots if (i == 4) xlabel('Hour of Day', 'FontSize', 8); end end end % Initialize legend legend3 = legend(gca, ... 'Global Horizontal' , ... 'Direct Normal' , ... 'Diffuse Horizontal' ); % Define legend properties set(legend3, ... 'FontSize' , 6 , ... 'Orientation' , 'horizontal' , ... 'Units' , 'inches' , ... 'Position' , [0.5 .125 5 .25] ); % Export and close figure set(gcf, 'PaperPositionMode', 'auto'); print('-dtiff', '-r500', '3 - Diurnal Variability of Solar Irradiance.tif'); close; %% TABULAR DATA PLOT % Load a data set of values into a matrix data = {diurnalmeanglo', diurnalmeandir',diurnalmeandif', monthlyglo, monthlydir, monthlydif}; titlestrings = {'Global Horizontal Irradiance', ... 'Direct Normal Irradiance', ... 'Diffuse Horizontal Irradiance', ... 'Global Horizontal Irradiance', ... 'Direct Normal Irradiance', ... 'Diffuse Horizontal Irradiance'}; xtickstrings = {'Jan' 'Feb' 'Mar' 'Apr' 'May' 'Jun' 'Jul' 'Aug' 'Sep' 'Oct' 'Nov' 'Dec'}; ytickstrings = {1 : 24, 1 : 24, 1 : 24, years, years, years}; xlabelstrings = {'Month of Year'}; ylabelstrings = {'Hour of Day', 'Hour of Day', 'Hour of Day', 'Year', 'Year', 'Year'}; rmap = {107, 179, 216, 107, 179, 216}; gmap = {128, 186, 90, 128, 186, 90}; bmap = {158, 53, 26, 158, 53, 26}; filename = {'4 - Tabular Data - Diurnal Global.tif', ... '5 - Tabular Data - Diurnal Direct.tif', ... '6 - Tabular Data - Diurnal Diffuse.tif', ... '7 - Tabular Data - Monthly Global.tif', ... '8 - Tabular Data - Monthly Direct.tif', ... '9 - Tabular Data - Monthly Diffuse.tif'}; for i = 1 : size(data, 2) % Specify colormap rgb(1, :) = 1:-((255-rmap{i})/255/128):(rmap{i}/255); rgb(2, :) = 1:-((255-gmap{i})/255/128):(gmap{i}/255); rgb(3, :) = 1:-((255-bmap{i})/255/128):(bmap{i}/255); % Initialize figure figure4 = figure(4); set(figure4, ... 'ColorMap' , rgb' , ... 'PaperUnits' , 'inches' , ... 'PaperSize' , [8.5 11] , ... 'Units' , 'inches' , ... 'Position' , [0 0 6 4] ); hold on; % Determine size of matrix [r c] = size(data{i}); % Create a colored plot of the matrix values imagesc(data{i}); % Create strings from the matrix values textstrings = num2str(data{i}(:), '%0.0f'); % Remove any space padding textstrings = strtrim(cellstr(textstrings)); % Create x and y coordinates for the strings [x, y] = meshgrid(1 : c, 1 : r); % Plot the strings plotstrings = text(x(:), y(:), textstrings(:), ... 'HorizontalAlignment' , 'center' , ... 'FontSize' , 6 ); % Plot grid xv1 = repmat((2 : c) - .5, [2 1]); xv1(end + 1, :) = NaN; xv2 = repmat([.5; c + .5; NaN], [1 r - 1]); yv1 = repmat((2 : r) - .5, [2 1]); yv1(end + 1, :) = NaN; yv2 = repmat([.5; r + .5; NaN], [1 c - 1]); line([xv1(:); xv2(:)], [yv2(:); yv1(:)], ... 'Color' , 'k' , ... 'HandleVisibility' , 'off' ); % Define plot properties set(gca, ... 'Box' , 'on' , ... 'FontSize' , 6 , ... 'LineWidth' , 1.5 , ... 'TickDir' , 'out' , ... 'TickLength' , [0.01 0.01] , ... 'YDir' , 'reverse' , ... 'XAxisLocation' , 'bottom' , ... 'YAxisLocation' , 'left' , ... 'XColor' , [.3 .3 .3] , ... 'YColor' , [.3 .3 .3] , ... 'XLim' , [0 c] + .5 , ... 'YLim' , [0 r] + .5 , ... 'XTickLabel' , xtickstrings , ... 'YTickLabel' , ytickstrings{i} , ... 'XTick' , 1 : 1 : c , ... 'YTick' , 1 : 1 : r ); title(titlestrings{i}, 'FontSize', 10); ylabel(ylabelstrings{i}, 'FontSize', 8); xlabel(xlabelstrings, 'FontSize', 8); colorbar4 = colorbar('Location', 'eastoutside', 'FontSize', 6); ylabel(colorbar4, 'Irradiance (W/{m^2})', 'FontSize', 8); % Export and close figure set(gcf, 'PaperPositionMode', 'auto'); print('-dtiff', '-r500', filename{i}); close; end %% METEROLOGICAL DATA %% ANNUAL VARIABILITY PLOT data = {annualmeandrybulb, annualmeanwindspd}; titlestrings = {'Dry Bulb Temperature', ... 'Wind Speed'}; ylabelstrings = {'Temperature (C^o)', ... 'Speed (m/s)'}; rmap = {167/255, 86/255}; gmap = {196/255, 31/255}; bmap = {201/255, 175/255}; filename = '10 - Annual Variability of Temperature and Wind.tif'; % Initialize figure figure1 = figure(1); set(figure1, ... 'PaperUnits' , 'inches' , ... 'PaperSize' , [8.5 11] , ... 'Units' , 'inches' , ... 'Position' , [0 0 6 5] ); hold on; for i = 1 : 2 % Intialize subplot subplot(2, 1, i); hold on; % Line plot of mean annual means plot([0 100], [mean(data{i}) mean(data{i})], ... 'LineStyle' , '--' , ... 'LineWidth' , 1 , ... 'Color' , 'k' ); % Line plot of annual means plot(data{i}, ... 'LineStyle' , '-' , ... 'Color' , [rmap{i} gmap{i} bmap{i}] , ... 'LineWidth' , 2.5 , ... 'Marker' , 'o' , ... 'MarkerSize' , 6 , ... 'MarkerEdgeColor' , [.3 .3 .3] , ... 'MarkerFaceColor' , [rmap{i} gmap{i} bmap{i}] ); % Define plot properties set(gca, ... 'Box' , 'off' , ... 'FontSize' , 6 , ... 'GridLineStyle' , ':' , ... 'LineWidth' , 1 , ... 'PlotBoxAspectRatio', [3 1 1] , ... 'TickDir' , 'out' , ... 'TickLength' , [.01 .01] , ... 'XTickLabel' , 1991 : 2005 , ... 'XColor' , [.3 .3 .3] , ... 'YColor' , [.3 .3 .3] , ... 'XGrid' , 'on' , ... 'YGrid' , 'on' , ... 'XLim' , [1 15] , ... 'YMinorTick' , 'on' , ... 'XTick' , 1 : 15 ); title(titlestrings{i}, 'FontSize', 10); xlabel('Year', 'FontSize', 8); ylabel(ylabelstrings{i}, 'FontSize', 8); end % Export and close figure set(gcf, 'PaperPositionMode', 'auto'); print('-dtiff', '-r500', filename); close; %% MONTHLY MEAN VARIABILITY PLOT data = {monthlymeandrybulb, monthlymeanwindspd}; datastd = {monthlystddrybulb, monthlystdwindspd}; titlestrings = {'Dry Bulb Temperature', ... 'Wind Speed'}; ylabelstrings = {'Temperature (C^o)', ... 'Speed (m/s)'}; xtickstrings = {'Jan' 'Feb' 'Mar' 'Apr' 'May' 'Jun' 'Jul' 'Aug' 'Sep' 'Oct' 'Nov' 'Dec'}; rmap = {167/255, 86/255}; gmap = {196/255, 31/255}; bmap = {201/255, 175/255}; filename = '11 - Monthly Variability of Temperature and Wind.tif'; % Initialize figure figure2 = figure(2); set(figure2, ... 'PaperUnits' , 'inches' , ... 'PaperSize' , [8.5 11] , ... 'Units' , 'inches' , ... 'Position' , [0 0 6 5] ); hold on; for i = 1 : 2 % Intialize subplot subplot(2, 1, i); hold on; % Fill plot of standard deviation fill([1:12 12:-1:1],[data{i}+datastd{i} fliplr(data{i}-datastd{i})], [.9 .9 .9], ... 'EdgeColor' , [.9 .9 .9] ); % Line plot of annual means plot(data{i}, ... 'LineStyle' , '-' , ... 'Color' , [rmap{i} gmap{i} bmap{i}] , ... 'LineWidth' , 2.5 , ... 'Marker' , 'o' , ... 'MarkerSize' , 6 , ... 'MarkerEdgeColor' , [.3 .3 .3] , ... 'MarkerFaceColor' , [rmap{i} gmap{i} bmap{i}] ); % Define plot properties set(gca, ... 'Box' , 'off' , ... 'FontSize' , 6 , ... 'GridLineStyle' , ':' , ... 'LineWidth' , 1 , ... 'PlotBoxAspectRatio', [3 1 1] , ... 'TickDir' , 'out' , ... 'TickLength' , [.01 .01] , ... 'XTickLabel' , xtickstrings , ... 'XColor' , [.3 .3 .3] , ... 'YColor' , [.3 .3 .3] , ... 'XGrid' , 'on' , ... 'YGrid' , 'on' , ... 'XLim' , [1 12] , ... 'YMinorTick' , 'on' , ... 'XTick' , 1 : 12 ); title(titlestrings{i}, 'FontSize', 10); xlabel('Month', 'FontSize', 8); ylabel(ylabelstrings{i}, 'FontSize', 8); end % Export and close figure set(gcf, 'PaperPositionMode', 'auto'); print('-dtiff', '-r500', filename); close; %% DIURNAL VARIABILITY PLOT % Define strings in month vector for plot titles monthstrings = {'January' 'February' 'March' 'April' 'May' 'June' 'July' 'August' 'September' 'October' 'November' 'December'}; % Initialize figure figure3 = figure(3); set(figure3, ... 'PaperUnits' , 'inches' , ... 'PaperSize' , [8.5 11] , ... 'Units' , 'inches' , ... 'Position' , [0 0 6 8] ); hold on; % Create a 3x4 grid of plots for i = 1 : 4 for j = 1 : 3 % Intialize subplot subplot(4, 3, (i - 1) * 3 + j); % Define plot properties set(gca, ... 'Box' , 'on' , ... 'FontSize' , 6 , ... 'GridLineStyle' , ':' , ... 'LineWidth' , 1 , ... 'PlotBoxAspectRatio', [1 1 1] , ... 'TickDir' , 'out' , ... 'TickLength' , [.02 .02] , ... 'XColor' , [.3 .3 .3] , ... 'YColor' , [.3 .3 .3] , ... 'XGrid' , 'on' , ... 'YGrid' , 'on' , ... 'XLim' , [0 24] , ... 'YLim' , [-10 40] , ... 'XMinorTick' , 'on' , ... 'YMinorTick' , 'on' , ... 'XTick' , 0 : 4 : 24 , ... 'YTick' , -10 : 5 : 40); % Add title from month vector title(monthstrings((i - 1) * 3 + j), 'FontSize', 8); % Plot the dry bulb temperature hold on; plot(diurnalmeandrybulb((i - 1) * 3 + j, :), ... 'Color' , [167/255 196/255 201/255] , ... 'LineWidth' , 1.5); % Add y-label to left plots if (j == 1) ylabel('Temperature (C)', 'FontSize', 8); end % Add x-label to bottom plots if (i == 4) xlabel('Hour of Day', 'FontSize', 8); end end end % Initialize legend legend3 = legend(gca, ... 'Dry Bulb Temperature'); % Define legend properties set(legend3, ... 'FontSize' , 6 , ... 'Orientation' , 'horizontal' , ... 'Units' , 'inches' , ... 'Position' , [0.5 .125 5 .25] ); % Export and close figure set(gcf, 'PaperPositionMode', 'auto'); print('-dtiff', '-r500', '12 - Diurnal Variability of Dry Bulb.tif'); close; %% TABULAR DATA PLOT % Load a data set of values into a matrix data = {diurnalmeandrybulb', monthlydrybulb}; titlestrings = {'Dry Bulb Temperature', ... 'Dry Bulb Temperature'}; xtickstrings = {'Jan' 'Feb' 'Mar' 'Apr' 'May' 'Jun' 'Jul' 'Aug' 'Sep' 'Oct' 'Nov' 'Dec'}; ytickstrings = {1 : 24, years}; xlabelstrings = {'Month of Year'}; ylabelstrings = {'Hour of Day', 'Years'}; rmap = {167, 167}; gmap = {196, 196}; bmap = {201, 201}; filename = {'13 - Tabular Data - Diurnal Dry Bulb.tif', ... '14 - Tabular Data - Monthly Dry Bulb.tif'}; for i = 1 : size(data, 2) % Specify colormap rgb(1, :) = [1:-((255-rmap{i})/255/128):(rmap{i}/255)]; rgb(2, :) = [1:-((255-gmap{i})/255/128):(gmap{i}/255)]; rgb(3, :) = [1:-((255-bmap{i})/255/128):(bmap{i}/255)]; % Initialize figure figure4 = figure(4); set(figure4, ... 'ColorMap' , rgb' , ... 'PaperUnits' , 'inches' , ... 'PaperSize' , [8.5 11] , ... 'Units' , 'inches' , ... 'Position' , [0 0 6 4] ); hold on; % Determine size of matrix [r c] = size(data{i}); % Create a colored plot of the matrix values imagesc(data{i}); % Create strings from the matrix values textstrings = num2str(data{i}(:), '%0.0f'); % Remove any space padding textstrings = strtrim(cellstr(textstrings)); % Create x and y coordinates for the strings [x, y] = meshgrid(1 : c, 1 : r); % Plot the strings plotstrings = text(x(:), y(:), textstrings(:), ... 'HorizontalAlignment' , 'center' , ... 'FontSize' , 6 ); % Plot grid xv1 = repmat((2 : c) - .5, [2 1]); xv1(end + 1, :) = NaN; xv2 = repmat([.5; c + .5; NaN], [1 r - 1]); yv1 = repmat((2 : r) - .5, [2 1]); yv1(end + 1, :) = NaN; yv2 = repmat([.5; r + .5; NaN], [1 c - 1]); line([xv1(:); xv2(:)], [yv2(:); yv1(:)], ... 'Color' , 'k' , ... 'HandleVisibility' , 'off' ); % Define plot properties set(gca, ... 'Box' , 'on' , ... 'FontSize' , 6 , ... 'LineWidth' , 1.5 , ... 'TickDir' , 'out' , ... 'TickLength' , [0.01 0.01] , ... 'YDir' , 'reverse' , ... 'XAxisLocation' , 'bottom' , ... 'YAxisLocation' , 'left' , ... 'XColor' , [.3 .3 .3] , ... 'YColor' , [.3 .3 .3] , ... 'XLim' , [0 c] + .5 , ... 'YLim' , [0 r] + .5 , ... 'XTickLabel' , xtickstrings , ... 'YTickLabel' , ytickstrings{i} , ... 'XTick' , 1 : 1 : c , ... 'YTick' , 1 : 1 : r ); title(titlestrings{i}, 'FontSize', 10); ylabel(ylabelstrings{i}, 'FontSize', 8); xlabel(xlabelstrings, 'FontSize', 8); colorbar4 = colorbar('Location', 'eastoutside', 'FontSize', 6); ylabel(colorbar4, 'Temperature (C)', 'FontSize', 8); % Export and close figure set(gcf, 'PaperPositionMode', 'auto'); print('-dtiff', '-r500', filename{i}); close; end %% DIURNAL VARIABILITY PLOT % Define strings in month vector for plot titles monthstrings = {'January' 'February' 'March' 'April' 'May' 'June' 'July' 'August' 'September' 'October' 'November' 'December'}; % Initialize figure figure3 = figure(3); set(figure3, ... 'PaperUnits' , 'inches' , ... 'PaperSize' , [8.5 11] , ... 'Units' , 'inches' , ... 'Position' , [0 0 6 8] ); hold on; % Create a 3x4 grid of plots for i = 1 : 4 for j = 1 : 3 % Intialize subplot subplot(4, 3, (i - 1) * 3 + j); % Define plot properties set(gca, ... 'Box' , 'on' , ... 'FontSize' , 6 , ... 'GridLineStyle' , ':' , ... 'LineWidth' , 1 , ... 'PlotBoxAspectRatio', [1 1 1] , ... 'TickDir' , 'out' , ... 'TickLength' , [.02 .02] , ... 'XColor' , [.3 .3 .3] , ... 'YColor' , [.3 .3 .3] , ... 'XGrid' , 'on' , ... 'YGrid' , 'on' , ... 'XLim' , [0 24] , ... 'YLim' , [0 10] , ... 'XMinorTick' , 'on' , ... 'YMinorTick' , 'on' , ... 'XTick' , 0 : 4 : 24 , ... 'YTick' , 0 : 1 : 10); % Add title from month vector title(monthstrings((i - 1) * 3 + j), 'FontSize', 8); % Plot the dry bulb temperature hold on; plot(diurnalmeanwindspd((i - 1) * 3 + j, :), ... 'Color' , [86/255 31/255 75/255] , ... 'LineWidth' , 1.5); % Add y-label to left plots if (j == 1) ylabel('Wind Speed (m/s)', 'FontSize', 8); end % Add x-label to bottom plots if (i == 4) xlabel('Hour of Day', 'FontSize', 8); end end end % Initialize legend legend3 = legend(gca, ... 'Wind Speed'); % Define legend properties set(legend3, ... 'FontSize' , 6 , ... 'Orientation' , 'horizontal' , ... 'Units' , 'inches' , ... 'Position' , [0.5 .125 5 .25] ); % Export and close figure set(gcf, 'PaperPositionMode', 'auto'); print('-dtiff', '-r500', '15 - Diurnal Variability of Wind Speed.tif'); close; %% DIURNAL VARIABILITY PLOT % Define strings in month vector for plot titles monthstrings = {'January' 'February' 'March' 'April' 'May' 'June' 'July' 'August' 'September' 'October' 'November' 'December'}; % Initialize figure figure3 = figure(3); set(figure3, ... 'PaperUnits' , 'inches' , ... 'PaperSize' , [8.5 11] , ... 'Units' , 'inches' , ... 'Position' , [0 0 6 8] ); hold on; % Create a 3x4 grid of plots for i = 1 : 4 for j = 1 : 3 % Intialize subplot subplot(4, 3, (i - 1) * 3 + j); % Plot the dry bulb temperature rose(diurnalmeanwinddir((i - 1) * 3 + j, :)./360.*2.*pi, 16); hline = findobj(gca, 'Type', 'line'); set(hline, ... 'Color' , [86/255 31/255 75/255] , ... 'LineWidth' , 2); % Define plot properties set(gca, ... 'Box' , 'on' , ... 'FontSize' , 6 , ... 'GridLineStyle' , ':' , ... 'LineWidth' , 1 , ... 'PlotBoxAspectRatio', [1 1 1] , ... 'TickDir' , 'out' , ... 'TickLength' , [.02 .02] , ... 'XColor' , [.3 .3 .3] , ... 'YColor' , [.3 .3 .3] , ... 'XGrid' , 'on' , ... 'YGrid' , 'on' , ... 'XMinorTick' , 'on' , ... 'YMinorTick' , 'on' ); % Add title from month vector title(monthstrings((i - 1) * 3 + j), 'FontSize', 8); % Add y-label to left plots if (j == 1) ylabel('Wind Direction (m/s)', 'FontSize', 8); end % Add x-label to bottom plots if (i == 4) xlabel('Hour of Day', 'FontSize', 8); end end end % Initialize legend legend3 = legend(gca, ... 'Wind Speed'); % Define legend properties set(legend3, ... 'FontSize' , 6 , ... 'Orientation' , 'horizontal' , ... 'Units' , 'inches' , ... 'Position' , [0.5 .125 5 .25] ); % Export and close figure set(gcf, 'PaperPositionMode', 'auto'); print('-dtiff', '-r500', '16 - Diurnal Variability of Wind Direction.tif'); close;