% Wind generator is 46" or 1.14 m in diameter.  
% Model Air Industrial serial number 47986 

% ------------------------------------------------------------------------
% --- Now lets get set to compare MTM2 data with NDBC data (taken at 1/6th
% the rate), assuming MTM2 and NDBC data already loaded...

wp = smooth(mtm2_windpower, 6);   % Average data first..
ndbc_mtm2_wp = interp1(mtm2_time, wp, ndbc_wind_time);  % Now interp to NDBC time

% Lets make some variables that have just the portion of the timeline where
% there is both MTM2 data and NDBC data...

ok = find(~isnan(ndbc_mtm2_wp));
t = ndbc_wind_time(ok);
pwp = ndbc_wind_power(ok);
mwp = ndbc_mtm2_wp(ok);
mw = ndbc_wind_speed(ok);

pwp = clean(pwp, 10000, 1);

% ------------------------------------------------------------------------
% Plot MTM2 measured and NDBC predicted power
hold off; plot(t, pwp, 'r'); hold on; plot(t, mwp);

% Plot fraction of time power less than a given level...
figure;
plot_lt_percent(0.19*pwp, 100)
hold on
plot_lt_percent(mwp, 100, 'r')

% ------------------------------------------------------------------------
% Plot Power Probability & Expectation Distributions...

% First NDBC buoy
[rngp, ipp] = plot_gt_probability(pwp, 0);
dpp = diff(ipp)./diff(rngp);
figure; loglog(rngp(1:160), dpp);
xlabel('NDBC Wind Power (W)');ylabel('Probability Distribution');
figure; loglog(rngp(1:160), dpp.*rngp(1:160))
xlabel('NDBC Wind Power (W)');ylabel('Power Production Distribution (W)');

% Now MTM2 data...
[rngm, imp] = plot_gt_probability(mwp, 100, '.');
dmp = diff(imp)./diff(rngm);
figure; loglog(rngm(2:99), dmp(2:99))
xlabel('MTM2 Wind Turbine Power (W)');ylabel('Probability Distribution');
figure; loglog(rngm(2:99), rngm(2:99).*dmp(2:99))
xlabel('MTM2 Wind Turbine Power (W)');ylabel('Power Production Distribution (W)');