close all, clear all
load data

lum = ['051';'007';'137';'033';'132']

tempE = ['131';'147';'157';'010']

ix = find(data.p(:,3) > 0)
piano1AltiIx = setdiff(ix,name2pos([lum; tempE],data))
piano1Alti = data.name(piano1AltiIx,:)

MIN = min(min(data.T(piano1AltiIx,:)))

MAX = max(max(data.T(piano1AltiIx,:)))

col = colormap;

X = data.p(piano1AltiIx,1);
Y = data.p(piano1AltiIx,2);
Z = data.p(piano1AltiIx,3);

a= 0
[XI,YI,ZI] = meshgrid(...
    (-a+min(X)):.2:(max(X)+a),...
    (-a+min(Y)):.2:(max(Y)+a),...
    (-a+min(Z)):.2:(max(Z)+a));



yyy = min(Y); dy = 0.1;

xxx = min(X); dx = 0.1;
%%
for j = 1:20:length(data.T)
j
V = data.T(piano1AltiIx,j);
VI = griddata3([X],[Y],[Z],[V],XI,YI,ZI,'linear');
VI(isnan(VI)) = mean(V);
hold off
h = slice(XI,YI,ZI,VI,[],[],[1.6 4.8]) ;

%set(h,'FaceColor','interp', 'EdgeColor','none', 'DiffuseStrength',.8)
hold on
h = slice(XI,YI,ZI,VI,[xxx],[],[]) ;
xxx = xxx + dx;
if xxx > max(X) || xxx < min(X)
        dx = -dx;
    end 
%set(h,'FaceColor','interp', 'EdgeColor','none', 'DiffuseStrength',.8)
h = slice(XI,YI,ZI,VI,[],[yyy],[]) ;
yyy = yyy + dy;
if yyy > max(Y) || yyy < min(Y)
        dy = -dy;
    end        
%set(h,'FaceColor','interp', 'EdgeColor','none', 'DiffuseStrength',.8)

camproj perspective
set(gcf,'Renderer','zbuffer')
title(datestr(data.start+data.dt*j,'ore HH giorno DD/mm'))
colorbar
caxis([MIN MAX])
drawnow
% if j > 1
%     view(ca);
% end
% if j == 1
%     pause
% end
% ca = view();
print(gcf,'-dpng',sprintf('%s/%08d.png','filmett',j));
end
%%