ndbc_wind_time = [];
ndbc_wind_dir_deg = [];
ndbc_wind_speed = [];
ndbc_wind_gust_speed = [];
ndbc_wave_time = [];
ndbc_wave_sigheight = [];
ndbc_wave_domperiod = [];
ndbc_wave_dir_deg = [];
ndbc_wind_power = [];
ndbc_wave_power = [];
ndbc_rad_time = [];
ndbc_rad_swpower1 = [];
ndbc_rad_swpower2 = [];

year = '2006';
mm = importdata(['46042h' year '.txt']);
mm.data = mm.data';
test = size(mm.data);

% Check to see if file has 'mm' column...a pretty fragile test, but should
% work for now...
if test(1) == 18
    offset = 1;
elseif test(1) == 17
    offset = 0;
else
    return;
end;

% ---------------------------------
% This file is most useful met data....  might or might not 'mm' column...
% 'YYYY'    'MM'    'DD'    'hh'    'mm'    'WD'    'WSPD'    'GST'    'WVHT'    'DPD'    'APD'    'MWD'    'BAR'    'ATMP'   'WTMP'    'DEWP'    'VIS'    'TIDE'
if offset == 0
    time = datenum(mm.data(1,:), mm.data(2,:), mm.data(3,:), mm.data(4,:),0, 0);
else
    time = datenum(mm.data(1,:), mm.data(2,:), mm.data(3,:), mm.data(4,:),mm.data(5,:), 0);
end;

ndbc_wind_time = [ndbc_wind_time time];
ndbc_wind_dir_deg = [ndbc_wind_dir_deg clean(mm.data(5+offset,:), 998, 1)];  % Units are degrees...
ndbc_wind_speed = [ndbc_wind_speed clean(mm.data(6+offset,:), 98, 1)];    % Units are m/s
ndbc_wind_gust_speed = [ndbc_wind_gust_speed clean(mm.data(7+offset,:), 98, 1)]; % Units are m/s
ndbc_wave_time = [ndbc_wave_time time];
ndbc_wave_sigheight = [ndbc_wave_sigheight clean(mm.data(8+offset,:), 98, 1)]; % Units are m
ndbc_wave_domperiod = [ndbc_wave_domperiod clean(mm.data(9+offset,:), 98, 1)]; % Units are s
ndbc_wave_dir_deg = [ndbc_wave_dir_deg clean(mm.data(11+offset,:), 998, 1)]; % Units are s

% Compute wind and wave power
ndbc_wind_power = [ndbc_wind_power 1.168 * clean(mm.data(6+offset,:), 98, 1).^3/2];
ndbc_wave_power = [ndbc_wave_power 1027 * 9.8^2 * clean(mm.data(8+offset,:), 98, 1).^2 .* clean(mm.data(9+offset,:), 98, 1) / (8*pi)];

clear mm time test offset

% ---------------------------------
% This file is radiation data....
mm = importdata(['46042r' year '.txt']);
mm.data = mm.data';

%  YYYY MM DD hh mm  SRAD1  SRAD2   LRAD
ndbc_rad_time = [ndbc_rad_time datenum(mm.data(1,:), mm.data(2,:), mm.data(3,:), mm.data(4,:),mm.data(5,:), 0)];
ndbc_rad_swpower1 = [ndbc_rad_swpower1 mm.data(6,:)];    % Units are W/m2
ndbc_rad_swpower2 = [ndbc_rad_swpower2 mm.data(7,:)];    % Units are W/m2

% ---------------------------------
% This file is just wind data....
mm = importdata(['46042c' year '.txt']);
mm.data = mm.data';

% YYYY MM DD hh mm DIR  SPD GDR GSP GTIME
wind_time = datenum(mm.data(1,:), mm.data(2,:), mm.data(3,:), mm.data(4,:),mm.data(5,:), 0);
wind_dir_deg = mm.data(6,:);  % Units are degrees...
wind_speed = mm.data(7,:);    % Units are m/s
wind_gust_dir_deg = mm.data(8,:); % Units are degrees
wind_gust_speed = mm.data(9,:); % Units are m/s
wind_gust_time = mm.data(10,:); % Units are minutes of hour...





