function [ Bmap2D ] = read2Dfieldmap_y_corrected( filespath )
%read2fieldmaps read fieldmaps from the files and stack them at a distance
%   filespath is the directory containing the scans

thresh = 0.01; % field threshold fraction (for locating the edge of the und)

Bmap2D = [];

filenames = {
{
'001gap000.000x+00.00y-00.20',
'002gap000.000x+00.00y-00.10',
'003gap000.000x+00.00y+00.00',
'004gap000.000x+00.00y+00.10',
'005gap000.000x+00.00y+00.20'}};

fns = ['/zscan.dat'];

xs = 1e-3*sort([linspace(-0.2,0.2,5)]);


for i = 1:numel(filenames{1})
    for j = 1:1
        filepath = [filespath '/' filenames{j}{i} fns(j,:)];
        try
            Bm = readfieldmap( filepath, 47 );
        %      Bm(:, 4) = Bm(:,3); % rearrange
        %      Bm(:, 3) = Bm(:,2); % to
        %      Bm(:, 2) = ys(i); % fit y in
            Bm(:, 4) = xs(i); % fit y in
            Bmap2D = [Bmap2D; Bm];
            break
        catch
            if(j==20)
                fprintf(['NOTE: could not read ' filepath '\n']);
    %                  fprintf('(It''s normal to have 1 and only 1 of these messages.)\n');
            end
        end
    end
end


end

