function ccdSpecs=getZeissSpecs_v2(serialNum)

%% DESCRIPTION
% Take serial number input string from Zeiss CCD (also called the "Unit Number")
% and output the relavant parameters in the structure ccdSpecs.
% Reads CCD output files (e.g. 031107_05_CCD1_5.bin) and outputs times and
% data columns for processing.
%
% 
%Written by Samuel R. Hall June, 07 2004
%Harp Specs added for 44120, 44121 Mar 2007, Kirk Ullmann
%______________________________________________________________

%% INPUT
%string:  serialNum = serial number of spectrometer
%______________________________________________________________

%% OUTPUT
%Structure: ccdSpecs
%           orderingCode: '(1376-142)'
%                   type: 'MCS-CCD 265-665'
%              serialNum: '044121'
%       xSecConverterNum: '997K'
%              numPixels: 532
%               wvlRange: '261.68 nm - 667.42 nm'
%           wvlCoeffs3_0: [253.6580 0.8020 -1.4962e-005 0]
%              validPixs: [1x512 double]
%     confidenceInterval: '0.12 nm'
%                 QAdate: '2005-10-28'
%              slitWidth: '50 microns'
%                allWvls: [1x532 double]
%              wvlsValid: [1x512 double]
%%_________________________________________________________________

%% START FUNCTION
%HIAPER CCD SPECS
if serialNum=='044120'
    ccdSpecs.orderingCode='(1376-142)';
    ccdSpecs.type='MCS-CCD 265-665';
    ccdSpecs.serialNum=serialNum;
    ccdSpecs.xSecConverterNum='506K';
    ccdSpecs.numPixels=532;
    ccdSpecs.wvlRange='261.63 nm - 666.47 nm';
    ccdSpecs.wvlCoeffs3_0=[253.619, 0.80075, -1.59941e-5, 0];
    ccdSpecs.validPixs=10:521;
    ccdSpecs.confidenceInterval='0.12 nm';
    ccdSpecs.QAdate='2005-10-28';
    ccdSpecs.slitWidth='50 microns';
elseif serialNum=='044121'
    ccdSpecs.orderingCode='(1376-142)';
    ccdSpecs.type='MCS-CCD 265-665';
    ccdSpecs.serialNum=serialNum;
    ccdSpecs.xSecConverterNum='997K';
    ccdSpecs.numPixels=532;
    ccdSpecs.wvlRange='261.68 nm - 667.42 nm';
    ccdSpecs.wvlCoeffs3_0=[253.658, 0.801992, -1.49624e-5, 0];
    ccdSpecs.validPixs=10:521;
    ccdSpecs.confidenceInterval='0.12 nm';
    ccdSpecs.QAdate='2005-10-28';
    ccdSpecs.slitWidth='50 microns';
    
%HIAPER NIR/VIS CCD specs
elseif serialNum=='044839'  
    ccdSpecs.orderingCode='(1332-256)';
    ccdSpecs.type='PGS-NIR 2u2';
    ccdSpecs.serialNum=serialNum;
    ccdSpecs.xSecConverterNum='38';
    ccdSpecs.numPixels=256;
    ccdSpecs.wvlRange='2217.77 nm - 902.81 nm';
    ccdSpecs.wvlCoeffs3_0=[2217.77, -4.32425, -0.00259193, 2.82e-6, -2.14e-8];
    ccdSpecs.validPixs=0:255;
    ccdSpecs.confidenceInterval='0.39 nm';
    ccdSpecs.QAdate='2005-12-20';
    ccdSpecs.slitWidth='';
elseif serialNum=='044840'  
    ccdSpecs.orderingCode='(1332-256)';
    ccdSpecs.type='PGS-NIR 2u2';
    ccdSpecs.serialNum=serialNum;
    ccdSpecs.xSecConverterNum='37';
    ccdSpecs.numPixels=256;
    ccdSpecs.wvlRange='2215.39 nm - 902.30';
    ccdSpecs.wvlCoeffs3_0=[2215.39, -4.29359, -0.00274748, 3.44e-6, -2.29e-8];
    ccdSpecs.validPixs=0:255;
    ccdSpecs.confidenceInterval='0.39 nm';
    ccdSpecs.QAdate='2005-12-20';
    ccdSpecs.slitWidth='';
