forked from SmileiPIC/Smilei
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathplot_spectrum_grid_series.m
104 lines (86 loc) · 2.1 KB
/
plot_spectrum_grid_series.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
clear;
directory_name = './output/';
file_name = 'ParticleBinning6';
file_number = '.h5';
full_name = strcat(directory_name, file_name, file_number);
info = h5info(full_name);
Ndata = size(info.Datasets,1);
Ndata = 10;
%Ndata = 100;
%Ndata = 1;
name = info.Datasets(Ndata).Name;
fp= hdf5read(full_name, name);
Color = {'red','blue','green','black','magenta', [1.0,0.6,0]};
me=1;
mp=100;
m=me;
Np=size(fp,1);
Nx=size(fp,2);
Ns=6;
minEe = 0.001;
maxEe = 1000;
minEp = 0.1;
maxEp = 5000;
minE = minEe;
maxE = maxEe;
factor = (maxE/minE)^(1.0/(Np-1));
Fp(1:Np,1:Ns)=0;
samplingFactor = 20;
startx(1:Ns) = 0;
endx(1:Ns) = 0;
startx(1) = 40000/samplingFactor+1;
endx(1) = startx(1) + 10000/samplingFactor;
startx(2) = 50000/samplingFactor;
endx(2) = startx(2) + 10000/samplingFactor;
startx(3) = 60000/samplingFactor;
endx(3) = startx(3) + 10000/samplingFactor;
startx(4) = 70000/samplingFactor;
endx(4) = startx(4) + 10000/samplingFactor;
startx(5) = 80000/samplingFactor;
endx(5) = startx(5) + 10000/samplingFactor;
startx(6) = 90000/samplingFactor;
endx(6) = startx(6) + 10000/samplingFactor;
%startx(1)= 5000/samplingFactor;
%endx(1) = fix(10000/samplingFactor);
%for i =2:Ns,
% startx(i) = endx(i-1);
% endx(i) = startx(i)+fix(5000/samplingFactor);
%end;
energy(1:Np) = 0;
de(1:Np) = 0;
energy(1) = minE;
for i = 2:Np,
energy(i) = energy(i-1)*factor;
end;
de(1) = energy(2) - energy(1);
for i = 2:Np,
de(i) = energy(i) - energy(i-1);
end;
for k=1:Ns,
norm = 0;
for i=1:Np,
for j=startx(k):endx(k),
Fp(i,k)=Fp(i,k)+fp(i,j)/de(i);
norm = norm + fp(i,j);
end;
end;
%comment for compare
%for i =1:Np,
% Fp(i,k) = Fp(i,k)/norm;
%end;
end;
figure(1);
hold on;
set(gca, 'YScale', 'log');
set(gca, 'XScale', 'log');
xlim([0.001 1000]);
%ylim([10^-10 10]);
for k = 1:Ns,
plot(energy(1:Np),Fp(1:Np,k),'color',Color{k},'LineWidth',2);
end;
title('F(E)');
xlabel('E/me c^2');
ylabel('F(E)');
%legend('1','2','3','4','5','6');
legend('far far downstream', ' far downstream', 'downstream', 'front', 'upstream', 'far upstream','Location','northeast');
grid;