%**************************************************************************
%This function gets the temperature measurements from the header of the
%undulator data file.
%
%Input:
%header, header from the undulator data file
%
%Output:
%temp, average undulator temperature (C)
%
%Zack Wolf, 10/04/07

function [temp] = temp_get_und_temp(header)

%Find the start of the temperature measurements
[r, c] = size(header);
for ii = 1 : c
    if strfind(header{ii}, 'Temperature (C)') > 0
        col_temp = ii;
        break;
    end
end

%Get the measurements
%temp_array = sscanf(header{col_temp + 1}, '%*s end %f --> mid %f --> start %f --> bot %f --> k_air %f --> k-gr %f');
temp_array = sscanf(header{col_temp + 1}, '%*s top_end %f --> top_mid %f --> top_start %f --> bottom %f --> Air %f --> Granite %f');
%temp_array = sscanf(header{col_temp + 1}, '%*s top_start %f --> top_mid %f --> top_end %f --> bot %f --> granite %f --> Air %f');
%temp_array = sscanf(header{col_temp + 1}, '%*s T5 %f --> T2 %f --> T1 %f --> T3 %f --> Air %f --> T4 %f');
temp_array = temp_array';
temp = sum(temp_array(1 : 4)) / 4;

%Done
