function fanCurveManual(nfit)
% fanCurveManual  Data reduction for fan curve. Data entered manually
%
% Synopsis:  fanCurveManual
%            fanCurveManual(nfit)
%
% Input:  nfit = (optional) degree of polynomial curve fit to fan curve
%                Default:  nfit = 4;

if nargin<1, nfit=4;  end

% --- Get data
[dn,dplen,vdpp,vdpn,emf,rzone,patm,name] = myFanData(false);

% --- Convert pressure and temperature data.  All routines are vectorized
dp = Omega05dp(vdpp);               %  Delta p across plenum:  Pa
p  = patm + dp;                     %  Absolute p upstream of nozzle, Pa
dpn = Omega10dp(vdpn);              %  Delta p across nozzle, Pa
T = Ttemp(emf,thermistorT(rzone));  %  T upstream of nozzle, C

% --- Loop over converted data to compute flow rate.  nozzleFlow is not vectorized
Q = zeros(size(dn));   %  preallocate
b = dn/dplen;          %  b = beta
for i=1:length(dn)
  Q(i) = nozzleFlow(dn(i),dn(i)/dplen,dpn(i),p(i),T(i));    % nominal flow rate
end

% --- Print table of results
fprintf('\nData for %s:\n',name);
fprintf('\n     T1      dn         dp1      dpn         Q\n');
fprintf('    (C)     (cm)        (Pa)     (Pa)      (m^3/s)\n');
for i=1:length(dn)
  fprintf('%8.2f  %8.4f  %8.2f  %8.1f  %10.6f\n',T(i),dn(i)*100,dp(i),dpn(i),Q(i));
end

% --- Obtain curve fit, plot data 
c = polyfit(Q,dp,nfit);
Qfit = linspace(0,max(Q));
dpfit = polyval(c,Qfit);
plot(Q,dp,'o',Qfit,dpfit,'--');
legend('Data',sprintf('Degree %d fit',nfit));
xlabel('Q  (m^3/s)');    ylabel('\Delta p  (Pa)');

% --- Print curve fit coefficients
fprintf('\nPolynomial coefficients in fit to fan curve data:\n');
for i=1:length(c)
  fprintf('\t%20.11e  Q^(%d)\n',c(i),nfit-i+1);
end