alt = h5read("simgrid.h5","/alt");
lat = h5read("simgrid.h5","/lat");
lon = h5read("simgrid.h5","/lon");
%alt = alt/1e3;


filename = "20230322_41460.000000.h5";




vars = ["/Tnall",'/n0all','/nHall','/nN2all','/nNall','/nO2all','/nOall','/vnrhoall','/vnxall'];

% altslice1 = 100;
% altslice2 = 300;
% latslice1 = 50;
% latslice2 = 200;
% lonslice1 = 150;
% lonslice2 = 350;

[~,altslice1] = find(min(abs(alt-100)));
[~,altslice2] = find(min(abs(alt-300)));
[~,latslice1] = find(min(abs(lat-64)));
[~,latslice2] = find(min(abs(lat-66)));
[~,lonslice1] = find(min(abs(lon-205)));
[~,lonslice2] = find(min(abs(lon-220)));

%

[LAT,LON] = meshgrid(lat,lon);
clf
plot(LAT,LON)
alt

%

%for vv = 1:length(vars)
vv = 1
var = h5read(filename,vars(vv));
disp("min = " + num2str(min(var(:))))
disp("max = " + num2str(max(var(:))))
disp("mean = " + num2str(mean(var(:))))
figure
set(gcf,'PaperPosition',[0,0,6.5,4.5])
tlo = tiledlayout(3,2)

nexttile
pcolor(lat,alt,squeeze(var(:,lonslice1,:)))
title([vars(vv), ' slice at lon ', num2str(lon(lonslice1))])
shading interp
colorbar
ylabel('altitude')
xlabel('latitude')

nexttile
pcolor(lat,alt,squeeze(var(:,lonslice2,:)))
title([vars(vv), ' slice at lon ', num2str(lon(lonslice2))])
shading flat
colorbar
ylabel('altitude')
xlabel('latitude')

nexttile
pcolor(lon,alt,squeeze(var(:,:,latslice1)))
title([vars(vv), ' slice at lat ', num2str(lat(latslice1))])
shading interp
colorbar
ylabel('altitude')
xlabel('longitude')

nexttile
pcolor(lon,alt,squeeze(var(:,:,latslice2)))
title([vars(vv), ' slice at lat ', num2str(lat(latslice2))])
shading flat
colorbar
ylabel('altitude')
xlabel('longitude')

nexttile
pcolor(lat,lon,squeeze(var(altslice1,:,:)))
title([vars(vv), ' slice at lat ', num2str(alt(altslice1))])
shading interp
colorbar
ylabel('longitude')
xlabel('latitude')

nexttile
pcolor(lat,lon,squeeze(var(altslice2,:,:)))
title([vars(vv), ' slice at lat ', num2str(alt(altslice2))])
shading flat
colorbar
ylabel('longitude')
xlabel('latitude')

saveas(gcf,'vnxall.png')
%
%    temp=1;
%end

%

unique(var)