function[new_x, new_y, field1] = ReadDrawField(filename, depth)
close all
clc

set(0, 'DefaultAxesFontSize', 14, 'DefaultAxesFontName', 'Arial');
set(0, 'DefaultTextFontSize', 16, 'DefaultTextFontName', 'Arial');

c = jsondecode(fileread('meta.json'));
c1 = c.dimensions;
c2 = c1{2};
x1 = c2.bounds.a;
x2 = c2.bounds.b;
nx = c2.n;

c3 = c1{3};
y1 = c3.bounds.a;
y2 = c3.bounds.b;
ny = c3.n;

c4 = c1{4};
z1 = c4.bounds.a;
z2 = c4.bounds.b;
nz = c4.n;


if (c.binary==1)
y = fopen(filename);
a = fread(y, 'double');
else
a = dlmread(filename);
end

b = a(:,1:2:end) + 1i*a(:,2:2:end);


if ((z1 - z2) == 0)
 field = b; 
else
  field = b(:, depth + 1);
end

field1 = reshape(field, ny, []);
new_x = linspace(x1, x2, size(field1,1));
new_y = linspace(y1, y2, size(field1,2));

figure;
imagesc(new_x/1000,new_y/1000,20*log10(abs(field1)));
hold on;
grid on;
xlabel('X, km');
ylabel('Y,km');
colorbar;
colormap(jet);
caxis([-120 -60]);
end