VERB_code_2.3
Plot_3pic.m
1 %% Plot the data specified in Plot.m
2 %
3 % PLOT_3PIC plots the data values in column-wise fashion, where each
4 % column represents a different energy level (0.5 MeV, 1.0 MeV, 2.0 MeV).
5 %
6 % For each energy level, PLOT_3PIC produces a pitch-angle scattering plot,
7 % a PSD plot, and a lifetime decay plot (see figures in paper for
8 % reference).
9 %
10 % See also: Plot.m
11 
12 %% Setup
13 
14 FontSize=9;
15 figure('Units', 'inches', 'Position', [1 1 10 8],...
16  'DefaultAxesFontName', 'times new roman', 'DefaultAxesFontWeight', 'bold', 'DefaultAxesFontSize', FontSize,...
17  'PaperOrientation', 'portrait', 'PaperPositionMode', 'auto', 'DefaultTextFontWeight', 'bold');
18 
19 % change target_en_list for more options
20 % this array hosts the different energy levels we are measuring
21 target_en_list = [0.5 1 2]; % 0.5, 1,0, 2.0 MeV
22 
23 %% Plot the data
24 
25 % For each energy level,
26 for i = 1:numel(target_en_list)
27 
28  target_en = target_en_list(i);
29 
30  % input parameters
31 
32  folder_name1=['../Execute/Output_', FIGURE, '/'];
33 
34  % 3 Plots' parameters
35  xmin1=0; % lower and upper x bounds
36  xmax1=90;
37  ymin1=DxxYLim(1); % lower and upper y bounds
38  ymax1=DxxYLim(2);
39 
40  xmin2=xmin1;
41  xmax2=xmax1;
42  ymin2=PSDYLim(1);
43  ymax2=PSDYLim(2);
44 
45  xmin3=xmin1;
46  xmax3=xmax1;
47  ymin3=DecayLim(1);
48  ymax3=DecayLim(2);
49 
50  text1=['E=' num2str(target_en) ' MeV'];
51  text2=' Chorus only';
52  text3=' Chorus and EMIC ';
53  xtext_loc=20;
54  ytext_loc=5e-3;
55 
56  % output parameters:
57  output_formats = [{'png'}];%{'epsc'}];%,{'pdf'}];%[{'fig'}, {'ai'}, , ];
58 
59  nfolders=3;
60 
61  col_num = i;
62 
63  folder_name=folder_name1;
64  text_cur=text1;
65 
66  dataFileName = [folder_name,'OutPSD.dat'];
67  gridFileName = [folder_name,'perp_grid.plt'];
68  oneDimDataFileName = [folder_name,'out1d.dat'];
69 %----------------------------------
70  % Pitch Angle Scattering plot
71  sb=subplot(3,nfolders,col_num);
72 
73  DxxPLTcell = cell(size(DxxFiles));
74  for iDxx = 1:numel(DxxFiles)
75  DxxPLT.DxxFileName = [folder_name,'../DiffCoeff/' DxxFiles{iDxx}];
76 
77  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
78  % Loading grid and data
79  [~,DxxPLT.en,DxxPLT.alpha, DxxPLT.f_var] = load_plt(DxxPLT.DxxFileName, 'squeeze');
80 
81  [~,ind_target_en] = min(abs(DxxPLT.en.arr(:,1) - target_en ));
82  DxxPLT.alpha.arr = squeeze( DxxPLT.alpha.arr(ind_target_en,:)*180/pi );
83  DxxPLT.x_var = DxxPLT.alpha;
84 
85  DxxPLT.f_var.arr = squeeze(DxxPLT.f_var.arr(ind_target_en,:));
86 
87  plot(DxxPLT.x_var.arr, DxxPLT.f_var.arr, DxxColors{iDxx}, 'LineWidth', 2);
88  hold on
89  end
90 
91  ylabel('D_{\alpha\alpha}, days^{-1}')
92  xlabel('Pitch Angle')
93  text(xtext_loc, ytext_loc, text_cur)
94  % picture properties
95  set(gca, 'yscale', 'log', 'xlim', [xmin1 xmax1], 'ylim', [ymin1 ymax1],'ytick',10.^[log10(DxxYLim(1)):1:log10(DxxYLim(2))]);
96 
97  legend(DxxNames,'Location','northwest','FontSize',6);
98 
99 %----------------------------------
100  % Phase Space Density Plot
101 
102  [L, epc, alpha] = load_plt(gridFileName, 'squeeze');
103  %alpha.arr = alpha.arr*180/pi;
104  alpha.arr = squeeze(alpha.arr(ind_target_en,:))*180/pi;
105  x_var = alpha;
106  [f_var] = load_plt(dataFileName);
107  f_var.arr = squeeze(f_var.arr(:,ind_target_en,:));
108 
109  % plot area
110  %subplot('Position', pos2);
111  sb=subplot(3,nfolders,col_num+nfolders);
112  %set(sb,'ActivePositionProperty', 'outerposition' )
113  % colormap
114  cmap = jet(size(f_var.arr,1));
115  % black for first color
116  cmap(1, :) = [0, 0, 0];
117  % using colormap
118  set(gca, 'ColorOrder', cmap, 'NextPlot', 'replacechildren', 'Box', 'on');
119  plot(x_var.arr, f_var.arr', 'LineWidth', 1);
120  ylabel('Phase Space Density')
121  xlabel('Pitch Angle')
122  % picture properties
123  set(gca, 'yscale', 'log', 'xlim', [xmin2 xmax2], 'ylim', [ymin2 ymax2],'ytick',10.^[log10(PSDYLim(1)):1:log10(PSDYLim(2))]);
124 
125  % loading various 1d data
126  [time, Kp, Boundary_fluxes, Lpp, Bw] = load_plt(oneDimDataFileName, 'squeeze');
127  caxis([0 max(time.arr)]);
128 
129  % Draw colorbar after Row 2
130  if (col_num==nfolders)
131  colormap(cmap)
132  cl=colorbar;
133  set(cl,'Position', [0.918,0.429,0.018 0.177])%('Position', [(pos2(1)+pos2(3)+1-cbar)/2, pos2(2), cbar/2, pos2(4)]);
134  end
135 
136 %----------------------------------
137  % Lifetime Decay Plot
138 
139  sb=subplot(3,nfolders,col_num+2*nfolders);
140 
141  it = (length(time.arr)-1);
142  dt = time.arr(it+1) - time.arr(it);
143  % decay.arr=zeros(time.size1,f_var.size1);
144  % for it=1:time.size1-1
145  % decay.arr(it,:)= (f_var.arr(it+1, :) + f_var.arr(it, :)).*dt./(f_var.arr(it, :) - f_var.arr(it+1, :))./2;
146  % end
147  decay.arr = (f_var.arr(it+1, :) + f_var.arr(it, :)).*dt./(f_var.arr(it, :) - f_var.arr(it+1, :))./2;
148  % cmap = jet(size(f_var.arr,1));
149  % % black for first color
150  % cmap(1, :) = [0, 0, 0];
151  % using colormap
152  set(gca, 'yscale', 'linear','ColorOrder', cmap, 'NextPlot', 'replacechildren', 'Box', 'on');
153  plot(alpha.arr, decay.arr,'k', 'LineWidth', 2);
154  set(gca, 'xlim', [xmin3 xmax3], 'ylim', [ymin3 ymax3]);
155  ylabel('Decay time, days');
156 
157  xlabel(alpha.name);
158  %caxis([0 max(time.arr)]);
159  %colorbar%('Position', [(pos2(1)+pos2(3)+1-cbar)/2, pos2(2), cbar/2, pos2(4)]);
160  %cl=colorbar;
161  %set(cl, 'Visible','off')
162 
163  %end % colomn loop
164  %saving to files
165 % for it = 1:max(size(output_formats))
166 % % saveas(gcf, [Plot_file_name, '.', output_formats{it}], output_formats{it});
167 % eval(['print -d', output_formats{it}, ' ', Plot_file_name, '.', output_formats{it}]);
168 %
169 % end
170  %print -r2048 -dpdf test.pdf
171  %close
172 
173 end
double max(double v1, double v2)
Return maximum.
void gcf(double *gammcf, double a, double x, double *gln)
Returns the incomplete gamma function Q(a, x) evaluated by its continued fraction representation as g...
Definition: erf.cpp:103
Phase Space Density class.
Definition: PSD.h:48
Parameters_structure parameters
Parameters structure, with all parameters from the parameters.ini file. The default parameters define...
Definition: Main.cpp:185