fproc_HXR_varscan

PURPOSE ^

SYNOPSIS ^

function fproc_HXR_varscan(basestr,file_str,shotnum,shotime,id_simul_o,locid_simul,locpath_simul,var,ic,krange,dtexp,HXRopt,cnumber,kdisp,opt)

DESCRIPTION ^

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SUBFUNCTIONS ^

SOURCE CODE ^

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 % select shot times if time scan
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,% density scan
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,% phase scan
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 % J_exp = NaN;
0100 % xrho_exp = NaN;
0101 %
0102 icdisp = 1 + cnumber - ic(1);
0103 %
0104 nc = length(ic);
0105 %nk = length(ik);
0106 %
0107 dI_tot = NaN(1,nvar);
0108 dI_exp = NaN(1,nvar);
0109 %dt = NaN(1,nvar);
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 %dJ = NaN(nr,nvar);
0121 %dxrho = NaN(nr,nvar);
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 %dNdtplasma = NaN(nk,nc,nvar);
0140 %dNdtdiag = NaN(nk,nc,nvar);
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}];%Simulation ID
0157         end
0158     else
0159         id_simul = [id_simul,id_simul_o,'_',var.str,'_',var.liststr{ivar}];%Simulation ID
0160     end
0161     id_simul = [id_simul,locid_simul];%Simulation ID
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     %dxrho(:,ivar) = data_proc.radial.xrho.';
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     %dNdtexp2(:,:,ivar) = hxr_proc.dNdtexp(ik2,ic);
0263     %
0264     %dt(ivar) = hxr.dt;
0265     %
0266     k(:,ivar) = hxr_proc.k(ik);
0267     %k2 = hxr_proc.k(ik2);
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]);%count rate
0299 sdNdtplasma = reshape(sum(dNdtplasma,1),[nc,nvar]);%count rate
0300 sdNdtexp = reshape(sum(dNdtexp,1),[nc,nvar]);%count rate
0301 %
0302 sdNdtexpmax = sdNdtexp == repmat(max(sdNdtexp),[nc,1]);
0303 sdNdtexpmax(cumsum(sdNdtexpmax) > 1) = 0;% case with two maxima
0304 icnorm = find(sdNdtexpmax).';
0305 %
0306 ndNdtdiag = sdNdtdiag./repmat(sdNdtdiag(icnorm),[nc,1]);%count rate
0307 ndNdtplasma = sdNdtplasma./repmat(sdNdtplasma(icnorm),[nc,1]);%count rate
0308 ndNdtexp = sdNdtexp./repmat(sdNdtexp(icnorm),[nc,1]);%count rate
0309 %
0310 endNdtdiag = sqrt(sdNdtdiag/dt)./repmat(sdNdtdiag(icnorm),[nc,1]);%count rate
0311 endNdtplasma = sqrt(sdNdtplasma/dt)./repmat(sdNdtplasma(icnorm),[nc,1]);%count rate
0312 endNdtexp = sqrt(sdNdtexp/dt)./repmat(sdNdtexp(icnorm),[nc,1]);%count rate
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 %dispstr = [];
0387 displeg = {};
0388 for ivar = 1:ndisp,
0389     ivarstr = [var.lab,' = ',num2str(var_disp(ivar)),' ',var.unit];
0390     %dispstr = [dispstr,ivarstr];
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'];%Simulation ID
0404     end
0405 else
0406     savestr = [savestr,id_simul_o,'_',var.str,'_scan'];%Simulation ID
0407 end
0408 savestr = [savestr,locid_simul];%Simulation ID
0409 %
0410 % --------------------- Current -----------------------
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 %set(gca,'xminorgrid','off')
0443 %set(gca,'xminortick','off')
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 %set(gca,'xminorgrid','off')
0479 %set(gca,'xminortick','off')
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 % --------------------- TPH 2D -----------------------
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),...ic,Tphplasma(:,ivar_disp),eTphplasma(:,ivar_disp),
0491     {'Exp.','LUKE'},2,'TPH2D',xlab_ic,'Photon Temperature (keV)',displeg,xlim_ic,'ylim_Tph',xtick_ic,'ytick_Tph',...{'Exp.','plasma','diag.'}
0492     {stylex2,stylex},markers,[color1,colors],[width,width2],siz,red,lspace,bspace2);
0493 %
0494 % if ndisp >= 1,
0495 %     %
0496 %     ifig = 2;figure(ifig),clf,set(ifig,'Name','TPH2D')
0497 %     %
0498 %     ylab = 'Photon Temperature (keV)';
0499 %     tit = dispstr;
0500 %     if isfield(opt,'ylim_Tph'),
0501 %         ylim = opt.ylim_Tph;
0502 %     else
0503 %         ylim = [0,max(max([Tphdiag(:,ivar_disp);Tphexp(maskic_exp,ivar_disp)]))]*1.2;%Tphplasma(:,ivar_disp),
0504 %     end
0505 %     %
0506 %     leg = {'LUKE'};%{'plasma','diag.'};%
0507 %     %
0508 %     if ~all(isnan(Tphexp(:,ivar_disp(1)))),
0509 %         if ndisp > 1,
0510 %             localcol = colors{rem(1,ncol)};
0511 %             localwidth = width;
0512 %         else
0513 %             localcol = color1;
0514 %             localwidth = width2;
0515 %         end
0516 %         graph1D_jd(ic(maskic_exp),Tphexp(maskic_exp,ivar_disp(1)),0,0,'','','',NaN,xlim_ic,ylim,style,marker,localcol,localwidth,siz,gca,1,lspace,bspace2,eTphexp(maskic_exp,ivar_disp(1)));
0517 %         leg = ['Exp.',leg];
0518 %     end
0519 %     %graph1D_jd(ic,Tphplasma(:,ivar_disp(1)),0,0,'','','',NaN,xlim_ic,ylim,style,marker2,colors{rem(1,ncol)},width2,siz,gca,1,lspace,bspace2,eTphplasma(:,ivar_disp(1)));
0520 %     graph1D_jd(ic,Tphdiag(:,ivar_disp(1)),0,0,xlab_ic,ylab,tit,leg,xlim_ic,ylim,style,marker3,colors{rem(1,ncol)},width2,siz,gca,red,lspace,bspace2,eTphdiag(:,ivar_disp(1)));
0521 %     for ivar = 2:ndisp,
0522 %         %graph1D_jd(ic,Tphplasma(:,ivar_disp(ivar)),0,0,'','','',NaN,xlim_ic,ylim,style,marker2,colors{rem(ivar,ncol)},width2,siz,gca,1,lspace,bspace2,eTphplasma(:,ivar_disp(ivar)));
0523 %         graph1D_jd(ic,Tphdiag(:,ivar_disp(ivar)),0,0,'','','',NaN,xlim_ic,ylim,style,marker3,colors{rem(ivar,ncol)},width2,siz,gca,1,lspace,bspace2,eTphdiag(:,ivar_disp(ivar)));
0524 %         if ~all(isnan(Tphexp(:,ivar_disp(ivar)))),
0525 %             graph1D_jd(ic(maskic_exp),Tphexp(maskic_exp,ivar_disp(ivar)),0,0,'','','',NaN,xlim_ic,ylim,style,marker,colors{rem(ivar,ncol)},width,siz,gca,1,lspace,bspace2,eTphexp(maskic_exp,ivar_disp(ivar)));
0526 %         end
0527 %     end
0528 %     %
0529 %     set(gca,'xtick',xtick_ic);
0530 %     %
0531 %     if isfield(opt,'ytick_Tph'),
0532 %         set(gca,'ytick',opt.ytick_Tph);
0533 %     end
0534 %     %
0535 %     print_jd(opt.print,['Fig_',savestr,'_TPH_2D'],[path_simul,'figures/'],ifig);
0536 %     %
0537 % end
0538 %
0539 % --------------------- TPH & CR 1D -----------------------
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;%Tphplasma(icdisp,:),
0557     ylim_CR = [0,max(max([sdNdtdiag(icdisp,:),sdNdtexp(icdisp,:)]))]*1.2;%sdNdtplasma(icdisp,:),
0558     ylim = max([ylim_Tph;ylim_CR/fac]);
0559 end
0560 %
0561 leg = {'T_{ph} LUKE',['CR LUKE ',CRleg]};%{'plasma','diag.'};%
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 %graph1D_jd(var.list,Tphplasma(icdisp,:),xlog,0,'','','',NaN,xlim,ylim,style,marker2,color2,width2,siz,gca,1,lspace,bspace2,eTphplasma(icdisp,:));
0569 %graph1D_jd(var.list,sdNdtplasma(icdisp,:)/fac,xlog,0,'','','',leg,xlim,ylim,style,marker2,color3,width2,siz,gca,1,lspace2,bspace,sqrt(sdNdtplasma(icdisp,:)/dt)/fac);
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 % --------------------- TPH 1D -----------------------
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;%Tphplasma(icdisp,:),
0593 end
0594 %
0595 leg = {'LUKE'};%{'plasma','diag.'};%
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 %graph1D_jd(var.list,Tphplasma(icdisp,:),xlog,0,'','','',NaN,xlim,ylim,stylex2,marker2,color2,width2,siz,gca,1,lspace,bspace2,eTphplasma(icdisp,:));
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 % --------------------- TOTAL COUNT RATE 1D -----------------------
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];%sdNdtplasma(icdisp,:),
0630 else
0631     ylim = [0,max(max([sdNdtdiag(icdisp,:),sdNdtexp(icdisp,:)]))]*1.2;%sdNdtplasma(icdisp,:),
0632 end
0633 %
0634 leg = {'LUKE'};%{'plasma','diag.'};%
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 %graph1D_jd(var.list,sdNdtplasma(icdisp,:)/fac,xlog,ylog,'','','',leg,xlim,ylim,stylex2,marker2,color2,width2,siz,gca,1,lspace,bspace2,sqrt(sdNdtplasma(icdisp,:)/dt));
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 % --------------------- SELECTED COUNT RATE 1D -----------------------
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];%dNdtplasma_disp(:,ikdisp),
0669 else
0670     ylim = [0,max([dNdtdiag_disp(:,ikdisp);dNdtexp_disp(:,ikdisp)])]*1.2;%dNdtplasma_disp(:,ikdisp),
0671 end
0672 %
0673 leg = {'LUKE'};%{'plasma','diag.'};%
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 %graph1D_jd(var.list,dNdtplasma_disp(:,ikdisp)/fac,xlog,ylog,'','','',leg,xlim,ylim,stylex2,marker2,color2,width2,siz,gca,1,lspace,bspace2,sqrt(dNdtplasma_disp(:,ikdisp)/dt));
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 % --------------------- COUNT RATE 2D -----------------------
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),...ic,sdNdtplasma(:,ivar_disp),sqrt(sdNdtplasma(:,ivar_disp)/dt),
0695     {'Exp.','LUKE'},4,'CR2D',xlab_ic,['Count rate (s^{-1}); ',krangestr],displeg,xlim_ic,'ylim_CRTOT',xtick_ic,'ytick_CRTOT',...{'Exp.','plasma','diag.'}
0696     {style2,style},markers,[color1,colors],[width,width2],siz,red,lspace,bspace2);
0697 %
0698 % if ndisp >= 1,
0699 %     %
0700 %     ifig = 4;figure(ifig),clf,set(ifig,'Name','CR 2D')
0701 %     %
0702 %     ylab = ['Count rate (s^{-1}); ',krangestr];
0703 %     tit = dispstr;
0704 %     if isfield(opt,'ylim_CRTOT'),
0705 %         ylim = opt.ylim_CRTOT;
0706 %     else
0707 %         ylim = [0,max(max([sdNdtdiag(:,ivar_disp);sdNdtexp(maskic_exp,ivar_disp)]))]*1.2;%sdNdtplasma(:,ivar_disp),
0708 %     end
0709 %     %
0710 %     leg = {'LUKE'};%{'plasma','diag.'};%
0711 %     %
0712 %     if ~all(isnan(sdNdtexp(:,ivar_disp(1)))),
0713 %         if ndisp > 1,
0714 %             localcol = colors{rem(1,ncol)};
0715 %             localwidth = width;
0716 %         else
0717 %             localcol = color1;
0718 %             localwidth = width2;
0719 %         end
0720 %         graph1D_jd(ic(maskic_exp),sdNdtexp(maskic_exp,ivar_disp(1)),0,0,'','','',NaN,xlim_ic,ylim,style,marker,localcol,localwidth,siz,gca,1,lspace,bspace2,sqrt(sdNdtexp(maskic_exp,ivar_disp(1))/dt));
0721 %         leg = ['Exp.',leg];
0722 %     end
0723 %     %graph1D_jd(ic,sdNdtplasma(:,ivar_disp(1)),0,0,'','','',NaN,xlim_ic,ylim,style,marker2,colors{rem(1,ncol)},width2,siz,gca,1,lspace,bspace2,sqrt(sdNdtplasma(:,ivar_disp(1))/dt));
0724 %     graph1D_jd(ic,sdNdtdiag(:,ivar_disp(1)),0,0,xlab_ic,ylab,tit,leg,xlim_ic,ylim,style,marker3,colors{rem(1,ncol)},width2,siz,gca,red,lspace,bspace2,sqrt(sdNdtdiag(:,ivar_disp(1))/dt));
0725 %     for ivar = 2:ndisp,
0726 %         %graph1D_jd(ic,sdNdtplasma(:,ivar_disp(ivar)),0,0,'','','',NaN,xlim_ic,ylim,style,marker2,colors{rem(ivar,ncol)},width2,siz,gca,1,lspace,bspace2,sqrt(sdNdtplasma(:,ivar_disp(ivar))/dt));
0727 %         graph1D_jd(ic,sdNdtdiag(:,ivar_disp(ivar)),0,0,'','','',NaN,xlim_ic,ylim,style,marker3,colors{rem(ivar,ncol)},width2,siz,gca,1,lspace,bspace2,sqrt(sdNdtdiag(:,ivar_disp(ivar))/dt));
0728 %         if ~all(isnan(sdNdtexp(:,ivar_disp(ivar)))),
0729 %             graph1D_jd(ic(maskic_exp),sdNdtexp(maskic_exp,ivar_disp(ivar)),0,0,'','','',NaN,xlim_ic,ylim,style,marker,colors{rem(ivar,ncol)},width,siz,gca,1,lspace,bspace2,sqrt(sdNdtexp(maskic_exp,ivar_disp(ivar))/dt));
0730 %         end
0731 %     end
0732 %     %
0733 %     set(gca,'xtick',xtick_ic);
0734 %     %
0735 %     if isfield(opt,'ytick_CRTOT'),
0736 %         set(gca,'ytick',opt.ytick_CRTOT);
0737 %     end
0738 %     %
0739 %     print_jd(opt.print,['Fig_',savestr,'_CR_2D'],[path_simul,'figures/'],ifig);
0740 %     %
0741 % end
0742 %
0743 %
0744 % --------------------- COUNT RATE 2D NORM -----------------------
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),...ic,ndNdtplasma(:,ivar_disp),endNdtplasma(:,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',...{'Exp.','plasma','diag.'}
0749     {style2,style},markers,[color1,colors],[width,width2],siz,red,lspace,bspace2);
0750 %
0751 % if ndisp >= 1,
0752 %     %
0753 %     ifig = 5;figure(ifig),clf,set(ifig,'Name','CR 2D norm')
0754 %     %
0755 %     ylab = ['Normalized Count rate (s^{-1}); ',krangestr];
0756 %     tit = dispstr;
0757 %     if isfield(opt,'ylim_CRNORM'),
0758 %         ylim = opt.ylim_CRNORM;
0759 %     else
0760 %         ylim = [0,max(max([ndNdtdiag(:,ivar_disp);ndNdtexp(maskic_exp,ivar_disp)]))]*1.2;%ndNdtplasma(:,ivar_disp),
0761 %     end
0762 %     %
0763 %     leg = {'LUKE'};%{'plasma','diag.'};%
0764 %     %
0765 %     if ~all(isnan(ndNdtexp(:,ivar_disp(1)))),
0766 %         if ndisp > 1,
0767 %             localcol = colors{rem(1,ncol)};
0768 %             localwidth = width;
0769 %         else
0770 %             localcol = color1;
0771 %             localwidth = width2;
0772 %         end
0773 %         graph1D_jd(ic(maskic_exp),ndNdtexp(maskic_exp,ivar_disp(1)),0,0,'','','',NaN,xlim_ic,ylim,style,marker,localcol,localwidth,siz,gca,1,lspace,bspace2,endNdtexp(maskic_exp,ivar_disp(1)));
0774 %         leg = ['Exp.',leg];
0775 %     end
0776 %     %graph1D_jd(ic,ndNdtplasma(:,ivar_disp(1)),0,0,'','','',NaN,xlim_ic,ylim,style,marker2,colors{rem(1,ncol)},width2,siz,gca,1,lspace,bspace2,endNdtplasma(:,ivar_disp(1)));
0777 %     graph1D_jd(ic,ndNdtdiag(:,ivar_disp(1)),0,0,xlab_ic,ylab,tit,leg,xlim_ic,ylim,style,marker3,colors{rem(1,ncol)},width2,siz,gca,red,lspace,bspace2,endNdtdiag(:,ivar_disp(1)));
0778 %     for ivar = 2:ndisp,
0779 %         %graph1D_jd(ic,ndNdtplasma(:,ivar_disp(ivar)),0,0,'','','',NaN,xlim_ic,ylim,style,marker2,colors{rem(ivar,ncol)},width2,siz,gca,1,lspace,bspace2,endNdtplasma(:,ivar_disp(ivar)));
0780 %         graph1D_jd(ic,ndNdtdiag(:,ivar_disp(ivar)),0,0,'','','',NaN,xlim_ic,ylim,style,marker3,colors{rem(ivar,ncol)},width2,siz,gca,1,lspace,bspace2,endNdtdiag(:,ivar_disp(ivar)));
0781 %         if ~all(isnan(ndNdtexp(:,ivar_disp(ivar)))),
0782 %             graph1D_jd(ic(maskic_exp),ndNdtexp(maskic_exp,ivar_disp(ivar)),0,0,'','','',NaN,xlim_ic,ylim,style,marker,colors{rem(ivar,ncol)},width,siz,gca,1,lspace,bspace2,endNdtexp(maskic_exp,ivar_disp(ivar)));
0783 %         end
0784 %     end
0785 %     %
0786 %     set(gca,'xtick',xtick_ic);
0787 %     %
0788 %     if isfield(opt,'ytick_CRNORM'),
0789 %         set(gca,'ytick',opt.ytick_CRNORM);
0790 %     end
0791 %     %
0792 %     print_jd(opt.print,['Fig_',savestr,'_CR_2D_norm'],[path_simul,'figures/'],ifig);
0793 %     %
0794 % end
0795 %
0796 %
0797 % --------------------- CURRENT PROFILE -----------------------
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 = {};%{'LUKE'};%{'plasma','diag.'};%
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 = {};%{'LUKE'};%{'plasma','diag.'};%
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 % --------------------- POWER PROFILE -----------------------
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 = {};%{'LUKE'};%{'plasma','diag.'};%
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 % figure(7),clf,set(7,'Name','Selected Count rate')
0904 % %
0905 % ylab = ['Count rate (s^{-1}) [',num2str(kmin),' - ',num2str(kmax),' keV]'];
0906 % ylim = NaN;%[0,2500];
0907 % %ytick = 0:500:2500;
0908 % %
0909 % leg = {};
0910 % %
0911 % for ivar = 1:length(var.disp),
0912 %     ivardisp = find(abs(var.list - var.disp(ivar)) < 10*eps);
0913 %     %
0914 %     if isempty(ivardisp),
0915 %         continue
0916 %     end
0917 %     %
0918 %     sdNdtdiag_disp = sdNdtdiag(:,ivardisp);%count rate
0919 %     %
0920 %     graph1D_jd(ic,sdNdtdiag_disp,0,0,'','','',NaN,xlim_ic,ylim,...
0921 %         style,markers{ivar},colors{ivar},width2,siz,gca,1,lspace,bspace,sqrt(sdNdtdiag_disp/dt));
0922 %     %
0923 %     leg = [leg,[var.lab,' = ',num2str(var.disp(ivar)),' ',var.unit]];
0924 %     %
0925 % end
0926 % %
0927 % set(gca,'xtick',xtick_ic);
0928 % %set(gca,'ytick',ytick);
0929 % %
0930 % %
0931 % leg = [leg,'Exp.'];
0932 % %
0933 % graph1D_jd(ic,sdNdtexp,0,0,xlab_ic,ylab,tit,leg,xlim_ic,ylim,...
0934 %     style,marker,color1,width2,siz,gca,red,lspace,bspace,sqrt(sdNdtexp/dt));
0935 % %
0936 % % for ivar = 1:length(var_disp),
0937 % %     ivardisp = find(abs(var.list - var_disp(ivar)) < 10*eps);
0938 % %     %
0939 % %     if isempty(ivardisp),
0940 % %         continue
0941 % %     end
0942 % %     %
0943 % %     sdNdtplasma_disp = sdNdtplasma(:,ivardisp);%number of counts
0944 % %     %
0945 % %     graph1D_jd(ic,sdNdtplasma_disp,0,0,'','','',NaN,xlim_ic,ylim,...
0946 % %         style2,markers{ivar},colors{ivar},width2,siz,gca,1,lspace,bspace,sqrt(sdNdtplasma_disp/dt));
0947 % %     %
0948 % % end
0949 % %
0950 % %print_jd(opt.print,['Fig_select_countrate_',num2str(vmindisp),'_',id_simul_o],[path_simul,'figures/'],7);
0951 % print_jd(opt.print,['Fig_select_countrate_',id_simul_o],[path_simul,'figures/'],7);
0952 % %
0953 % %
0954 % %
0955 % figure(8),clf,set(8,'Name','Selected Norm Count rate')
0956 % %
0957 % ylab = ['Normalized Count rate [',num2str(kmin),' - ',num2str(kmax),' keV]'];
0958 % ylim = [0,1.4];%sdNdtplasma,
0959 % ytick = 0:0.2:1.4;
0960 % %
0961 % leg = {};
0962 % %
0963 % for ivar = 1:length(var.disp),
0964 %     ivardisp = find(abs(var.list - var.disp(ivar)) < 10*eps);
0965 %     %
0966 %     if isempty(ivardisp),
0967 %         continue
0968 %     end
0969 %     %
0970 %     ndNdtdiag_disp = ndNdtdiag(:,ivardisp);%count rate
0971 %     endNdtdiag_disp = endNdtdiag(:,ivardisp);%count rate
0972 %     %
0973 %     graph1D_jd(ic,ndNdtdiag_disp,0,0,'','','',NaN,xlim_ic,ylim,...
0974 %         style,markers{ivar},colors{ivar},width2,siz,gca,1,lspace,bspace,endNdtdiag_disp);
0975 %     %
0976 %     leg = [leg,[var.lab,' = ',num2str(var.disp(ivar)),' ',var.unit]];
0977 %     %
0978 % end
0979 % %
0980 % set(gca,'xtick',xtick_ic);
0981 % set(gca,'ytick',ytick);
0982 % %
0983 % %
0984 % leg = [leg,'Exp.'];
0985 % %
0986 % graph1D_jd(ic,ndNdtexp,0,0,xlab_ic,ylab,tit,leg,xlim_ic,ylim,...
0987 %     style,marker,color1,width2,siz,gca,red,lspace,bspace,endNdtexp);
0988 % %
0989 % % for ivar = 1:length(var_disp),
0990 % %     ivardisp = find(abs(var.list - var_disp(ivar)) < 10*eps);
0991 % %     %
0992 % %     if isempty(ivardisp),
0993 % %         continue
0994 % %     end
0995 % %     %
0996 % %     ndNdtplasma_disp = ndNdtplasma(:,ivardisp);%number of counts
0997 % %     endNdtplasma_disp = endNdtplasma(:,ivardisp);%number of counts
0998 % %     %
0999 % %     graph1D_jd(ic,ndNdtplasma_disp,0,0,'','','',NaN,xlim_ic,ylim,...
1000 % %         style2,markers{ivar},colors{ivar},width2,siz,gca,1,lspace,bspace,endNdtplasma_disp);
1001 % %     %
1002 % % end
1003 % %
1004 % %print_jd(opt.print,['Fig_select_norm_countrate_',num2str(vmindisp),'_',id_simul_o],[path_simul,'figures/'],8);
1005 % print_jd(opt.print,['Fig_select_norm_countrate_',id_simul_o],[path_simul,'figures/'],8);
1006 % %
1007 %
1008 %
1009 % figure(9),clf,set(9,'Name','TPH_chord')
1010 % %
1011 % kmin = min(k);
1012 % %
1013 % ylab = ['Photon temperature (keV)'];
1014 % tit = '';
1015 % %
1016 % ylim = NaN;%[0,2500];
1017 % %ytick = 0:500:2500;
1018 % %
1019 % leg = {};
1020 % %
1021 % % for ivar = 1:length(var_disp),
1022 % %     ivardisp = find(abs(var.list - var_disp(ivar)) < 10*eps);
1023 % %     %
1024 % %     if isempty(ivardisp),
1025 % %         continue
1026 % %     end
1027 % %     %
1028 % %     maskQdiag = (1 - Qdiag(:,ivardisp,ivdisp) < 1e-2) & (Tphdiag(:,ivardisp,ivdisp) > eTphdiag(:,ivardisp,ivdisp));
1029 % %     %
1030 % %     graph1D_jd(ic(maskQdiag),Tphdiag(maskQdiag,ivardisp,ivdisp),0,0,'','','',NaN,xlim_ic,ylim,...
1031 % %         style,markers{ivar},colors{ivar},width2,siz,gca,1,lspace,bspace,eTphdiag(maskQdiag,ivardisp,ivdisp));
1032 % %     %
1033 % %     leg = [leg,[var_lab,' = ',num2str(var_disp(ivar)),' ',var_unit]];
1034 % %     %
1035 % % end
1036 % %
1037 % set(gca,'xtick',xtick_ic);
1038 % %set(gca,'ytick',ytick);
1039 % %
1040 % leg = [leg,'Exp.'];
1041 % %
1042 % maskexp = (1 - Qexp < 1e-2) & (Tphexp > eTphexp);
1043 % %
1044 % graph1D_jd(ic(maskexp),Tphexp(maskexp),0,0,xlab_ic,ylab,tit,leg,xlim_ic,ylim,...
1045 %     style,marker,color1,width2,siz,gca,red,lspace,bspace,eTphexp(maskexp));
1046 % %
1047 % % for ivar = 1:length(var_disp),
1048 % %     ivardisp = find(abs(var.list - var_disp(ivar)) < 10*eps);
1049 % %     %
1050 % %     if isempty(ivardisp),
1051 % %         continue
1052 % %     end
1053 % %     %
1054 % %     maskQplasma = (1 - Qplasma(:,ivardisp,ivdisp) < 1e-2) & (Tphplasma(:,ivardisp,ivdisp) > eTphplasma(:,ivardisp,ivdisp));
1055 % %     %
1056 % %     graph1D_jd(ic(maskQplasma),Tphplasma(maskQplasma,ivardisp,ivdisp),0,0,'','','',NaN,xlim_ic,ylim,...
1057 % %         style,markers{ivar},colors{ivar},width2,siz,gca,1,lspace,bspace,eTphplasma(maskQplasma,ivardisp,ivdisp));
1058 % %     %
1059 % %     leg = [leg,[var_lab,' = ',num2str(var_disp(ivar)),' ',var_unit]];
1060 % %     %
1061 % % end
1062 % %
1063 % %print_jd(opt.print,['Fig_1D_tph_chord_',num2str(vmindisp),'_',id_simul_o],[path_simul,'figures/'],9);
1064 % print_jd(opt.print,['Fig_1D_tph_chord_',id_simul_o],[path_simul,'figures/'],9);
1065 %
1066 %
1067 % --------------------- Norm. Exp. CR -----------------------
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         %print_jd(opt.print,['Fig_countrate_exp_',num2str(vmindisp),'_',id_simul_o],[path_simul,'figures/'],10);
1102         print_jd(opt.print,['Fig_',savestr,'_CR_EXP'],[path_simul,'figures/'],ifig);
1103         %
1104     end
1105 end
1106 %
1107 % --------------------- Weighed ray length -----------------------
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 %set(gca,'xminorgrid','off')
1122 %set(gca,'xminortick','off')
1123 %
1124 print_jd(opt.print,['Fig_',savestr,'_S'],[path_simul,'figures/'],ifig);
1125 %
1126 % --------------------- Power absorption -----------------------
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 %set(gca,'xminorgrid','off')
1141 %set(gca,'xminortick','off')
1142 %
1143 print_jd(opt.print,['Fig_',savestr,'_Pvar'],[path_simul,'figures/'],ifig);
1144 
1145 
1146 % %
1147 % figure(3),clf,set(3,'Name','Deposition peak')
1148 % %
1149 % ylab = '\rho_{peak}';
1150 % tit = '';
1151 % ylim = [0,1];
1152 % %
1153 % leg = {'LUKE','C3PO'};
1154 % %
1155 % if var.firstref,
1156 %     graph1D_jd(xlim,[drho(1),drho(1)],xlog,0,'','','',NaN,xlim,ylim,style,marker,color3,width,siz);
1157 %     leg = [[var_lab,' = ',num2str(var.list(1))],leg];
1158 % end
1159 % %
1160 % if var.lastref,
1161 %     graph1D_jd(xlim,[drho(end),drho(end)],xlog,0,'','','',NaN,xlim,ylim,style2,marker,color3,width,siz);
1162 %     leg = [[var_lab,' = ',num2str(var.list(end))],leg];
1163 % end
1164 % %
1165 % graph1D_jd(var.list,drho,xlog,0,'','','',NaN,xlim,ylim,style,marker2,color2,width2,siz);
1166 % graph1D_jd(var.list,drho_lin,xlog,0,xlab,ylab,tit,leg,xlim,ylim,style,marker1,color3,width2,siz,gca,red,lspace,bspace);
1167 % %
1168 % set(gca,'xtick',xtick);
1169 % set(gca,'xminorgrid','off')
1170 % set(gca,'xminortick','off')
1171 % %
1172 % print_jd(opt.print,['Fig_rho_peak_',id_simul_o],[path_simul,'figures/'],3);
1173 % %
1174 % %
1175 % %
1176 % figure(4),clf,set(4,'Name','RF ray fragments')
1177 % %
1178 % ylab = 'RF ray fragments';
1179 % tit = '';
1180 % ylim = NaN;
1181 % %
1182 % leg = {};
1183 % %
1184 % if var.firstref,
1185 %     graph1D_jd(xlim,[dnfrags(1),dnfrags(1)],xlog,0,'','','',NaN,xlim,ylim,style,marker,color3,width,siz);
1186 %     leg = [[var_lab,' = ',num2str(var.list(1))],leg];
1187 % end
1188 % %
1189 % if var.lastref,
1190 %     graph1D_jd(xlim,[dnfrags(end),dnfrags(end)],xlog,0,'','','',NaN,xlim,ylim,style2,marker,color3,width,siz);
1191 %     leg = [[var_lab,' = ',num2str(var.list(end))],leg];
1192 % end
1193 % %
1194 % graph1D_jd(var.list,dnfrags,xlog,0,xlab,ylab,tit,leg,xlim,ylim,style,marker2,color2,width2,siz,gca,red,lspace,bspace);
1195 % %
1196 % set(gca,'xtick',xtick);
1197 % set(gca,'xminorgrid','off')
1198 % set(gca,'xminortick','off')
1199 % %
1200 % print_jd(opt.print,['Fig_nfrags_',id_simul_o],[path_simul,'figures/'],4);
1201 % %
1202 % %
1203 % xlab = '\rho';
1204 % xlim = [0,1];
1205 % xtick = 0:0.2:1;
1206 % %
1207 % figure(5),clf,set(5,'Name','Deposition profile')
1208 % %
1209 % ylab = 'dP/d\rho/(2\piR_p) (MW/m)';
1210 % tit = '';
1211 % ylim = NaN;
1212 % %
1213 % leg = {'C3PO','LUKE'};
1214 % %
1215 % graph1D_jd(dxrho(ivar_C3PO,:),dwxdPdrho_rf_2piRp_lin(ivar_C3PO,:),0,0,xlab,ylab,tit,NaN,xlim,ylim,style2,marker,color,width,siz,gca,red,lspace,bspace);
1216 % graph1D_jd(dxrho(ivar_C3PO,:),dwxdPdrho_rf_2piRp,0,0,'','','',leg,xlim,ylim,style,marker,color,width2,siz);
1217 % %
1218 % set(gca,'xtick',xtick);
1219 % %
1220 % print_jd(opt.print,['Fig_profile_',id_simul_o],[path_simul,'figures/'],5);
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;%,y3
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         %graph1D_jd(x2,y3(:,1),0,0,'','','',NaN,xlim,ylim,styles{3},markers{1 + rem(1,ncol)},colors{1 + rem(1,ncol)},widths(3),siz,gca,1,lspace,bspace,ey3(:,1));
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             %graph1D_jd(x3,y3(:,ivar),0,0,'','','',NaN,xlim,ylim,styles{3},markers{1 + rem(ivar,ncol)},colors{1 + rem(ivar,ncol)},widths(3),siz,gca,1,lspace,bspace,ey3(:,ivar));
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         %for ivar = 1:size(y2,2),
1290             %graph1D_jd(x3,y3(:,ivar),0,0,'','','',NaN,xlim,ylim,styles{3},markers{1 + rem(ivar,ncol)},colors{1 + rem(ivar,ncol)},widths(3),siz,gca,1,lspace,bspace,ey3(:,ivar));
1291         %end
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

Community support and wiki are available on Redmine. Last update: 18-Apr-2019.