clf;

temp=[7.56,4.97,0.14,-4.79,-11.1,-17.78,-23.5,-30.3,-32.47,-34.8,-37.1,-37.8,-38.7,-39.2,-39.68];
avg=[3062.5,1854.9,987.0,544.9,290.0,152.2,116.1,63.7,47.5,38.6,31.0,28.4,25.0,26.5,21.2];
avg_per_sec=avg./60;

%%Fit gives: 16.33*exp(0.1462*x)
%%General model Exp1:
%%       f(x) = a*exp(b*x)
%%Coefficients (with 95% confidence bounds):
%%       a =       16.33  (14.59, 18.06)
%%       b =      0.1462  (0.1301, 0.1624)

%%Goodness of fit:
%%  SSE: 20.67
%%R-square: 0.993
%%Adjusted R-square: 0.9925
%%RMSE: 1.261


fit_temp=[-40:.01:8];
fit_avg_per_sec=16.8*exp(.146.*fit_temp);

plot(temp,avg_per_sec,'*',fit_temp,fit_avg_per_sec);
xlabel('Temperature (C)');
ylabel('Average Counts/pixel/sec');
title('CCD Performance: Dark Current (Bias Subtracted)');
legend('Observed values','Best fit');