elseif serialNum=='044118'   
    ccdSpecs.orderingCode='(1376-119)';
    ccdSpecs.type='MCS 275-1075';
    ccdSpecs.serialNum=serialNum;
    ccdSpecs.xSecConverterNum='Spalt';
    ccdSpecs.numPixels=1024;
    ccdSpecs.wvlRange='261.01 nm - 1090.56 nm';
    ccdSpecs.wvlCoeffs3_0=[260.007, 0.828671, -6.79155e-7, -1.63153e-8];
    ccdSpecs.validPixs=0:1023;
    ccdSpecs.confidenceInterval='0.20 nm';
    ccdSpecs.QAdate='2007-10-21';
    ccdSpecs.slitWidth='';
elseif serialNum=='044119'  
    ccdSpecs.orderingCode='(1376-119)';
    ccdSpecs.type='MCS 275-1075';
    ccdSpecs.serialNum=serialNum;
    ccdSpecs.xSecConverterNum='Spalt';
    ccdSpecs.numPixels=1024;
    ccdSpecs.wvlRange='261.39 nm - 1089.76 nm';
    ccdSpecs.wvlCoeffs3_0=[261.394, 0.827815, 2.05642e-6, -1.92777e-8];
    ccdSpecs.validPixs=0:1023;
    ccdSpecs.confidenceInterval='0.20 nm';
    ccdSpecs.QAdate='2007-10-21';
    ccdSpecs.slitWidth='';
    
%CAFS CCD SPECS
elseif serialNum=='027424'
    ccdSpecs.orderingCode='(1212-555)';
    ccdSpecs.type='MCS-CCD 280-680';
    ccdSpecs.serialNum=serialNum;
    ccdSpecs.xSecConverterNum='9736';
    ccdSpecs.numPixels=532;
    ccdSpecs.wvlRange='278.64 nm - 682.21 nm';
    ccdSpecs.wvlCoeffs3_0=[266.563, 0.805416, -3.08241e-6, -2.2182e-8];
    ccdSpecs.validPixs=10:521;
    ccdSpecs.confidenceInterval='0.07 nm';
    ccdSpecs.QAdate='2003-09-23';
    ccdSpecs.slitWidth='20 microns';
elseif serialNum=='037185'
    ccdSpecs.orderingCode='(1287-994)';
    ccdSpecs.type='MCS-CCD 275-675';
    ccdSpecs.serialNum=serialNum;
    ccdSpecs.xSecConverterNum='086 F';
    ccdSpecs.numPixels=532;
    ccdSpecs.wvlRange='270.04 nm - 678.54 nm';
    ccdSpecs.wvlCoeffs3_0=[261.95, 0.808466, -4.58587e-6, -2.38602e-8];
    ccdSpecs.validPixs=10:521;
    ccdSpecs.confidenceInterval='0.07 nm';
    ccdSpecs.QAdate='2004-08-05';
    ccdSpecs.slitWidth='20 microns';
elseif serialNum=='137183'
    ccdSpecs.orderingCode='(1287-994)';
    ccdSpecs.type='MCS-CCD 275-675';
    ccdSpecs.serialNum=serialNum;
    ccdSpecs.xSecConverterNum='???';
    ccdSpecs.numPixels=532;
    ccdSpecs.wvlRange='268.36 nm - 675.56 nm';
    ccdSpecs.wvlCoeffs3_0=[260.342, 0.802208, -8.24487e-6, -3.51018e-9];
    ccdSpecs.validPixs=10:521;
    ccdSpecs.confidenceInterval='0.13 nm';
    ccdSpecs.QAdate='2007-11-02';
    ccdSpecs.slitWidth='20 microns';
elseif serialNum=='137186'
    ccdSpecs.orderingCode='(1287-994)';
    ccdSpecs.type='MCS-CCD 275-675';
    ccdSpecs.serialNum=serialNum;
    ccdSpecs.xSecConverterNum='252 F';
    ccdSpecs.numPixels=532;
    ccdSpecs.wvlRange='269.124 nm - 676.38 nm';
    ccdSpecs.wvlCoeffs3_0=[261.026, 0.809232, -1.16701e-5, -2.18704e-8];
    ccdSpecs.validPixs=10:521;
    ccdSpecs.confidenceInterval='0.06 nm';
    ccdSpecs.QAdate='2007-11-07';
    ccdSpecs.slitWidth='20 microns'; 
