0001 function fproc_HXR_varscan(basestr,file_str,shotnum,shotime,id_simul_o,locid_simul,locpath_simul,...
0002 var,ic,krange,dtexp,HXRopt,cnumber,kdisp,opt)
0003
0004 if isfield(opt,'savepath'),
0005 savepath = opt.savepath;
0006 else
0007 savepath = [basestr,filesep,shotnum,filesep];
0008 end
0009
0010 path_simul = [savepath,locpath_simul];
0011
0012 if isfield(opt,'hxr_file'),
0013 hxr_file = opt.hxr_file;
0014 else
0015 hxr_file = [savepath,'HXR_',basestr,'_',shotnum,'.mat'];
0016 end
0017
0018 if ~exist(hxr_file,'file'),
0019 get_hxrspec_forLUKE_jd(basestr,str2num(shotnum),savepath)
0020 end
0021
0022
0023 if isfield(opt,'exp_file'),
0024 exp_file = opt.exp_file;
0025 else
0026 exp_file = [savepath,'HXREXP_',basestr,'_',shotnum,'.mat'];
0027 end
0028 if ~exist(exp_file,'file'),
0029 collect_hxr_forLUKE_jd(basestr,str2num(shotnum),HXRopt,savepath)
0030 end
0031
0032
0033
0034 if iscell(shotime),
0035 equilbase = file_str;
0036 id_simul_o = basestr;
0037 var.str = shotnum;
0038
0039 var.liststr = select_shotimes_jd([equilbase,basestr,'_',shotnum,'_'],[locid_simul,'.mat'],path_simul,shotime);
0040 nvar = length(var.liststr);
0041
0042 if nvar == 0,
0043 keyboard
0044 return
0045 end
0046
0047 for ivar = 1:nvar,
0048 ttimes(ivar) = str2num(var.liststr{ivar});
0049 end
0050
0051 if real(opt.xdisp) == 0,
0052 var.list = ttimes;
0053 elseif real(opt.xdisp) == 1,
0054 [nvol,tn]=tsbase(str2double(shotnum),'sprofnmoy');
0055 if isempty(nvol),
0056 [nvol,tn]=tsbase(str2double(shotnum),'snmoy');
0057 nvol = nvol/1e19;
0058 end
0059 var.list = interp1(tn,nvol,ttimes);
0060 var.lab = '<n>';
0061 var.unit = '\times 10^{19} m^{-3}';
0062 elseif real(opt.xdisp) == 2,
0063 [npardem,tn]=tsbase(str2double(shotnum),'gnpardem');
0064 var.list = interp1(tn(:,imag(opt.xdisp)),npardem(:,imag(opt.xdisp)),ttimes);
0065 var.lab = 'n_{||}';
0066 var.unit = '';
0067
0068 [var.list,isort] = sort(var.list);
0069 ttimes = ttimes(isort);
0070 var.liststr = var.liststr(isort);
0071 end
0072
0073 ivar_disp = [];
0074 for ivar = 1:nvar,
0075 if any(ttimes(ivar) == var.disp),
0076 ivar_disp = [ivar_disp,ivar];
0077 end
0078 end
0079 ivar_dispexp = ivar_disp;
0080
0081 else
0082 equilbase = [file_str,basestr,'_',shotnum,'_',shotime,'_'];
0083 nvar = length(var.list);
0084 ttimes = repmat(str2num(shotime),[1,nvar]);
0085 ivar_disp = [];
0086 for ivar = 1:nvar,
0087 var.liststr{ivar} = num2str(var.list(ivar));
0088 if any(abs(var.list(ivar) - var.disp) < 10*eps),
0089 ivar_disp = [ivar_disp,ivar];
0090 ivar_dispexp = ivar;
0091 end
0092 end
0093
0094 end
0095
0096 var_disp = var.list(ivar_disp);
0097 ndisp = length(var_disp);
0098
0099
0100
0101
0102 icdisp = 1 + cnumber - ic(1);
0103
0104 nc = length(ic);
0105
0106
0107 dI_tot = NaN(1,nvar);
0108 dI_exp = NaN(1,nvar);
0109
0110
0111 ds_c3po = NaN(1,nvar);
0112 ds_luke = NaN(1,nvar);
0113
0114 dp0_rf_2piRp = NaN(1,nvar);
0115 dp_rf_2piRp = NaN(1,nvar);
0116 dp_rf_2piRp_lin = NaN(1,nvar);
0117
0118 drho = NaN(1,nvar);
0119
0120
0121
0122
0123 Tphplasma = NaN(nc,nvar);
0124 Tphexp = NaN(nc,nvar);
0125 Tphdiag = NaN(nc,nvar);
0126 eTphplasma = NaN(nc,nvar);
0127 eTphexp = NaN(nc,nvar);
0128 eTphdiag = NaN(nc,nvar);
0129 Aplasma = NaN(nc,nvar);
0130 Aexp = NaN(nc,nvar);
0131 Adiag = NaN(nc,nvar);
0132 eAplasma = NaN(nc,nvar);
0133 eAexp = NaN(nc,nvar);
0134 eAdiag = NaN(nc,nvar);
0135 Qplasma = NaN(nc,nvar);
0136 Qexp = NaN(nc,nvar);
0137 Qdiag = NaN(nc,nvar);
0138
0139
0140
0141
0142 dvarplasma = NaN(1,nvar);
0143 dvardiag = NaN(1,nvar);
0144
0145 icpeak = NaN(1,nvar);
0146
0147 varmask = false(1,nvar);
0148
0149 for ivar = 1:nvar,
0150
0151 texp = [ttimes(ivar) - dtexp/2,ttimes(ivar) + dtexp/2];
0152
0153 id_simul = equilbase;
0154 if iscell(id_simul_o),
0155 for iid = 1:length(id_simul_o),
0156 id_simul = [id_simul,id_simul_o{iid},'_',var.str,'_',var.liststr{ivar}];
0157 end
0158 else
0159 id_simul = [id_simul,id_simul_o,'_',var.str,'_',var.liststr{ivar}];
0160 end
0161 id_simul = [id_simul,locid_simul];
0162
0163 [hxr_proc,hxr,data_proc] = fproc_hxr(basestr,path_simul,id_simul,hxr_file,exp_file,texp,ic,krange,opt);
0164
0165 if isempty(hxr_proc),
0166 varmask(ivar) = true;
0167
0168 continue
0169 end
0170
0171 dI_tot(ivar) = data_proc.scalar.I_tot;
0172
0173 if isfield(data_proc.scalar,'I_exp'),
0174 dI_exp(ivar) = data_proc.scalar.I_exp;
0175 elseif isfield(opt,'I_exp'),
0176 dI_exp(ivar) = opt.I_exp;
0177 end
0178
0179 dp0_rf_2piRp(ivar) = data_proc.scalar.p0_rf_2piRp;
0180 dp_rf_2piRp(ivar) = data_proc.scalar.p_rf_2piRp;
0181 dp_rf_2piRp_lin(ivar) = data_proc.scalar.p_rf_2piRp_lin;
0182
0183 dJ(:,ivar) = data_proc.radial.J_tot.';
0184 dP(:,ivar) = data_proc.radial.P_rf.';
0185
0186 if opt.rho == 'g',
0187 dxrho(:,ivar) = data_proc.radial.xrhoG.';
0188 drho(ivar) = sum(data_proc.wave.wp_rf_2piRp.'.*data_proc.wave.wrhoG)/sum(data_proc.wave.wp_rf_2piRp);
0189 elseif opt.rho == 'p',
0190 dxrho(:,ivar) = data_proc.radial.xrhoP.';
0191 drho(ivar) = sum(data_proc.wave.wp_rf_2piRp.'.*data_proc.wave.wrhoP)/sum(data_proc.wave.wp_rf_2piRp);
0192 elseif opt.rho == 't',
0193 dxrho(:,ivar) = data_proc.radial.xrhoT.';
0194 drho(ivar) = sum(data_proc.wave.wp_rf_2piRp.'.*data_proc.wave.wrhoT)/sum(data_proc.wave.wp_rf_2piRp);
0195 elseif opt.rho == 'v',
0196 dxrho(:,ivar) = data_proc.radial.xrhoV.';
0197 drho(ivar) = sum(data_proc.wave.wp_rf_2piRp.'.*data_proc.wave.wrhoV)/sum(data_proc.wave.wp_rf_2piRp);
0198 else
0199 error('rho type not recognized')
0200 end
0201
0202 if isfield(data_proc.radial,'xdA_dke'),
0203 dxdA(:,ivar) = data_proc.radial.xdA_dke.';
0204 else
0205 dxdA(:,ivar) = NaN*dxrho(:,ivar);
0206 end
0207
0208
0209
0210 ds_c3po(ivar) = 0;
0211 ds_luke(ivar) = 0;
0212
0213 if isfield(data_proc,'wave') && isfield(data_proc.wave,'wrays'),
0214 xs_c3po = [];
0215 xP0_2piRp_c3po = [];
0216 xs_luke = [];
0217 xP0_2piRp_luke = [];
0218 for iw = 1:length(data_proc.wave.wrays),
0219 for iray = 1:length(data_proc.wave.wrays{iw}),
0220 xs_c3po = [xs_c3po,data_proc.wave.wrays{iw}{iray}.c3po.ss];
0221 xP0_2piRp_c3po = [xP0_2piRp_c3po,data_proc.wave.wrays{iw}{iray}.c3po.P0_2piRp];
0222 if isfield(data_proc.wave.wrays{iw}{iray},'luke'),
0223 xs_luke = [xs_luke,data_proc.wave.wrays{iw}{iray}.luke{end}.ss];
0224 xP0_2piRp_luke = [xP0_2piRp_luke,data_proc.wave.wrays{iw}{iray}.luke{end}.P0_2piRp];
0225 end
0226 end
0227 end
0228
0229 ds_c3po(ivar) = sum(xs_c3po.*xP0_2piRp_c3po)/sum(xP0_2piRp_c3po);
0230
0231 if ~isempty(xs_luke),
0232 ds_luke(ivar) = sum(xs_luke.*xP0_2piRp_luke)/sum(xP0_2piRp_luke);
0233 end
0234 end
0235
0236 Tphplasma(:,ivar) = hxr_proc.Tphplasma;
0237 Tphdiag(:,ivar) = hxr_proc.Tphdiag;
0238 Tphexp(:,ivar) = hxr_proc.Tphexp;
0239 Aplasma(:,ivar) = hxr_proc.Aplasma;
0240 Adiag(:,ivar) = hxr_proc.Adiag;
0241 Aexp(:,ivar) = hxr_proc.Aexp;
0242 eAplasma(:,ivar) = hxr_proc.eAplasma;
0243 eAdiag(:,ivar) = hxr_proc.eAdiag;
0244 eAexp(:,ivar) = hxr_proc.eAexp;
0245 Qplasma(:,ivar) = hxr_proc.Qplasma;
0246 Qdiag(:,ivar) = hxr_proc.Qdiag;
0247 Qexp(:,ivar) = hxr_proc.Qexp;
0248 eTphplasma(:,ivar) = hxr_proc.eTphplasma;
0249 eTphdiag(:,ivar) = hxr_proc.eTphdiag;
0250 eTphexp(:,ivar) = hxr_proc.eTphexp;
0251
0252 dvarplasma(ivar) = hxr_proc.dvarplasma;
0253 dvardiag(ivar) = hxr_proc.dvardiag;
0254
0255 icpeak(ivar) = hxr_proc.icpeak;
0256
0257 ik = hxr_proc.ik;
0258
0259 dNdtplasma(:,:,ivar) = hxr_proc.dNdtplasma(ik,ic);
0260 dNdtdiag(:,:,ivar) = hxr_proc.dNdtdiag(ik,ic);
0261 dNdtexp(:,:,ivar) = hxr_proc.dNdtexp(ik,ic);
0262
0263
0264
0265
0266 k(:,ivar) = hxr_proc.k(ik);
0267
0268
0269 end
0270
0271 if ~exist('k','var'),
0272 disp('No results found. Aborted.')
0273 keyboard
0274 return
0275 end
0276
0277 dxdrho = diff([zeros(1,nvar);(dxrho(1:end-1,:) + dxrho(2:end,:))/2;ones(1,nvar)]);
0278
0279 dNdtplasma(:,:,varmask) = NaN;
0280 dNdtdiag(:,:,varmask) = NaN;
0281 dNdtexp(:,:,varmask) = NaN;
0282
0283 dt = 0.016;
0284
0285 if ~all(all(k(:,~varmask) == repmat(k(:,find(~varmask,1,'first')),[1,sum(~varmask)]))),
0286 error('verify energy list')
0287 else
0288 k = k(:,find(~varmask,1,'first'));
0289 end
0290
0291 nk = length(k);
0292 ikdisp = find(k == mean(kdisp));
0293
0294 dNdtdiag_disp = reshape(dNdtdiag(:,icdisp,:),[nk,nvar]).';
0295 dNdtplasma_disp = reshape(dNdtplasma(:,icdisp,:),[nk,nvar]).';
0296 dNdtexp_disp = reshape(dNdtexp(:,icdisp,:),[nk,nvar]).';
0297
0298 sdNdtdiag = reshape(sum(dNdtdiag,1),[nc,nvar]);
0299 sdNdtplasma = reshape(sum(dNdtplasma,1),[nc,nvar]);
0300 sdNdtexp = reshape(sum(dNdtexp,1),[nc,nvar]);
0301
0302 sdNdtexpmax = sdNdtexp == repmat(max(sdNdtexp),[nc,1]);
0303 sdNdtexpmax(cumsum(sdNdtexpmax) > 1) = 0;
0304 icnorm = find(sdNdtexpmax).';
0305
0306 ndNdtdiag = sdNdtdiag./repmat(sdNdtdiag(icnorm),[nc,1]);
0307 ndNdtplasma = sdNdtplasma./repmat(sdNdtplasma(icnorm),[nc,1]);
0308 ndNdtexp = sdNdtexp./repmat(sdNdtexp(icnorm),[nc,1]);
0309
0310 endNdtdiag = sqrt(sdNdtdiag/dt)./repmat(sdNdtdiag(icnorm),[nc,1]);
0311 endNdtplasma = sqrt(sdNdtplasma/dt)./repmat(sdNdtplasma(icnorm),[nc,1]);
0312 endNdtexp = sqrt(sdNdtexp/dt)./repmat(sdNdtexp(icnorm),[nc,1]);
0313
0314 dPfrac = dp_rf_2piRp./dp0_rf_2piRp;
0315 dPfrac_lin = dp_rf_2piRp_lin./dp0_rf_2piRp;
0316
0317 style0 = 'none';
0318 style = '-';
0319 style2 = '--';
0320 marker = 'none';
0321 marker1 = '+';
0322 marker2 = 'o';
0323 marker3 = 's';
0324 marker4 = '.';
0325 markers = {marker1,marker2,marker3,marker4};
0326 color = NaN;
0327 color1 = 'k';
0328 color2 = 'r';
0329 color3 = 'b';
0330 color4 = 'g';
0331 color5 = 'm';
0332 color6 = 'c';
0333 colors = {color2,color3,color4,color5};
0334
0335 width = 0.5;
0336 width2 = 2;
0337 siz = 20+14*1i;
0338
0339 red = 0.9;
0340 lspace = 0.7;
0341 lspace2 = 0.5;
0342 bspace = 0.7;
0343 bspace2 = 0.6;
0344
0345 if ~isempty(var.unit),
0346 xlab = [var.lab,' (',var.unit,')'];
0347 else
0348 xlab = var.lab;
0349 end
0350
0351 if isfield(opt,'xlim'),
0352 xlim = opt.xlim;
0353 else
0354 xlim = [min(var.list),max(var.list)];
0355 end
0356
0357 if isfield(opt,'xtick'),
0358 xtick = opt.xtick;
0359 else
0360 xtick = var.list;
0361 end
0362
0363 if isfield(opt,'xcont') && opt.xcont == 0;
0364 stylex = style0;
0365 stylex2 = style0;
0366 else
0367 stylex = style;
0368 stylex2 = style2;
0369 end
0370
0371 if isfield(opt,'icrej_exp') && ~isempty(opt.icrej_exp),
0372 maskic_exp = ~any(repmat(ic,[length(opt.icrej_exp),1]) == repmat(opt.icrej_exp.',[1,length(ic)]),1);
0373 else
0374 maskic_exp = true(1,nc);
0375 end
0376
0377 xlog = var.log;
0378
0379 xlab_ic = 'Chord #';
0380 xlim_ic = [min(ic)-1,max(ic)+1];
0381 xtick_ic = 0:5:60;
0382
0383 ncol = length(colors);
0384
0385 chordstr = ['chord # ',num2str(cnumber)];
0386
0387 displeg = {};
0388 for ivar = 1:ndisp,
0389 ivarstr = [var.lab,' = ',num2str(var_disp(ivar)),' ',var.unit];
0390
0391 displeg = [displeg,ivarstr];
0392 end
0393 kstr = ['k = ',num2str(kdisp(1)),' - ',num2str(kdisp(2)),' keV'];
0394
0395 kmin = min(k);
0396 kmax = max(k);
0397
0398 krangestr = ['k = ',num2str(kmin),' - ',num2str(kmax),' keV'];
0399
0400 savestr = equilbase;
0401 if iscell(id_simul_o),
0402 for iid = 1:length(id_simul_o),
0403 savestr = [savestr,id_simul_o{iid},'_',var.str,'_scan'];
0404 end
0405 else
0406 savestr = [savestr,id_simul_o,'_',var.str,'_scan'];
0407 end
0408 savestr = [savestr,locid_simul];
0409
0410
0411
0412 ifig = 1;figure(ifig),clf,set(ifig,'Name','Current')
0413
0414 ylab = 'Current (kA)';
0415 tit = '';
0416
0417 if isfield(opt,'ylim_I'),
0418 ylim = opt.ylim_I;
0419 else
0420 ylim = 1e3*[0,max(dI_tot)]*1.2;
0421 end
0422
0423 leg = {'LUKE'};
0424
0425 if var.firstref,
0426 graph1D_jd(xlim,[dI_tot(1),dI_tot(1)]*1e3,xlog,0,'','','',NaN,xlim,ylim,stylex,marker,color3,width,siz);
0427 leg = [[var.lab,' = ',num2str(var.list(1))],leg];
0428 end
0429
0430 if var.lastref,
0431 graph1D_jd(xlim,[dI_tot(end),dI_tot(end)]*1e3,xlog,0,'','','',NaN,xlim,ylim,stylex2,marker,color3,width,siz);
0432 leg = [[var.lab,' = ',num2str(var.list(end))],leg];
0433 end
0434
0435 if ~all(isnan(dI_exp)) && (~isfield(opt,'I_exp') || opt.I_exp == 1),
0436 graph1D_jd(var.list,dI_exp*1e3,0,0,'','','',NaN,xlim,ylim,stylex,marker3,color1,width2,siz);
0437 leg = ['Exp.',leg];
0438 end
0439 graph1D_jd(var.list,dI_tot*1e3,xlog,0,xlab,ylab,tit,leg,xlim,ylim,stylex,marker2,color2,width2,siz,gca,red,lspace,bspace);
0440
0441 set(gca,'xtick',xtick);
0442
0443
0444
0445 if isfield(opt,'ytick_I'),
0446 set(gca,'ytick',opt.ytick_I);
0447 end
0448
0449 print_jd(opt.print,['Fig_',savestr,'_I_tot'],[path_simul,'figures/'],ifig);
0450
0451 ifig = 101;figure(ifig),clf,set(ifig,'Name','Current and Location')
0452
0453 ylab = '';
0454 tit = '';
0455
0456 if isfield(opt,'ylim_Irho'),
0457 ylim = opt.ylim_Irho;
0458 else
0459 ylim = [0,max([dI_tot,1])]*1.2;
0460 end
0461
0462 leg = {'I (MA)','r/a'};
0463
0464 if var.firstref,
0465 graph1D_jd(xlim,[dI_tot(1),dI_tot(1)],xlog,0,'','','',NaN,xlim,ylim,stylex,marker,color2,width,siz);
0466 graph1D_jd(xlim,[drho(1),drho(1)],xlog,0,'','','',NaN,xlim,ylim,stylex,marker,color3,width,siz);
0467 end
0468
0469 if var.lastref,
0470 graph1D_jd(xlim,[dI_tot(end),dI_tot(end)],xlog,0,'','','',NaN,xlim,ylim,stylex2,marker,color2,width,siz);
0471 graph1D_jd(xlim,[drho(end),drho(end)],xlog,0,'','','',NaN,xlim,ylim,stylex2,marker,color3,width,siz);
0472 end
0473
0474 graph1D_jd(var.list,dI_tot,xlog,0,'','','',NaN,xlim,ylim,stylex,marker2,color2,width2,siz);
0475 graph1D_jd(var.list,drho,xlog,0,xlab,ylab,tit,leg,xlim,ylim,stylex,marker3,color3,width2,siz,gca,red,lspace,bspace);
0476
0477 set(gca,'xtick',xtick);
0478
0479
0480
0481 if isfield(opt,'ytick_Irho'),
0482 set(gca,'ytick',opt.ytick_Irho);
0483 end
0484
0485 print_jd(opt.print,['Fig_',savestr,'_I_tot_rho'],[path_simul,'figures/'],ifig);
0486
0487
0488
0489 plot_2D_jd(opt,path_simul,savestr,'TPH_2D',ic(maskic_exp),Tphexp(maskic_exp,ivar_dispexp),eTphexp(maskic_exp,ivar_dispexp),...
0490 ic,Tphdiag(:,ivar_disp),eTphdiag(:,ivar_disp),...
0491 {'Exp.','LUKE'},2,'TPH2D',xlab_ic,'Photon Temperature (keV)',displeg,xlim_ic,'ylim_Tph',xtick_ic,'ytick_Tph',...
0492 {stylex2,stylex},markers,[color1,colors],[width,width2],siz,red,lspace,bspace2);
0493
0494
0495
0496
0497
0498
0499
0500
0501
0502
0503
0504
0505
0506
0507
0508
0509
0510
0511
0512
0513
0514
0515
0516
0517
0518
0519
0520
0521
0522
0523
0524
0525
0526
0527
0528
0529
0530
0531
0532
0533
0534
0535
0536
0537
0538
0539
0540
0541 ifig = 3;figure(ifig),clf,set(ifig,'Name','TPHCR1D')
0542
0543 ylab = '';
0544 tit = [chordstr,'; ',krangestr];
0545 if isfield(opt,'CRfac'),
0546 fac = opt.CRfac;
0547 CRleg = ['(\times ',num2str(fac),' s^{-1})'];
0548 else
0549 fac = 1e3;
0550 CRleg = '(ms^{-1})';
0551 end
0552
0553 if isfield(opt,'ylim_Tph'),
0554 ylim = opt.ylim_Tph;
0555 else
0556 ylim_Tph = [0,max(max([Tphdiag(icdisp,:),Tphexp(icdisp,:)]))]*1.2;
0557 ylim_CR = [0,max(max([sdNdtdiag(icdisp,:),sdNdtexp(icdisp,:)]))]*1.2;
0558 ylim = max([ylim_Tph;ylim_CR/fac]);
0559 end
0560
0561 leg = {'T_{ph} LUKE',['CR LUKE ',CRleg]};
0562
0563 if ~all(isnan(Tphexp(icdisp,:))),
0564 graph1D_jd(var.list,Tphexp(icdisp,:),xlog,0,'','','',NaN,xlim,ylim,stylex,marker3,color2,width,siz,gca,1,lspace,bspace2,eTphexp(icdisp,:));
0565 graph1D_jd(var.list,sdNdtexp(icdisp,:)/fac,xlog,0,'','','',NaN,xlim,ylim,stylex,marker3,color3,width,siz,gca,1,lspace,bspace2,sqrt(sdNdtexp(icdisp,:)/dt)/fac);
0566 leg = ['T_{ph} Exp.',['CR Exp. ',CRleg],leg];
0567 end
0568
0569
0570 graph1D_jd(var.list,Tphdiag(icdisp,:),xlog,0,xlab,ylab,tit,NaN,xlim,ylim,stylex2,marker2,color2,width2,siz,gca,red,lspace,bspace2,eTphdiag(icdisp,:));
0571 graph1D_jd(var.list,sdNdtdiag(icdisp,:)/fac,xlog,0,'','','',leg,xlim,ylim,stylex2,marker2,color3,width2,siz,gca,1,lspace,bspace2,sqrt(sdNdtdiag(icdisp,:)/dt)/fac);
0572
0573 set(gca,'xtick',xtick);
0574
0575 if isfield(opt,'ytick_Tph'),
0576 set(gca,'ytick',opt.ytick_Tph);
0577 end
0578
0579 print_jd(opt.print,['Fig_',savestr,'_TPHCR_1D_ic_',num2str(icdisp)],[path_simul,'figures/'],ifig);
0580
0581
0582
0583
0584 ifig = 301;figure(ifig),clf,set(ifig,'Name','TPHCR1D')
0585
0586 ylab = 'Photon Temperature (keV)';
0587 tit = [chordstr,'; ',krangestr];
0588
0589 if isfield(opt,'ylim_Tph'),
0590 ylim = opt.ylim_Tph;
0591 else
0592 ylim = [0,max(max([Tphdiag(icdisp,:),Tphexp(icdisp,:)]))]*1.2;
0593 end
0594
0595 leg = {'LUKE'};
0596
0597 if ~all(isnan(Tphexp(icdisp,:))),
0598 graph1D_jd(var.list,Tphexp(icdisp,:),xlog,0,'','','',NaN,xlim,ylim,stylex,marker3,color1,width2,siz,gca,1,lspace,bspace2,eTphexp(icdisp,:));
0599 leg = ['Exp.',leg];
0600 end
0601
0602 graph1D_jd(var.list,Tphdiag(icdisp,:),xlog,0,xlab,ylab,tit,NaN,xlim,ylim,stylex,marker2,color2,width2,siz,gca,red,lspace,bspace2,eTphdiag(icdisp,:));
0603
0604 set(gca,'xtick',xtick);
0605
0606 if isfield(opt,'ytick_Tph'),
0607 set(gca,'ytick',opt.ytick_Tph);
0608 end
0609
0610 print_jd(opt.print,['Fig_',savestr,'_TPH_1D_ic_',num2str(icdisp)],[path_simul,'figures/'],ifig);
0611
0612
0613
0614
0615 ifig = 302;figure(ifig),clf,set(ifig,'Name','CRTOT1D')
0616
0617 ylab = 'Count rate (s^{-1})';
0618 tit = [chordstr,'; ',krangestr];
0619
0620 if isfield(opt,'ylog_CR'),
0621 ylog = opt.ylog_CR;
0622 else
0623 ylog = 0;
0624 end
0625
0626 if isfield(opt,'ylim_CRTOT'),
0627 ylim = opt.ylim_CRTOT;
0628 elseif ylog == 1,
0629 ylim = [min(min([sdNdtdiag(icdisp,:),sdNdtexp(icdisp,:)]))/2,max(max([sdNdtdiag(icdisp,:),sdNdtexp(icdisp,:)]))*2];
0630 else
0631 ylim = [0,max(max([sdNdtdiag(icdisp,:),sdNdtexp(icdisp,:)]))]*1.2;
0632 end
0633
0634 leg = {'LUKE'};
0635
0636 if ~all(isnan(sdNdtexp(icdisp,:))),
0637 graph1D_jd(var.list,sdNdtexp(icdisp,:),xlog,ylog,'','','',NaN,xlim,ylim,stylex,marker3,color1,width2,siz,gca,1,lspace,bspace2,sqrt(sdNdtexp(icdisp,:)/dt));
0638 leg = ['Exp.',leg];
0639 end
0640
0641 graph1D_jd(var.list,sdNdtdiag(icdisp,:),xlog,ylog,xlab,ylab,tit,NaN,xlim,ylim,stylex,marker2,color2,width2,siz,gca,red,lspace,bspace2,sqrt(sdNdtdiag(icdisp,:)/dt));
0642
0643 set(gca,'xtick',xtick);
0644
0645 if isfield(opt,'ytick_CRTOT'),
0646 set(gca,'ytick',opt.ytick_CRTOT);
0647 end
0648
0649 print_jd(opt.print,['Fig_',savestr,'_CR_TOT_1D_ic_',num2str(icdisp)],[path_simul,'figures/'],ifig);
0650
0651
0652
0653
0654 ifig = 303;figure(ifig),clf,set(ifig,'Name','CRSEL1D')
0655
0656 ylab = 'Count rate (s^{-1})';
0657 tit = [chordstr,'; ',kstr];
0658
0659 if isfield(opt,'ylog_CR'),
0660 ylog = opt.ylog_CR;
0661 else
0662 ylog = 0;
0663 end
0664
0665 if isfield(opt,'ylim_CRSEL'),
0666 ylim = opt.ylim_CRSEL;
0667 elseif ylog == 1,
0668 ylim = [min([dNdtdiag_disp(:,ikdisp);dNdtexp_disp(:,ikdisp)])/2,max([dNdtdiag_disp(:,ikdisp);dNdtexp_disp(:,ikdisp)])*2];
0669 else
0670 ylim = [0,max([dNdtdiag_disp(:,ikdisp);dNdtexp_disp(:,ikdisp)])]*1.2;
0671 end
0672
0673 leg = {'LUKE'};
0674
0675 if ~all(isnan(sdNdtexp(icdisp,:))),
0676 graph1D_jd(var.list,dNdtexp_disp(:,ikdisp),xlog,ylog,'','','',NaN,xlim,ylim,stylex,marker3,color1,width2,siz,gca,1,lspace,bspace2,sqrt(dNdtexp_disp(:,ikdisp)/dt));
0677 leg = ['Exp.',leg];
0678 end
0679
0680 graph1D_jd(var.list,dNdtdiag_disp(:,ikdisp),xlog,ylog,xlab,ylab,tit,NaN,xlim,ylim,stylex,marker2,color2,width2,siz,gca,red,lspace,bspace2,sqrt(dNdtdiag_disp(:,ikdisp)/dt));
0681
0682 set(gca,'xtick',xtick);
0683
0684 if isfield(opt,'ytick_CRSEL'),
0685 set(gca,'ytick',opt.ytick_CRSEL);
0686 end
0687
0688 print_jd(opt.print,['Fig_',savestr,'_CR_SEL_1D_ic_',num2str(icdisp)],[path_simul,'figures/'],ifig);
0689
0690
0691
0692
0693 plot_2D_jd(opt,path_simul,savestr,'CR_2D',ic(maskic_exp),sdNdtexp(maskic_exp,ivar_dispexp),sqrt(sdNdtexp(maskic_exp,ivar_dispexp)/dt),...
0694 ic,sdNdtdiag(:,ivar_disp),sqrt(sdNdtdiag(:,ivar_disp)/dt),...
0695 {'Exp.','LUKE'},4,'CR2D',xlab_ic,['Count rate (s^{-1}); ',krangestr],displeg,xlim_ic,'ylim_CRTOT',xtick_ic,'ytick_CRTOT',...
0696 {style2,style},markers,[color1,colors],[width,width2],siz,red,lspace,bspace2);
0697
0698
0699
0700
0701
0702
0703
0704
0705
0706
0707
0708
0709
0710
0711
0712
0713
0714
0715
0716
0717
0718
0719
0720
0721
0722
0723
0724
0725
0726
0727
0728
0729
0730
0731
0732
0733
0734
0735
0736
0737
0738
0739
0740
0741
0742
0743
0744
0745
0746 plot_2D_jd(opt,path_simul,savestr,'CR_2D_norm',ic(maskic_exp),ndNdtexp(maskic_exp,ivar_dispexp),endNdtexp(maskic_exp,ivar_dispexp),...
0747 ic,ndNdtdiag(:,ivar_disp),endNdtdiag(:,ivar_disp),...
0748 {'Exp.','LUKE'},5,'CR2D norm',xlab_ic,['Normalized count rate (s^{-1}); ',krangestr],displeg,xlim_ic,'ylim_CRNORM',xtick_ic,'ytick_CRNORM',...
0749 {style2,style},markers,[color1,colors],[width,width2],siz,red,lspace,bspace2);
0750
0751
0752
0753
0754
0755
0756
0757
0758
0759
0760
0761
0762
0763
0764
0765
0766
0767
0768
0769
0770
0771
0772
0773
0774
0775
0776
0777
0778
0779
0780
0781
0782
0783
0784
0785
0786
0787
0788
0789
0790
0791
0792
0793
0794
0795
0796
0797
0798
0799 if ndisp >= 1,
0800
0801 ifig = 6;figure(ifig),clf,set(ifig,'Name','Current profiles')
0802
0803 xlab_rho = '\rho';
0804 xlim_rho = [0,1];
0805 xtick_rho = 0:0.2:1;
0806
0807 ylab = 'J (MA/m^2)';
0808 tit = '';
0809
0810 if isfield(opt,'ylim_J'),
0811 ylim = opt.ylim_J;
0812 else
0813 ylim = [min(min(dJ(:,ivar_disp))),max(max(dJ(:,ivar_disp)))]*1.2;
0814 end
0815
0816 leg = {};
0817
0818 for ivar = 1:ndisp-1,
0819 graph1D_jd(dxrho(:,ivar_disp(ivar)),dJ(:,ivar_disp(ivar)).',0,0,'','','',NaN,xlim_rho,ylim,style,markers{rem(ivar,ncol)},colors{rem(ivar,ncol)},width2,siz);
0820 end
0821
0822 graph1D_jd(dxrho(:,ivar_disp(ndisp)),dJ(:,ivar_disp(ndisp)).',0,0,xlab_rho,ylab,tit,displeg,xlim_rho,ylim,style,markers{rem(ndisp,ncol)},colors{rem(ndisp,ncol)},width2,siz,gca,red,lspace,bspace);
0823
0824 set(gca,'xtick',xtick_rho);
0825 if isfield(opt,'ytick_J'),
0826 set(gca,'ytick',opt.ytick_J);
0827 end
0828
0829 print_jd(opt.print,['Fig_',savestr,'_J'],[path_simul,'figures/'],ifig);
0830
0831
0832 ifig = 61;figure(ifig),clf,set(ifig,'Name','dJdrho profiles')
0833
0834 xlab_rho = '\rho';
0835 xlim_rho = [0,1];
0836 xtick_rho = 0:0.2:1;
0837
0838 ylab = 'dJ/d\rho (MA)';
0839 tit = '';
0840
0841 dJdxdrho = dJ.*dxdA./dxdrho;
0842
0843 if isfield(opt,'ylim_dJdrho'),
0844 ylim = opt.ylim_dJdrho;
0845 else
0846 ylim = [min(min(dJdxdrho(:,ivar_disp))),max(max(dJdxdrho(:,ivar_disp)))]*1.2;
0847 end
0848
0849 leg = {};
0850
0851 for ivar = 1:ndisp-1,
0852 graph1D_jd(dxrho(:,ivar_disp(ivar)),dJdxdrho(:,ivar_disp(ivar)).',0,0,'','','',NaN,xlim_rho,ylim,style,markers{rem(ivar,ncol)},colors{rem(ivar,ncol)},width2,siz);
0853 end
0854
0855 graph1D_jd(dxrho(:,ivar_disp(ndisp)),dJdxdrho(:,ivar_disp(ndisp)).',0,0,xlab_rho,ylab,tit,displeg,xlim_rho,ylim,style,markers{rem(ndisp,ncol)},colors{rem(ndisp,ncol)},width2,siz,gca,red,lspace,bspace);
0856
0857 set(gca,'xtick',xtick_rho);
0858 if isfield(opt,'ytick_dJdrho'),
0859 set(gca,'ytick',opt.ytick_dJdrho);
0860 end
0861
0862 print_jd(opt.print,['Fig_',savestr,'_dJdrho'],[path_simul,'figures/'],ifig);
0863
0864 end
0865
0866
0867
0868 if ndisp >= 1,
0869
0870 ifig = 7;figure(ifig),clf,set(ifig,'Name','Power profiles')
0871
0872 xlab_rho = '\rho';
0873 xlim_rho = [0,1];
0874 xtick_rho = 0:0.2:1;
0875
0876 ylab = 'P_{rf} (MW/m^3)';
0877 tit = '';
0878
0879 if isfield(opt,'ylim_P'),
0880 ylim = opt.ylim_P;
0881 else
0882 ylim = [0,max(max(dP(:,ivar_disp)))]*1.2;
0883 end
0884
0885 leg = {};
0886
0887 for ivar = 1:ndisp-1,
0888 graph1D_jd(dxrho(:,ivar_disp(ivar)),dP(:,ivar_disp(ivar)).',0,0,'','','',NaN,xlim_rho,ylim,style,markers{rem(ivar,ncol)},colors{rem(ivar,ncol)},width2,siz);
0889 end
0890
0891 graph1D_jd(dxrho(:,ivar_disp(ndisp)),dP(:,ivar_disp(ndisp)).',0,0,xlab_rho,ylab,tit,displeg,xlim_rho,ylim,style,markers{rem(ndisp,ncol)},colors{rem(ndisp,ncol)},width2,siz,gca,red,lspace,bspace);
0892
0893 set(gca,'xtick',xtick_rho);
0894 if isfield(opt,'ytick_P'),
0895 set(gca,'ytick',opt.ytick_P);
0896 end
0897
0898 print_jd(opt.print,['Fig_',savestr,'_P'],[path_simul,'figures/'],ifig);
0899
0900 end
0901
0902
0903
0904
0905
0906
0907
0908
0909
0910
0911
0912
0913
0914
0915
0916
0917
0918
0919
0920
0921
0922
0923
0924
0925
0926
0927
0928
0929
0930
0931
0932
0933
0934
0935
0936
0937
0938
0939
0940
0941
0942
0943
0944
0945
0946
0947
0948
0949
0950
0951
0952
0953
0954
0955
0956
0957
0958
0959
0960
0961
0962
0963
0964
0965
0966
0967
0968
0969
0970
0971
0972
0973
0974
0975
0976
0977
0978
0979
0980
0981
0982
0983
0984
0985
0986
0987
0988
0989
0990
0991
0992
0993
0994
0995
0996
0997
0998
0999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069 if ndisp >= 1,
1070
1071 ylim = [0,1.2];
1072 ytick = 0:0.2:1.2;
1073 nvar_dispexp = length(ivar_dispexp);
1074
1075 for ivar = 1:nvar_dispexp,
1076
1077 if nvar_dispexp > 1,
1078 tit = displeg{ivar};
1079 else
1080 tit = '';
1081 end
1082
1083 ifig = 700+ivar;figure(ifig),clf,set(ifig,'Name','Exp. CR')
1084
1085 dNdtexp_sel = dNdtexp(:,maskic_exp,ivar_dispexp(ivar));
1086 dNdtexp_max = repmat(max(dNdtexp_sel,[],2),[1,sum(maskic_exp)]);
1087 Nnorm = dNdtexp_sel./dNdtexp_max;
1088 eNnorm = sqrt(dNdtexp_sel/dt)./dNdtexp_max;
1089
1090 leg = {};
1091 for iik = 1:length(k),
1092 leg{iik} = ['k = ',num2str(k(iik)),' keV'];
1093 end
1094
1095 graph1D_jd(repmat(ic(maskic_exp).',[1,length(k)]),Nnorm.',0,0,xlab_ic,ylab,tit,leg,xlim_ic,ylim,...
1096 style,marker,color,width2,siz,gca,red,lspace,bspace,eNnorm.');
1097
1098 set(gca,'xtick',xtick_ic);
1099 set(gca,'ytick',ytick);
1100
1101
1102 print_jd(opt.print,['Fig_',savestr,'_CR_EXP'],[path_simul,'figures/'],ifig);
1103
1104 end
1105 end
1106
1107
1108
1109 ifig = 8;figure(ifig),clf,set(ifig,'Name','Ray length')
1110
1111 ylab = 'Weighed ray length (m)';
1112 tit = '';
1113 ylim = [0,max([ds_c3po,ds_luke])]*1.5;
1114
1115 leg = {'C3PO','LUKE'};
1116
1117 graph1D_jd(var.list,ds_c3po,xlog,0,'','','',NaN,xlim,ylim,stylex,marker2,color3,width2,siz);
1118 graph1D_jd(var.list,ds_luke,xlog,0,xlab,ylab,tit,leg,xlim,ylim,stylex,marker1,color2,width2,siz,gca,red,lspace,bspace);
1119
1120 set(gca,'xtick',xtick);
1121
1122
1123
1124 print_jd(opt.print,['Fig_',savestr,'_S'],[path_simul,'figures/'],ifig);
1125
1126
1127
1128 ifig = 9;figure(ifig),clf,set(ifig,'Name','Power')
1129
1130 ylab = 'Fraction of power absorbed';
1131 tit = '';
1132 ylim = [0,max([dPfrac,dPfrac_lin])]*1.5;
1133
1134 leg = {'C3PO','LUKE'};
1135
1136 graph1D_jd(var.list,dPfrac_lin,xlog,0,'','','',NaN,xlim,ylim,stylex,marker2,color3,width2,siz);
1137 graph1D_jd(var.list,dPfrac,xlog,0,xlab,ylab,tit,leg,xlim,ylim,stylex,marker1,color2,width2,siz,gca,red,lspace,bspace);
1138
1139 set(gca,'xtick',xtick);
1140
1141
1142
1143 print_jd(opt.print,['Fig_',savestr,'_Pvar'],[path_simul,'figures/'],ifig);
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223 end
1224
1225 function plot_2D_jd(opt,savepath,savestr,figlabel,x1,y1,ey1,x2,y2,ey2,yleg,ifig,figname,xlab,ylab,displeg,xlim,fylim,xtick,fytick,styles,markers,colors,widths,siz,red,lspace,bspace)
1226
1227 nexp = size(y1,2);
1228
1229 if nexp == 0,
1230 return
1231 end
1232
1233 figure(ifig),clf,set(ifig,'Name',figname)
1234
1235 if isfield(opt,fylim),
1236 ylim = opt.(fylim);
1237 else
1238 ylim = [0,max([max(y1),max(y2)])]*1.2;
1239 end
1240
1241 ncol = length(colors) - 1;
1242 nmar = length(markers) - 1;
1243
1244 if nexp > 1,
1245 else
1246 end
1247
1248 if nexp > 1,
1249 leg = yleg(2);
1250 tit = [displeg{1},' (',colors{1 + rem(1,ncol)},')'];
1251 for iexp = 2:nexp,
1252 tit = [tit,'; ',displeg{iexp},' (',colors{1 + rem(iexp,ncol)},')'];
1253 end
1254
1255 if ~all(isnan(y1(:,1))),
1256 localcol = colors{1 + rem(1,ncol)};
1257 localwidth = widths(1);
1258 graph1D_jd(x1,y1(:,1),0,0,'','','',NaN,xlim,ylim,styles{1},markers{1},localcol,localwidth,siz,gca,1,lspace,bspace,ey1(:,1));
1259 leg = [yleg(1),leg];
1260 end
1261
1262
1263 graph1D_jd(x2,y2(:,1),0,0,xlab,ylab,tit,leg,xlim,ylim,styles{2},markers{1 + rem(1,ncol)},colors{1 + rem(1,ncol)},widths(2),siz,gca,red,lspace,bspace,ey2(:,1));
1264
1265 for ivar = 2:size(y2,2),
1266
1267 graph1D_jd(x2,y2(:,ivar),0,0,'','','',NaN,xlim,ylim,styles{2},markers{1 + rem(ivar,ncol)},colors{1 + rem(ivar,ncol)},widths(2),siz,gca,1,lspace,bspace,ey2(:,ivar));
1268 graph1D_jd(x1,y1(:,ivar),0,0,'','','',NaN,xlim,ylim,styles{1},markers{1 + rem(ivar,ncol)},colors{1 + rem(ivar,ncol)},widths(1),siz,gca,1,lspace,bspace,ey1(:,ivar));
1269 end
1270
1271 else
1272
1273 leg = displeg;
1274 tit = '';
1275
1276 if ~all(isnan(y1(:,1))),
1277 localcol = colors{1};
1278 localwidth = widths(2);
1279 graph1D_jd(x1,y1(:,1),0,0,'','','',NaN,xlim,ylim,styles{1},markers{1},localcol,localwidth,siz,gca,1,lspace,bspace,ey1(:,1));
1280 leg = [yleg(1),leg];
1281 end
1282
1283 for ivar = 1:size(y2,2)-1,
1284 graph1D_jd(x2,y2(:,ivar),0,0,'','','',NaN,xlim,ylim,styles{2},markers{1 + rem(ivar,ncol)},colors{1 + rem(ivar,ncol)},widths(2),siz,gca,1,lspace,bspace,ey2(:,ivar));
1285 end
1286
1287 graph1D_jd(x2,y2(:,end),0,0,xlab,ylab,tit,leg,xlim,ylim,styles{2},markers{1 + rem(size(y2,2),ncol)},colors{1 + rem(size(y2,2),ncol)},widths(2),siz,gca,red,lspace,bspace,ey2(:,end));
1288
1289
1290
1291
1292
1293 end
1294
1295
1296 set(gca,'xtick',xtick);
1297
1298 if isfield(opt,fytick),
1299 set(gca,'ytick',opt.(fytick));
1300 end
1301
1302 print_jd(opt.print,['Fig_',savestr,'_',figlabel],[savepath,'figures/'],ifig);
1303 end