Skip to content
Snippets Groups Projects
Commit b42d0522 authored by Antoine Merle's avatar Antoine Merle
Browse files

Merge remote-tracking branch 'origin/master' into add_summary_in_defaults

parents c3dffdd3 ab71e5df
No related branches found
No related tags found
1 merge request!64add new ids available, thomson_scattering and summary, in various global functions
Pipeline #42942 passed with stage
in 1 minute and 35 seconds
function Info=AK_MDS_node_info(node,shot,k_debug,shot_time)
% Get information about node in MDS
% Call: Info=AK_MDS_node_info(node,shot,k_debug)
% node - MDS node name, for example '\RESULTS::CXRS_001:COMMENT'
% shot - TCV shot number (default [], opened shot)
% k_debug - debug key (default false)
s=sprintf('%s',mfilename);
Info.OK = 1;
Info.msg = 'OK';
if nargin < 1, node=[]; end
if nargin < 2, shot=[]; end
if nargin < 3, k_debug = false; end
if nargin < 4, shot_time=[]; end
if ~isempty(shot),
Info.shot=mdsopen(shot);
if isempty(Info.shot),
Info.msg=sprintf('ERROR in %s - MDS Open shot #%d - probably not exist',s,shot); disp(Info.msg);
Info.OK=-100; mdsclose; return
elseif (shot~=Info.shot)&&(shot~=0),
Info.msg=sprintf('ERROR in %s - MDS Open shot #%d <> data.shot #%d',s,shot,Info.shot); disp(Info.msg);
Info.OK=-101; mdsclose; return
end
else
[Info.shot,stat]=mdsvalue('$SHOT');
if ~mod(stat,2),
Info.msg=sprintf('ERROR in %s - MDS shot is nor opened',s); disp(Info.msg);
Info.OK=-102; mdsclose; return
elseif isempty(Info.shot);
Info.msg=sprintf('ERROR in %s - MDS shot is unknown',s); disp(Info.msg);
Info.OK=-103; mdsclose; return
end
end
if isempty(shot_time),
% Info.shot_time = mdsvalue('shot_date(nint($1))',Info.shot);
[Info.shot_time,stat] = mdsdata(['tcv_shot_time(',int2str(Info.shot),')']);
else
Info.shot_time=shot_time; stat=1;
end
chk_tim=true;
if ~mod(stat,2),
[shot_time,stat] = mdsvalue('shot_date(nint($1))',Info.shot);
lf= findstr(shot_time,sprintf('\n'));
if ~isempty(lf), shot_time=shot_time(1:lf(1)-1); end
Info.shot_time = shot_time;
chk_tim=false;
end
if (k_debug~=0), disp(sprintf(' ----- TCV shot %d cycle start date and time: %s -----',Info.shot,Info.shot_time)); end
Info.shot_time_vec=datevec(Info.shot_time,'dd-mmm-yyyy HH:MM:SS.FFF'); timk=[10000 100 1 0.01 0.0001 0.000001];
Info.shot_run= sum(Info.shot_time_vec.*timk);
if ~isempty(node),
Info.node=node;
tdis=sprintf('getnci("\\%s","FULLPATH")' ,node); [node_fullpath,stat_fullpath] =mdsdata(tdis);
tdis=sprintf('owner_ascii("\\%s")' ,node); [node_ownerid, stat_ownerid ] =mdsdata(tdis);
tdis=sprintf('times(getnci("\\%s","TIME_INSERTED"))',node); [node_time, stat_time ] =mdsdata(tdis);
tdis=sprintf('uid_gid("\\%s")' ,node); [node_ownerID, stat_ownerID ] =mdsdata(tdis);
if ~mod(stat_fullpath,2), node_fullpath = 'unknown'; Info.OK = -201; end
if ~mod(stat_ownerid ,2), node_ownerid = 0 ; Info.OK = -202; end
if ~mod(stat_time ,2), node_time = 'unknown'; Info.OK = -203; end
if ~mod(stat_ownerID ,2), node_ownerID = [] ; Info.OK = -204; end
Info.node_fullpath= deblank(node_fullpath);
Info.node_ownerid = node_ownerid;
Info.node_time = node_time;
Info.node_ownerID = node_ownerID;
%if ~isempty(node_ownerID),
% cmd=sprintf('getent passwd %d | sed -e ''s/\\:.*//''',node_ownerID(1)); [stat,owner] = system(cmd);
% if (stat~=0), owner=[]; end
% cmd=sprintf('getent group %d | sed -e ''s/\\:.*//''',node_ownerID(2)); [stat,group] = system(cmd);
% if (stat~=0), group=[]; end
% if isempty(group), group=sprintf('%d',node_ownerID(2)); end
% if isempty(owner), owner=sprintf('%d',node_ownerID(1)); end
% if ~isempty(findstr(group,'invalid option')), group='unknown'; end
% if ~isempty(findstr(owner,'invalid option')), owner='unknown'; end
% node_owner=sprintf('[%s,%s]',deblank(group),deblank(owner));
%else
% node_owner=sprintf('[unknown,unknown]');
%end
Info.node_owner = sprintf(' user %s',node_ownerid);
if (k_debug~=0), disp(sprintf('Node %s (%s) created %s by %s',Info.node,Info.node_fullpath,Info.node_time,Info.node_owner)); end
if mod(stat_time ,2),
Info.node_time_vec=datevec(Info.node_time,'dd-mmm-yyyy HH:MM:SS.FFF'); timk=[10000 100 1 0.01 0.0001 0.000001];
Info.node_run= sum(Info.node_time_vec.*timk);
else
Info.node_time_vec=[1970 1 1 0 0 0]; timk=[10000 100 1 0.01 0.0001 0.000001];
Info.node_run= sum(Info.node_time_vec.*timk);
end
if (Info.node_run-Info.shot_run)<-0.005,
if (Info.OK==1)&&chk_tim,
Info.OK=-301;
Info.msg=sprintf('WARNING node %s is craeated before shot #%d created',Info.node,Info.shot);
if (k_debug~=0), disp(Info.msg); end
end
end
end
if ~isempty(shot), mdsclose; end
return
\ No newline at end of file
function profiles=CXRS_fit_profies(V,Times,param_prof,param_plot);
% Fit profiles with "interpos" function
% Call profiles=CXRS_fit_profies(V,Times,param_prof,param_plot);
%sel=find((V.t+V.dt/2>=Times(1))&(V.t-V.dt/2<=Times(2)));
sel=find((V.t>=Times(1))&(V.t<=Times(2)));
x = V.x(sel); dx = V.dx(sel); y = V.y(sel); dy = V.dy(sel); t = V.t(sel); dt = V.dt(sel); sys = V.sys(sel);
% shift of duplicated points in rho
Xb=x;
for ip=1:length(Xb)
sss=1:length(Xb); sss=find(sss~=ip);
iff=(find(Xb(ip)==Xb(sss)));
if length(iff)>0, Xb(iff(1))=Xb(iff(1))+1.e-8; end
end
% sort points in rho
[x,iii] = sort(Xb);
if length(iii)==0 % No data
profiles.t_lim=Times;
profiles.x_prof=[];
%profiles.x_prof= NaN(1,101)
profiles.y_prof=[];
profiles.dy_prof=[];
profiles.use.x=[]; profiles.use.dx=[]; profiles.use.y=[]; profiles.use.dy=[]; profiles.use.t=[]; profiles.use.dt=[];profiles.use.sys=[];
profiles.param_prof = param_prof;
profiles.param_plot = param_plot;
if param_plot.ON,
if param_plot.clear, clf; end
hve(1)=plot(0,NaN,'ok'); hold on
set(hve(1),'Color',param_plot.color,'LineStyle','none','LineWidth',param_plot.lnwidth,'Marker',param_plot.typemk,'MarkerSize',param_plot.sizemk);
profiles.plot_handle=hve(1);
end
return;
end
dx=dx(iii); y=y(iii); dy=dy(iii); t=t(iii); dt=dt(iii);sys=sys(iii);
if isempty(param_prof.xout), param_prof.xout=linspace(min(x)*0.98,max(x)*1.02,101); end
if ((min(x)-min(param_prof.xout))>0.45),
param_prof.xout=linspace(min(x)*0.85,max(param_prof.xout),length(param_prof.xout));
%disp(sprintf('Redefine rho for %4.4f-%4.4fsec',Times));
end
x_prof = param_prof.xout;
XXmax=max([max(x)+0.01 1.3]);
if length(iii)>=10,
%y_prof = interpos(param_prof.kopt,x,y,x_prof,param_prof.taus,param_prof.nbc,param_prof.ybc,abs(dy)+param_prof.err_min);
%disp('...before')
y_prof = interpos(param_prof.kopt,[0; x; XXmax],[y(1); y; 0],x_prof,param_prof.taus,param_prof.nbc,param_prof.ybc,[abs(y(1))+abs(dy(1))*10.; abs(dy); 0]+param_prof.err_min );
%disp('...after')
else
y_prof = x_prof'*NaN;
end
y_prof=y_prof';
for ip=1:length(x_prof)
W=1./dy.*1./(1.+((x-x_prof(ip))./dx).^2); W=W/sum(W);
Wn=sum(1./(1.+((x-x_prof(ip))./dx).^2));
dy_prof(ip) = sqrt(sum(W.*dy.^2))./sqrt(Wn);
end
profiles.t_lim=[min(t-dt/2.) max(t+dt/2.)];
profiles.x_prof=x_prof;
profiles.y_prof=y_prof;
profiles.dy_prof=dy_prof;
profiles.use.x=x; profiles.use.dx=dx; profiles.use.y=y; profiles.use.dy=dy; profiles.use.t=t; profiles.use.dt=dt;profiles.use.sys=sys;
profiles.param_prof = param_prof;
profiles.param_plot = param_plot;
if param_plot.ON,
if param_plot.clear, clf; end
% matlab version
[v, ~] = version;
mat_ver = str2double(v(1:3));
hve=CXRS_errorbar(mat_ver, x,y,dx,dy); set(hve,'Color',param_plot.color); C=get(hve(1),'Color'); hold on
set(hve(1),'Color',max(C-0.2,[0 0 0]),'LineStyle','none','LineWidth',1.0,'Marker',param_plot.typemk,'MarkerSize',param_plot.sizemk);
set(hve(2),'Color',C); set(hve(1),'MarkerFaceColor',min(C+0.5,[1 1 1]),'MarkerEdgeColor',max(C-0.3,[0 0 0]));
if param_plot.clear, grid on; if ~isnan(max(x_prof)), set(gca,'Xlim',[min(x_prof) max(x_prof)]); else, set(gca,'Xlim',[0 1.1]); end, end
hh=plot(x_prof,y_prof,'-r');
set(hh,'Color',max(C-0.1,[0 0 0]),'LineStyle','-','LineWidth',param_plot.lnwidth);
if (size(y_prof,2)~=size(dy_prof,2)), y_prof=y_prof'; end
% whos x_prof y_prof dy_prof
hh=plot(x_prof,y_prof+dy_prof,'-r');
set(hh,'Color',min(C+0.2,[1 1 1]),'LineStyle','--','LineWidth',1.);
hh=plot(x_prof,y_prof-dy_prof,'-r');
set(hh,'Color',min(C+0.2,[1 1 1]),'LineStyle','--','LineWidth',1.);
profiles.plot_handle=hve(1);
end
return
function cxrs_profiles = CXRS_get_profiles(varargin)
% Gets (reads from MDS) Ti,Vi,nC,Zeff profiles from TCV CXRS diagnostic, interpolates and plots
% Call: cxrs_profiles = CXRS_get_profiles(varargin);
%
% Few Shots where it works: 42422 42404 42398 42310 42388 42357 42353 42340 42329 42308 42254 42231
% Old Shots where it works: 41874 41757 41396 40268 40070 39360 38930 37108 36424 36401 36354 36203 36201 36196 (07.11.2008)
%
% Inputs: {1} shot - TCV shot number
% or data - structure from CXRS data analysis
% {2} sys - cxrs system(s) LFS, HFS, ALL or 1,2,0 (default ALL)
% {3} time - time, {a} [tmin tmax],
% {b} [tmin:dt:tmax], [Tmin(i) Tmax(i)]=[t(i) t(i+1)];
% {c} -[tmin(1) tmax(1) ... tmin(end) tmax(end)]) - direct specification of [Tmin(i) Tmax(i)]=abs([t(i*2-1) t(i*2)]);
% default [] - all times for first system in sys
% {4} param - parameters strucrure, useful fields:
% param.k_plot - 1 (default) plot results, 0 disable graphics, -1 plot in new figures, <=-2 plot on the top of existing figure (hold on)
% param.prof.all - structire with parameters for interpos (see help interpos) used if corresponding filelds in param.prof.(Ti,vi,nc,zeff) are empty
% param.prof.all.xout - rho for proffit, if empty variable on time according to rho_min rho_max of CXRS measurement
% Output:
% OK: 1 -OK, or error index
% argin: cell of input arguments
% shot: shot number
% system: CXRS systems used
% param: used parameters strucrure
% Times: used times
% data: cxrs data from CXRS_load_MDS(shot,isys,'result',[],...)
% exp: experimental data for Ti, vTor, vPol, nC, Zeff structures with x,dx,y,dy,t,dt,sys
% Ti, vTor, vPol, nC, Zeff - cells with proffit data from CXRS_fit_profies.m function
% proffit: proffit data Ti(eV), vTor(km/sec), vPol(km/sec), nC(m^{-3}), Zeff all (time x rho) with rho(time x rho) - (normalized poloidal flux)^0.5,
%
%
% See also: CXRS_save_profiles - save cxrs_profiles in MDS
% CXRS_calc_automatic - automatic CXRS data analysis
% CXRS_save_MDS - save CXRS data
% Examples: shot=42422; cxrs_profiles = CXRS_get_profiles(shot); % standard run
% cxrs_profiles = CXRS_get_profiles; param=cxrs_profiles.param; param.prof.all.xout=linspace(0,1.1,101);
% cxrs_profiles = CXRS_get_profiles(shot,[],[],param); % define rho grid
% mdsopen(shot); tdiTS=tdi('\results::thomson.profiles.auto:te'); mdsclose; % get TS times
% dTimes=0.05; % max TS/CXRS time difference (50/2 ms)
% Times(1:2:length(tdiTS.dim{1})*2)=tdiTS.dim{1}'-dTimes/2;
% Times(2:2:length(tdiTS.dim{1})*2)=tdiTS.dim{1}'+dTimes/2;
% cxrs_profiles = CXRS_get_profiles; param=cxrs_profiles.param; param.prof.all.xout=linspace(0,1.1,101);
% cxrs_profiles = CXRS_get_profiles(shot,[],-Times,param); % gives CXRS profiles at TS times 101 rho points in [0 1.1]
% cxrs_profiles = CXRS_get_profiles; param=cxrs_profiles.param; param.prof.all.xout=tdiTS.dim{2}';
% param.k_plot=0; % without plot for profiles
% cxrs_profiles = CXRS_get_profiles(shot,[],-Times,param); % gives CXRS profiles at TS times and rho
% param.prof.all.xout=[]; param.prof.Ti.taus=1.e-5; param.prof.vi.taus=5.e-5;
% cxrs_profiles = CXRS_get_profiles(shot,[],[],param); % define taus for interpos for Ti and vi
% plot profiles from LFS,VER&HFS systems on the same plots by different colors
% cxrs_profiles = CXRS_get_profiles; param=cxrs_profiles.param; param.prof.all.xout=linspace(0,1.1,101);
% param.prof.Ti.taus=1.e-5; param.prof.vi.taus=2.e-5; param.prof.nc.taus=5.e-5;
% shot=45262; times=[0.41 1.01];
% param.k_plot= 1; cxrs_profiles = CXRS_get_profiles(shot,1,times,param);
% param.k_plot=-2; cxrs_profiles = CXRS_get_profiles(shot,2,times,param);
% param.k_plot=-3; cxrs_profiles = CXRS_get_profiles(shot,3,times,param);
%
%
% Created: A.Karpushov, CRPP-EPFL, 01.04.2011
s=mfilename;
cxrs_profiles.OK=1;
%if nargin==0, cmd=sprintf('help %s',s); eval(cmd); cxrs_profiles.OK=0; return; end
% input arguments
ninparg = 4; inparg=varargin; for iinparg=nargin+1:ninparg, inparg{iinparg}=[]; end
if isa(inparg{1},'numeric'), % shot number
shot=inparg{1}; k_load=1;
elseif isa(inparg{1},'struct'), % data structure from CXRS data analysis
data=inparg{1};
if ~isfield(data,'shot'), data_OK=0; elseif ~isfield(data,'calc'), data_OK=0; elseif ~isfield(data.calc,'Ti'), data_OK=0; else data_OK=1; end
if data_OK, k_load=0; shot=data.shot; inparg{2}=data.system; else, cmd=sprintf('help %s',s); eval(cmd); cxrs_profiles.OK=0; return; end
else,
cmd=sprintf('help %s',s); eval(cmd); cxrs_profiles.OK=-9998; return;
end
if isempty(inparg{2}),
sys=0;
elseif isa(inparg{2},'char'),
switch upper(inparg{2});
case ('ALL'),
sys=0;
case ('LFS'),
sys=1;
case ('VER'),
sys=2;
case ('HFS'),
sys=3;
case ('EDG'),
sys=4;
otherwise,
cmd=sprintf('help %s',s); eval(cmd); cxrs_profiles.OK=-9999; return;
end
elseif isa(inparg{2},'numeric'),
if ((inparg{2} >= -1)&(inparg{2} <= 4)),
sys=inparg{2};
else
cmd=sprintf('help %s',s); eval(cmd); cxrs_profiles.OK=0; return;
end
else,
cmd=sprintf('help %s',s); eval(cmd); cxrs_profiles.OK=0; return;
end
if (sys(1)==0), sys=[1 2]; end % LFS & VER systems
if (sys(1)==-1), sys=[1 2 3]; end % LFS & VER & HFS systems
if ~isempty(inparg{3}),
if (max(inparg{3}(1))<=0)&(length(inparg{3})>=2),
Time_min=abs(inparg{3}(1:2:end)); Time_max=abs(inparg{3}(2:2:end)); % [tmin(1) tmax(1) tmin(2) tmax(2) ... tmin(end) tmax(end)]
elseif (length(inparg{3})==1),
Time_min=abs(inparg{3})-0.05; Time_max=abs(inparg{3})+0.05; % single time point
else
Time_min=abs(inparg{3}(1:end-1)); Time_max=abs(inparg{3}(2:end)); % tmax(i)=tmin(i-1)
end
else,
Time_min=[]; Time_max=[];
end
% Default paramaters
param.name = 'Default parameters';
param.k_plot = 1;
param.k_debug = 1;
[colos,lnstyle,typemk]=CXRS_plot_definition;
param.plot.colos = colos;
param.plot.lnstyle = lnstyle;
param.plot.typemk = typemk;
a.kopt = 23; % option for interpolation and extrapolation method, 23 - cubic spline interpolation, with tension=taus
%a.xout = linspace(0,1.10,101); % output grid for interpos
a.xout = [];
%a.taus = [];
a.taus = 2.e-3 ; % tension value for cubic spline interpolation
%a.nbc = [1 2 ]; % 0/1/2 - VALUE OF SECOND DERIVATIVE; 1-ST; FUNCTION AT XBCLFT
a.nbc = [1 0 ]; % 0/1/2 - VALUE OF SECOND DERIVATIVE; 1-ST; FUNCTION AT XBCLFT
a.ybc = [0. 0. 0. 1.]; % 1-ST DERIVATIVE 0 (left); 2-MD DERIVATIVE 0. (right) at rho 0.0 and 1.0
% for sigma taus(i)=taus .* sigma(i) ./ min(sigma)
param.prof.all = a;
param.prof.Ti = a;
param.prof.vi = a;
param.prof.nc = a;
param.prof.zeff = a;
param.prof.Ti.err_min = 10.0;
param.prof.vi.err_min = 0.5;
param.prof.nc.err_min = 1.e+17;
param.prof.zeff.err_min = 0.5;
% add input parameters
if ~isempty(inparg{4}),
if ~isa(inparg{4},'struct'), cmd=sprintf('help %s',s); eval(cmd); cxrs_profiles.OK=0; return; end
parinp=inparg{4};
parnames = fieldnames(parinp);
for ipar=1:length(parnames)
cmd=sprintf('param.%s = parinp.%s;',parnames{ipar},parnames{ipar});
eval(cmd);
end
end
if ~isempty(param.prof.all.xout),
param.prof.Ti.xout = param.prof.all.xout;
param.prof.vi.xout = param.prof.all.xout;
param.prof.nc.xout = param.prof.all.xout;
param.prof.zeff.xout = param.prof.all.xout;
end
cxrs_profiles.argin=inparg;
cxrs_profiles.shot = shot;
cxrs_profiles.system = sys;
cxrs_profiles.param = param;
cxrs_profiles.Times=(Time_min+Time_max)/2.;
if nargin==0, cxrs_profiles.OK=0; return; end
V.y = []; V.dy = []; V.x=[]; V.dx=[]; V.t=[]; V.dt=[]; V.sys=[];
Ti=V; vTor=V; vPol=V; nC=V; Zeff=V;
jsis=0;
for isys=sys
%data=CXRS_load_MDS(shot,isys,'result',[],param.k_debug,param.k_plot);
if k_load, data=CXRS_load_MDS(shot,isys,'result',[],param.k_debug,0); end
% if ~isfield(data.calc,'Ti'), data.OK=0; end
if (data.OK==1)
jsis=jsis+1; cxrs_profiles.data{jsis}=data;
nr=size(data.calc.Ti,1); nt=length(data.calc.time);
for it=1:nt,
time(1:nr,it)=data.calc.time(it);
if (length(data.calc.dtime)==1), dtime(1:nr,it)=data.calc.dtime; else, dtime(1:nr,it)=data.calc.dtime(it); end
end
if isempty(Time_min), Time_min=time(1,:)-dtime(1,:)/2; Time_max=time(1,:)+dtime(1,:)/2; end
Times=(Time_min+Time_max)/2.;
if isfield(data.calc,'Ti'),
Vold=Ti; V.y=data.calc.Ti; V.dy=data.calc.err_Ti;
sel=find(~isnan(V.y)&~isnan(V.dy));
V.y=data.calc.Ti(sel); V.dy=data.calc.err_Ti(sel); V.x=data.calc.rho(sel); V.dx=data.calc.rho_err(sel); V.t=time(sel); V.dt=dtime(sel); V.sys=ones(size(V.y))*data.system;
V.y = [Vold.y; V.y]; V.dy = [Vold.dy; V.dy]; V.x = [Vold.x; V.x]; V.dx = [Vold.dx; V.dx]; V.t = [Vold.t; V.t]; V.dt = [Vold.dt; V.dt]; V.sys = [Vold.sys; V.sys];
Ti=V;
end
if isfield(data.calc,'vi')&((((data.system==2)&(data.shot<47823))||((data.system==3)&(data.shot>=47823)))||(data.system==4)), % VER CXRS system
Vold=vPol; V.y=data.calc.vi; V.dy=data.calc.err_vi;
sel=find(~isnan(V.y)&~isnan(V.dy));
V.y=data.calc.vi(sel); V.dy=data.calc.err_vi(sel); V.x=data.calc.rho(sel); V.dx=data.calc.rho_err(sel); V.t=time(sel); V.dt=dtime(sel); V.sys=ones(size(V.y))*data.system;
V.y = [Vold.y; V.y]; V.dy = [Vold.dy; V.dy]; V.x = [Vold.x; V.x]; V.dx = [Vold.dx; V.dx]; V.t = [Vold.t; V.t]; V.dt = [Vold.dt; V.dt]; V.sys = [Vold.sys; V.sys];
vPol=V;
else % LFS CXRS system
Vold=vTor; V.y=data.calc.vi; V.dy=data.calc.err_vi;
sel=find(~isnan(V.y)&~isnan(V.dy));
V.y=data.calc.vi(sel); V.dy=data.calc.err_vi(sel); V.x=data.calc.rho(sel); V.dx=data.calc.rho_err(sel); V.t=time(sel); V.dt=dtime(sel); V.sys=ones(size(V.y))*data.system;
V.y = [Vold.y; V.y]; V.dy = [Vold.dy; V.dy]; V.x = [Vold.x; V.x]; V.dx = [Vold.dx; V.dx]; V.t = [Vold.t; V.t]; V.dt = [Vold.dt; V.dt]; V.sys = [Vold.sys; V.sys];
vTor=V;
end
if isfield(data.calc,'ni'),
Vold=nC; V.y=data.calc.ni; V.dy=data.calc.err_ni;
sel=find(~isnan(V.y)&~isnan(V.dy));
V.y=data.calc.ni(sel); V.dy=data.calc.err_ni(sel); V.x=data.calc.rho(sel); V.dx=data.calc.rho_err(sel); V.t=time(sel); V.dt=dtime(sel); V.sys=ones(size(V.y))*data.system;
V.y = [Vold.y; V.y]; V.dy = [Vold.dy; V.dy]; V.x = [Vold.x; V.x]; V.dx = [Vold.dx; V.dx]; V.t = [Vold.t; V.t]; V.dt = [Vold.dt; V.dt]; V.sys = [Vold.sys; V.sys];
nC=V;
end
if isfield(data.calc,'zeff'),
Vold=Zeff; V.y=data.calc.zeff; V.dy=data.calc.err_zeff;
sel=find(~isnan(V.y)&~isnan(V.dy));
V.y=data.calc.zeff(sel); V.dy=data.calc.err_zeff(sel); V.x=data.calc.rho(sel); V.dx=data.calc.rho_err(sel); V.t=time(sel); V.dt=dtime(sel); V.sys=ones(size(V.y))*data.system;
V.y = [Vold.y; V.y]; V.dy = [Vold.dy; V.dy]; V.x = [Vold.x; V.x]; V.dx = [Vold.dx; V.dx]; V.t = [Vold.t; V.t]; V.dt = [Vold.dt; V.dt]; V.sys = [Vold.sys; V.sys];
Zeff=V;
end
end
end
if isempty(Ti.y), msg=sprintf('%s - No CXRS Data for TCV shot:%d',s,cxrs_profiles.shot); disp(msg); cxrs_profiles.OK=-100; return; end
cxrs_profiles.Times=Times;
cxrs_profiles.Time_min=Time_min;
cxrs_profiles.Time_max=Time_max;
cxrs_profiles.exp.Ti=Ti;
cxrs_profiles.exp.vTor=vTor;
cxrs_profiles.exp.vPol=vPol;
cxrs_profiles.exp.nC=nC;
cxrs_profiles.exp.Zeff=Zeff;
figures=[1:5]+9900;
names_exp{1} = 'Ti'; names_exp{2} = 'vTor'; names_exp{3} = 'vPol'; names_exp{4} = 'nC'; names_exp{5} = 'Zeff';
names_par{1} = 'Ti'; names_par{2} = 'vi'; names_par{3} = 'vi'; names_par{4} = 'nc'; names_par{5} = 'zeff';
names_uni{1} = 'eV'; names_uni{2} = 'km/sec'; names_uni{3} = 'km/sec'; names_uni{4} = 'm^{-3}'; names_uni{5} = ' ';
%if cxrs_profiles.param.k_plot==1 || cxrs_profiles.param.k_plot==-1 || cxrs_profiles.param.k_plot<=-2
if cxrs_profiles.param.k_plot~=0
param_plot.ON = 1; param_plot.lnwidth = 2.0; param_plot.sizemk = 6.0;
else
param_plot.ON = 0;
end
iaddcolor=0;
for iexp=1:length(names_exp),
if isfield(cxrs_profiles.exp,names_exp{iexp})
if cxrs_profiles.param.k_plot==1
figure(figures(iexp))
elseif cxrs_profiles.param.k_plot>=2
figure(figures(iexp))
iaddcolor=cxrs_profiles.param.k_plot+1;
elseif cxrs_profiles.param.k_plot==-1
figure
elseif cxrs_profiles.param.k_plot<=-2
figure(figures(iexp)); hold on
iaddcolor=-cxrs_profiles.param.k_plot+1;
end
clear profiles
cmd=sprintf('param_prof = cxrs_profiles.param.prof.%s;',names_par{iexp}); eval(cmd);
cmd=sprintf('exp_data = cxrs_profiles.exp.%s;',names_exp{iexp}); eval(cmd);
if ~isempty(exp_data.y),
for it=1:length(cxrs_profiles.Time_min)
%if (it==1 && iaddcolor==0), param_plot.clear = 1; else, param_plot.clear = 0; end
if (it==1 && cxrs_profiles.param.k_plot>0), param_plot.clear = 1; else, param_plot.clear = 0; end
param_plot.color = cxrs_profiles.param.plot.colos(it+iaddcolor,:);
param_plot.typemk = cxrs_profiles.param.plot.typemk{it+iaddcolor};
param_plot.lnstyle = cxrs_profiles.param.plot.lnstyle{1};
profiles{it}=CXRS_fit_profies(exp_data,[cxrs_profiles.Time_min(it) cxrs_profiles.Time_max(it)],param_prof,param_plot);
end
cmd=sprintf('cxrs_profiles.%s=profiles;',names_exp{iexp}); eval(cmd);
%if (cxrs_profiles.param.k_plot>0),
if (cxrs_profiles.param.k_plot~=0),
title(sprintf('CXRS %s for TCV shot: %5.5d sys.No.:[%s]',names_exp{iexp},cxrs_profiles.shot,num2str(cxrs_profiles.system)));
xlabel('\rho_{TCV}')
ylabel(sprintf('%s, %s',names_exp{iexp},names_uni{iexp}));
clear hh leg
for it=1:length(profiles),
hh(it)=profiles{it}.plot_handle;
if isempty(profiles{it}.y_prof),
leg{it}=sprintf('%3.3f-%3.3fs - No Data',profiles{it}.t_lim);
else
%leg{it}=sprintf('%2.2f-%2.2f->%2.2f-%2.2fs',cxrs_profiles.Time_min(it),cxrs_profiles.Time_max(it),profiles{it}.t_lim);
%leg{it}=sprintf('%3.3f-%3.3fs',profiles{it}.t_lim);
if length(cxrs_profiles.system)==1
SysP=sprintf('(S%d)',cxrs_profiles.system);
else
SysP='';
end
leg{it}=sprintf('#%d@%3.3f-%3.3fs%s',shot,profiles{it}.t_lim,SysP);
set(hh(it),'Tag','CXRS data','DisplayName',leg{it});
end
end
hE = findobj(gcf,'-regexp','Tag','CXRS data');
if(length(hE)>0),
hE=hE(end:-1:1);
leg=get(hE,'DisplayName');
legend(hE,leg,'location','best');
end
%legend(hh,leg,'location','best'); grid on
end
else
if (cxrs_profiles.param.k_plot~=0), clf; tit=sprintf('No CXRS %s for TCV shot:%d sys.No.:[%s]',names_exp{iexp},shot,num2str(sys)); title(tit); text(0.5,0.5,tit,'HorizontalAlignment','center'); end
end
end
end
cxrs_profiles.proffit.shot=cxrs_profiles.shot;
cxrs_profiles.proffit.comment=sprintf('CXRS proffit data, function:%s, executed:%s',mfilename,datestr(now));
for it=1:length(cxrs_profiles.Ti)
D=cxrs_profiles.Ti{it};
cxrs_profiles.proffit.time(1,it) = mean(D.t_lim);
cxrs_profiles.proffit.dtime(1,it) = (D.t_lim(2)-D.t_lim(1))/2.;
if ~isempty(D.y_prof), rho=D.x_prof; else rho=cxrs_profiles.param.prof.Ti.xout'; end
if isempty(rho); rho=NaN(1,101); end
if isempty(D.y_prof), V=rho*NaN; D.dy_prof=[]; elseif (length(find(isnan(D.y_prof)))>0), V=rho*NaN; else, V=D.y_prof'; end
if isempty(D.dy_prof), dV=rho*NaN; elseif (length(find(isnan(D.dy_prof)))>0), dV=rho*NaN; else, dV=D.dy_prof'; end
V(find(V<0))=0;
cxrs_profiles.proffit.Ti(:,it) =V'; cxrs_profiles.proffit.dTi(:,it) =dV'; cxrs_profiles.proffit.Ti_rho(:,it) = rho';
cxrs_profiles.proffit.rho(:,it) = rho';
if isfield(cxrs_profiles,'vTor')
D=cxrs_profiles.vTor{it};
if ~isempty(D.y_prof), rho=D.x_prof; else, rho=cxrs_profiles.proffit.rho(:,it); end
if isempty(D.y_prof), V=rho*NaN; D.dy_prof=[]; elseif (length(find(isnan(D.y_prof)))>0), V=rho*NaN; else, V=D.y_prof'; end
if isempty(D.dy_prof), dV=rho*NaN; elseif (length(find(isnan(D.dy_prof)))>0), dV=rho*NaN; else, dV=D.dy_prof'; end
cxrs_profiles.proffit.vTor(:,it) =V'; cxrs_profiles.proffit.dvTor(:,it) =dV'; cxrs_profiles.proffit.vTor_rho(:,it) = rho';
end
if isfield(cxrs_profiles,'vPol')
D=cxrs_profiles.vPol{it};
if ~isempty(D.y_prof), rho=D.x_prof; else, rho=cxrs_profiles.proffit.rho(:,it); end
if isempty(D.y_prof), V=rho*NaN; D.dy_prof=[]; elseif (length(find(isnan(D.y_prof)))>0), V=rho*NaN; else, V=D.y_prof'; end
if isempty(D.dy_prof), dV=rho*NaN; elseif (length(find(isnan(D.dy_prof)))>0), dV=rho*NaN; else, dV=D.dy_prof'; end
cxrs_profiles.proffit.vPol(:,it) =V'; cxrs_profiles.proffit.dvPol(:,it) =dV'; cxrs_profiles.proffit.vPol_rho(:,it) = rho';
end
if isfield(cxrs_profiles,'nC')
D=cxrs_profiles.nC{it};
if ~isempty(D.y_prof), rho=D.x_prof; else, rho=cxrs_profiles.proffit.rho(:,it); end
if isempty(D.y_prof), V=rho*NaN; D.dy_prof=[]; elseif (length(find(isnan(D.y_prof)))>0), V=rho*NaN; else, V=D.y_prof'; end
if isempty(D.dy_prof), dV=rho*NaN; elseif (length(find(isnan(D.dy_prof)))>0), dV=rho*NaN; else, dV=D.dy_prof'; end
V(find(V<0))=0;
cxrs_profiles.proffit.nC(:,it) =V'; cxrs_profiles.proffit.dnC(:,it) =dV'; cxrs_profiles.proffit.nC_rho(:,it) = rho';
end
if isfield(cxrs_profiles,'Zeff')
D=cxrs_profiles.Zeff{it};
if ~isempty(D.y_prof), rho=D.x_prof; else, rho=cxrs_profiles.proffit.rho(:,it); end
if isempty(D.y_prof), V=rho*NaN; D.dy_prof=[]; elseif (length(find(isnan(D.y_prof)))>0), V=rho*NaN; else, V=D.y_prof'; end
if isempty(D.dy_prof), dV=rho*NaN; elseif (length(find(isnan(D.dy_prof)))>0), dV=rho*NaN; else, dV=D.dy_prof'; end
V(find(V<1))=1;
cxrs_profiles.proffit.Zeff(:,it) =V'; cxrs_profiles.proffit.dZeff(:,it) =dV'; cxrs_profiles.proffit.Zeff_rho(:,it) = rho';
end
end
if (length(find(~isnan(cxrs_profiles.proffit.Ti)))==0), msg=sprintf('%s - Proffit not possible for TCV shot:%d',s,cxrs_profiles.shot); disp(msg); cxrs_profiles.OK=-101; return; end
return
This diff is collapsed.
function [colos,lnstyle,typemk]=CXRS_plot_definition
% [colos,lnstyle,typemk]=CXRS_plot_definition
% define colors, linestyles and markers
% taken from OS
col_1 = [1. 0. 0. ]; % red
col_2 = [0. 0.4 0. ]; % dark green
col_3 = [0 0 1 ]; % blue
col_4 = [0.7 0.4 0.9 ]; % purple
col_5 = [0. 1. 0.9 ]; % cyan
col_6 = [1 0.85 0.3 ]; % yellow
col_7 = [0. 1. 0. ]; % light green
col_8 = [1.0 0.1 0.7 ]; % reddish magenta
col_9= [1. 0.7 0 ];
col_10 = [0 0.52 0.93 ];
col_11= [0. 0. 0. ]; % black
col_12= [0.075 0.933 0.676];
col_13 = [0.8 0.1 0.95 ];
% using uisetcolor
typemk={'o', 'p', 'd', 's', '^', 'v', '<', '>', 'h', '*', 'o', 'p', 'd', 's', '^', 'v', '<', '>', 'h', '*', 'o', 'p', 'd', 's', '^', 'v', '<', '>', 'h', '*', 'o', 'p', 'd', 's', '^', 'v', '<', '>', 'h', '*', 'o', 'p', 'd', 's', '^', 'v', '<', '>', 'h', '*', 'o', 'p', 'd', 's', '^', 'v', '<', '>', 'h', '*', 'o', 'p', 'd', 's', '^', 'v', '<', '>', 'h', '*', 'o', 'p', 'd', 's', '^', 'v', '<', '>', 'h', '*', 'o', 'p', 'd', 's', '^', 'v', '<', '>', 'h', '*', 'o', 'p', 'd', 's', '^', 'v', '<', '>', 'h', '*', 'o', 'p', 'd', 's', '^', 'v', '<', '>', 'h', '*', 'o', 'p', 'd', 's', '^', 'v', '<', '>', 'h', '*', 'o', 'p', 'd', 's', '^', 'v', '<', '>', 'h', '*', 'o', 'p', 'd', 's', '^', 'v', '<', '>', 'h','*'};
typemk={'o', 's', '^', 'v', '<', '>', 'p', 'd', 'h', '*', 'o', 's', '^', 'v', '<', '>', 'p', 'd', 'h', '*', 'o', 's', '^', 'v', '<', '>', 'p', 'd', 'h', '*', 'o', 's', '^', 'v', '<', '>', 'p', 'd', 'h', '*', 'o', 's', '^', 'v', '<', '>', 'p', 'd', 'h', '*', 'o', 's', '^', 'v', '<', '>', 'p', 'd', 'h', '*', 'o', 's', '^', 'v', '<', '>', 'p', 'd', 'h', '*', 'o', 's', '^', 'v', '<', '>', 'p', 'd', 'h', '*', 'o', 's', '^', 'v', '<', '>', 'p', 'd', 'h', '*', 'o', 's', '^', 'v', '<', '>', 'p', 'd', 'h', '*', 'o', 's', '^', 'v', '<', '>', 'p', 'd', 'h', '*', 'o', 's', '^', 'v', '<', '>', 'p', 'd', 'h', '*', 'o', 's', '^', 'v', '<', '>', 'p', 'd', 'h', '*', 'o', 's', '^', 'v', '<', '>', 'p', 'd', 'h', '*'};
lnstyle={'-', '--', '-.', ':', '-', '--', '-.', ':', '-', '--', '-.', ':', '-', '--', '-.', ':', '-', '--', '-.', ':', '-', '--', '-.', ':', '-', '--', '-.', ':', '-', '--', '-.', ':', '-', '--', '-.', ':', '-', '--', '-.', ':', '-', '--', '-.', ':', '-', '--', '-.', ':', '-', '--', '-.', ':', '-', '--', '-.', ':', '-', '--', '-.', ':', '-', '--', '-.', ':','-', '--', '-.', ':', '-', '--', '-.', ':', '-', '--', '-.', ':', '-', '--', '-.', ':', '-', '--', '-.', ':', '-', '--', '-.', ':', '-', '--', '-.', ':', '-', '--', '-.', ':', '-', '--', '-.', ':', '-', '--', '-.', ':', '-', '--', '-.', ':', '-', '--', '-.', ':', '-', '--', '-.', ':', '-', '--', '-.', ':', '-', '--', '-.', ':', '-', '--', '-.', ':'};
colos=[col_1; col_2; col_3; col_4; col_5; col_6; col_7; col_8; col_9; col_10; col_11; col_12; col_13; col_1; col_2; col_3; col_4; col_5; col_6; col_7; col_8; col_9; col_10; col_11; col_12; col_13; col_1; col_2; col_3; col_4; col_5; col_6; col_7; col_8; col_9; col_10; col_11; col_12; col_13; col_1; col_2; col_3; col_4; col_5; col_6; col_7; col_8; col_9; col_10; col_11; col_12; col_13;col_1; col_2; col_3; col_4; col_5; col_6; col_7; col_8; col_9; col_10; col_11; col_12; col_13; col_1; col_2; col_3; col_4; col_5; col_6; col_7; col_8; col_9; col_10; col_11; col_12; col_13; col_1; col_2; col_3; col_4; col_5; col_6; col_7; col_8; col_9; col_10; col_11; col_12; col_13; col_1; col_2; col_3; col_4; col_5; col_6; col_7; col_8; col_9; col_10; col_11; col_12; col_13; col_1; col_2; col_3; col_4; col_5; col_6; col_7; col_8; col_9; col_10; col_11; col_12; col_13; col_1; col_2; col_3; col_4; col_5; col_6; col_7; col_8; col_9; col_10; col_11; col_12; col_13;col_1; col_2; col_3; col_4; col_5; col_6; col_7; col_8; col_9; col_10; col_11; col_12; col_13; col_1; col_2; col_3; col_4; col_5; col_6; col_7; col_8; col_9; col_10; col_11; col_12; col_13];
typemk = [typemk typemk typemk];
lnstyle = [lnstyle lnstyle lnstyle ];
colos = [colos; colos; colos ];
return
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