elseif serialNum=='037188'
    ccdSpecs.orderingCode='(1287-994)';
    ccdSpecs.type='MCS-CCD 275-675';
    ccdSpecs.serialNum=serialNum;
    ccdSpecs.xSecConverterNum='509 Y';
    ccdSpecs.numPixels=532;
    ccdSpecs.wvlRange='267.88 nm - 675.69 nm';
    ccdSpecs.wvlCoeffs3_0=[259.82, 0.806396, -1.03193e-5, -1.03554e-8];
    ccdSpecs.validPixs=10:521;
    ccdSpecs.confidenceInterval='0.05 nm';
    ccdSpecs.QAdate='2008-07-08';
    ccdSpecs.slitWidth='20 microns';     
    
%% PDA Specs    
elseif serialNum=='044117'
    ccdSpecs.orderingCode='(1287-994)';
    ccdSpecs.type='PDA1';
    ccdSpecs.serialNum=serialNum;
    ccdSpecs.xSecConverterNum='31F';
    ccdSpecs.numPixels=512;
    ccdSpecs.wvlRange='273.24 nm - 676.84 nm';
    ccdSpecs.wvlCoeffs3_0=[273.937, 0.831292, -1.4104e-5, -4.83331e-8];
    ccdSpecs.validPixs=0:511;
    ccdSpecs.confidenceInterval='0.10 nm';
    ccdSpecs.QAdate='2004-04-08';
    ccdSpecs.slitWidth='20 microns';
    
    elseif serialNum=='020518'
    ccdSpecs.orderingCode='(1287-994)';
    ccdSpecs.type='PDA2';
    ccdSpecs.serialNum=serialNum;
    ccdSpecs.xSecConverterNum='31F';
    ccdSpecs.numPixels=512;
    ccdSpecs.wvlRange='273.24 nm - 676.84 nm';
    ccdSpecs.wvlCoeffs3_0=[278.705, 0.840739, -3.82962e-5, 1.03852e-8];
    ccdSpecs.validPixs=0:511;
    ccdSpecs.confidenceInterval='0.10 nm';
    ccdSpecs.QAdate='2004-04-08';
    ccdSpecs.slitWidth='20 microns';
    
%NOTE: CCD 37183 and 37186 were rebuilt in 2007.  Old Data should be run
%with 037183 or 037186 as the CCD SN#, new data with 137183 or 137186

elseif serialNum=='037183'
    ccdSpecs.orderingCode='(1287-994)';
    ccdSpecs.type='MCS-CCD 275-675';
    ccdSpecs.serialNum=serialNum;
    ccdSpecs.xSecConverterNum='31F';
    ccdSpecs.numPixels=532;
    ccdSpecs.wvlRange='273.24 nm - 676.84 nm';
    ccdSpecs.wvlCoeffs3_0=[261.181, 0.803848, -2.89815e-6, -1.67086e-8];
    ccdSpecs.validPixs=15:521;
    ccdSpecs.confidenceInterval='0.10 nm';
    ccdSpecs.QAdate='2004-04-08';
    ccdSpecs.slitWidth='20 microns';
elseif serialNum=='037186'
    ccdSpecs.orderingCode='(1287-994)';
    ccdSpecs.type='MCS-CCD 275-675';
    ccdSpecs.serialNum=serialNum;
    ccdSpecs.xSecConverterNum='252 F';
    ccdSpecs.numPixels=532;
    ccdSpecs.wvlRange='270.86 nm - 678.97 nm';
    ccdSpecs.wvlCoeffs3_0=[262.734, 0.8131, -2.19643e-5, -1.01195e-8];
    ccdSpecs.validPixs=10:521;
    ccdSpecs.confidenceInterval='0.06 nm';
    ccdSpecs.QAdate='2004-08-05';
    ccdSpecs.slitWidth='20 microns';

else
    errordlg(['The serial number ',serialNum,' does not match any in zeissParams.m'],...
        'Zeiss CCD Serial Number','replace')
    error('zeissParams.m');
end    

%Create wvl array from coeffs
ccdSpecs.allWvls=polyval(ccdSpecs.wvlCoeffs3_0(end:-1:1),[0:ccdSpecs.numPixels-1]);

%Get array of valid wvls (add one because wvls begins at i=1, not i=0)
ccdSpecs.wvlsValid=ccdSpecs.allWvls(ccdSpecs.validPixs+1);
