function calfile=find_read_hs2cal(file_loc,mlab,sensors)

if ~isstruct(sensors)
    temp=sensors;
    [r c] = size(temp);
    sensors=struct([]);
    i=1;
    
    if iscell(temp)
        if r < c
            r = c;
        end;
        while i <= r
            % This is equivalent to sensor(1,i).hs2 = [];
            sensors = setfield(sensors,{1,i},char(temp(i)),[]);
            i=i+1;
        end  
    else
        while i <= r
        sensors = setfield(sensors,{i},char(temp(i,:)),[]);
        i=i+1;
        end;
    end
    
end;

file_name = fullfile(file_loc, 'cfg', [char(mlab) '.cfg']);
fid=fopen(file_name);

start = ftell(fid);
items = fieldnames(sensors);
[r c] = size(items);
%calfile = struct([]);
i=1;

while i <= r
    search_item = char(items(i));
    n = length(search_item);
    while ~feof(fid)
        S=fgetl(fid);
        if strncmp(S,search_item,n)
            if i==1
                calfile = struct(search_item, getCalFile(S));
            else
                calfile = setfield(calfile,search_item, getCalFile(S));
            end    
        end
    end
    fseek(fid,start,'bof');
    i = i+1;
end;
    
fclose(fid);

function calfile = getCalFile(S)
% THe cfg file uses paths like /oasis/eqpac/cfg/specprr.ep1.20031023
i = strfind(S, '/'); % Assumes unix style path
filename = S(i(end) + 1: end);

calfile = fullfile(getOasisPath, 'eqpac', 'cfg', filename);

