Skip to content
Snippets Groups Projects
Commit f916da89 authored by Antoine Cyril David Hoffmann's avatar Antoine Cyril David Hoffmann
Browse files

Statistical analysis and 3D plots in phase space

parent 15277710
No related branches found
No related tags found
No related merge requests found
title1 = GIFNAME;
FIGDIR = BASIC.RESDIR;
GIFNAME = [FIGDIR, GIFNAME,'.gif'];
% Setup figure frame
fig = figure('Color','white','Position', [100, 100, 400, 400]);
plt = @(x) squeeze(reshape(x(:,:,1),[],1));
scale_x = max(abs(plt(X(:,:,1))));
scale_y = max(abs(plt(Y(:,:,1))));
scale_z = max(abs(plt(Z(:,:,1))));
plot3(plt(X)/scale_x,plt(Y)/scale_y,plt(Z)/scale_z,'.k','MarkerSize',MARKERSIZE);
view(VIEW);
colormap jet
axis tight manual % this ensures that getframe() returns a consistent size
in = 1;
nbytes = fprintf(2,'frame %d/%d',in,numel(FRAMES));
for n = FRAMES % loop over selected frames
plt = @(x) squeeze(reshape(x(:,:,n),[],1));
scale_x = max(abs(plt(X)));
scale_y = max(abs(plt(Y)));
scale_z = max(abs(plt(Z)));
plot3(plt(X)/scale_x,plt(Y)/scale_y,plt(Z)/scale_z,'.k','MarkerSize',MARKERSIZE);
view(VIEW);
xlabel(XNAME); ylabel(YNAME); zlabel(ZNAME);
title(['$t \approx$', sprintf('%.3d',ceil(T(n)))...
,', scaling = ',sprintf('%.1e',scale_x)]);
grid on;
drawnow
% Capture the plot as an image
frame = getframe(fig);
im = frame2im(frame);
[imind,cm] = rgb2ind(im,32);
% Write to the GIF File
if in == 1
imwrite(imind,cm,GIFNAME,'gif', 'Loopcount',inf);
else
imwrite(imind,cm,GIFNAME,'gif','WriteMode','append', 'DelayTime',DELAY);
end
% terminal info
while nbytes > 0
fprintf('\b')
nbytes = nbytes - 1;
end
nbytes = fprintf(2,'frame %d/%d',n,numel(FRAMES));
in = in + 1;
end
disp(' ')
disp(['Gif saved @ : ',GIFNAME])
if 0
%% ni ne phase space for different time windows
fig = figure;
t0 = 20; t1 = 20; [~,it0] = min(abs(t0-Ts2D)); [~,it1] = min(abs(t1-Ts2D));
plt = @(x) squeeze(reshape(x(:,:,it0:it1),[],1));
plot(plt(ni00),plt(ne00),'.');
title(['$',num2str(Ts2D(it0)),'\leq t \leq',num2str(Ts2D(it1)),'$']);
xlabel('$n_i$'); ylabel('$n_e$');
end
if 0
%% histograms
fig = figure;
t0 = 100; t1 = 100; [~,it0] = min(abs(t0-Ts2D)); [~,it1] = min(abs(t1-Ts2D));
plt = @(x) squeeze(reshape(x(:,:,it0:it1),[],1));
hist(plt(ni00),100); hold on
title(['$',num2str(Ts2D(it0)),'\leq t \leq',num2str(Ts2D(it1)),'$']);
xlabel('$n_i$');
end
if 0
%% ni ne phi 3D phase space
fig = figure;
t0 = 20; t1 = 20; [~,it0] = min(abs(t0-Ts2D)); [~,it1] = min(abs(t1-Ts2D));
plt = @(x) squeeze(reshape(x(:,:,it0:it1),[],1));
plot3(plt(ni00),plt(ne00),plt(phi),'.','MarkerSize',0.5);
title(['$',num2str(Ts2D(it0)),'\leq t \leq',num2str(Ts2D(it1)),'$']);
xlabel('$n_i$'); ylabel('$n_e$'); zlabel('$\phi$'); grid on;
end
t0 = 0;
skip_ = 1;
DELAY = 0.01*skip_;
FRAMES = floor(t0/(Ts2D(2)-Ts2D(1)))+1:skip_:numel(Ts2D);
if 0
%% ni ne phi 3D phase space GIF
GIFNAME = ['ni_ne_phi_phase_space',sprintf('_%.2d',JOBNUM)];
X = ne00; Y = ni00; Z = phi; T = Ts2D;
MARKERSIZE = 0.01;
XNAME = '$n_i$'; YNAME = '$n_e$'; ZNAME = '$\phi$'; VIEW = [1,-1,1];
create_gif_3D
end
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment