function [index] = find_index(fileList,time_tr)
    % GATHERARCHIVE Extracts a variable with a given name from a list of .h5 files
    %
    % Inputs:
    %   - fileList: A cell array of strings representing the file names or paths
    %               of the .h5 files to extract the variable from
    %   - variableName: A string representing the name of the variable to extract
    %
    % Output:
    %   - varData: A cell array of matrices representing the values of the
    %              variable in each of the .h5 files

    % Initialize the output variable
    % Loop through ecach file in the list

    index = cell(length(fileList), 1);
    tolerance = 0.01;

    for i = 1:length(fileList)
        drop_file = fileList{i};
        drop_times = time_tr{i};
        [path, filename, ext] = fileparts(drop_file);

        h5_path = strrep(path, '/PBLH','/Archive_drop/Archive/');
        h5_file = strcat(filename,'.h5');
        full_path_h5 = strcat(h5_path,h5_file)                
        gps_time = h5read(full_path_h5, '/Nav_Data/gps_time');
        indices = zeros(size(drop_times));
        for j = 1:length(drop_times)
            [~,idx] = min(abs(gps_time - drop_times(j)));
            indices(j) = idx;
        end
        index{i} = indices;
        
    end 
      
end






