Commit c52416df authored by Olivier Sauter's avatar Olivier Sauter
Browse files

fix gdat_plot, mex for jet, and other small

parent 9569692a
......@@ -574,7 +574,15 @@ elseif strcmp(mapping_for_jet.method,'switchcase')
end
else
% assume same time for all
% mds_dir = '/home/amerle/public/mds-ssh';
mds_dir = '/home/amerle/public/mds-ssh3';
if exist(mds_dir,'dir') && ~strcmp(which('mdsipmex'),fullfile(mds_dir,'mdsipmex.mexa64'))
addpath(mds_dir);
end
mdsconnect(['ssh://' gdat_params.jet_user '@mdsplus.jetdata.eu']);
if exist(mds_dir,'dir') && ~strcmp(which('mdsipmex'),fullfile(mds_dir,'mdsipmex.mexa64'))
rmpath(mds_dir);
end
rda_data_request = ['ppf/kk3/' num2str(i,'te%.2d')];
bb = mdsvalue(['_bb=jet("' rda_data_request '",' num2str(shot) ')']);
if ~isempty(bb) && numel(bb)==size(aa.data,2)
......
......@@ -34,7 +34,8 @@ end
if usemdsplus
% use mdsplus
mds_dir = '/home/amerle/codes/mds-ssh';
% mds_dir = '/home/amerle/public/mds-ssh';
mds_dir = '/home/amerle/public/mds-ssh3';
if exist(mds_dir,'dir') && ~strcmp(which('mdsipmex'),fullfile(mds_dir,'mdsipmex.mexa64'))
addpath(mds_dir);
end
......@@ -170,6 +171,9 @@ if usemdsplus
if ~unix('test -d /home/duval/mdsplus')
rmpath('/home/duval/mdsplus')
end
if exist(mds_dir,'dir') && ~strcmp(which('mdsipmex'),fullfile(mds_dir,'mdsipmex.mexa64'))
rmpath(mds_dir);
end
else
% use RDA
......
......@@ -348,11 +348,13 @@ if do_mdsopen_mdsclose
end
mapping_for_tcv.expression = mapping_for_tcv.expression(7:end);
elseif shot==-1 || liuqe_version_eff==-1
ishot = mdsopen('pcs', shot);
[ishot,shot_stat] = mdsopen('pcs', shot);
else
ishot = mdsopen(shot); % if ishot equal to shot, then mdsclose at the end
[ishot,shot_stat] = mdsopen(shot); % if ishot equal to shot, then mdsclose at the end
end
if isempty(ishot) || ishot~=shot
if mod(shot_stat,2)==0
ishot
warning('error opening shot');
if gdat_params.nverbose>=1; warning(['cannot open shot= ' num2str(shot)]); end
return
end
......@@ -2501,7 +2503,7 @@ elseif strcmp(mapping_for_tcv.method,'switchcase')
if isempty(model_data.dim)
fprintf('And it was NOT requested \n');
else
fprintf('And it was requested. Check if plasma was a blip or if NB1 did not work \n');
fprintf('And it was requested. Check if plasma was a blip or if NB1 did not work \n');
end
end
end
......@@ -2532,7 +2534,7 @@ elseif strcmp(mapping_for_tcv.method,'switchcase')
end
%
if any(strmatch('nbi2',gdat_data.gdat_params.source))
% NB2
% NB2
nodenameeff = '\results::NB2:POWR_TCV';
nb2_data_tdi = tdi(nodenameeff);
if ~isempty(nb2_data_tdi.dim) && ~ischar(nb2_data_tdi.data) && ~isempty(nb2_data_tdi.dim)
......@@ -2565,14 +2567,14 @@ elseif strcmp(mapping_for_tcv.method,'switchcase')
if isempty(model_data.dim)
fprintf('And it was NOT requested \n');
else
fprintf('And it was requested. Check if plasma was a blip or if NB1 did not work \n');
fprintf('And it was requested. Check if plasma was a blip or if NB1 did not work \n');
end
end
end
end
end
if any(strmatch('dnbi',gdat_data.gdat_params.source))
% NB2
% NB2
nodenameeff = '\RESULTS::DNBI:POWR_TCV';
nb2_data_tdi = tdi(nodenameeff);
if ~isempty(nb2_data_tdi.data) && ~ischar(nb2_data_tdi.data) && ~isempty(nb2_data_tdi.dim)
......
......@@ -107,6 +107,7 @@ global_quantities_desc.volume = params_eff.data_request;
params_eff.data_request = 'w_mhd';
global_quantities.w_mhd = gdat(params_equilibrium.shot,params_eff);
global_quantities_desc.w_mhd = params_eff.data_request;
ids_equilibrium_description.global_quantities = global_quantities_desc;
global_quantities_fieldnames = fieldnames(global_quantities);
special_fields = {'magnetic_axis', 'psi_axis', 'q_min'}; % fields needing non-automatic treatments
......@@ -214,9 +215,10 @@ for it=1:ntime
ids_equilibrium.time_slice{it}.boundary.x_point = {};
end
end
ids_equilibrium_description.boundary = boundary_desc;
ids_equilibrium_description.boundary_temp = temp_desc;
%% constraints
% TODO: Add description
% Measured values
liuqe_time = ids_equilibrium.time; % Not necessarily magnetics time so far
......@@ -224,9 +226,15 @@ mag_time = mdsvalue('\magnetics::bpol_003:dim0');
itime = iround_os(mag_time, liuqe_time);
mag_time_req = mdscvt(mag_time(itime),'f');
bpol = mdsvalue('\magnetics::bpol_003[$1,*]',mag_time_req);
nbpol = size(bpol,2);
constraints_desc.bpol_probe.measured = sprintf('from %s i=1:%d','\magnetics::bpol_003[i,*]',nbpol);
flux = mdsvalue('tcv_idealloop("flux")[$1,*]',mag_time_req);
diam = mdsvalue('\results::dmlcor[$1]',mag_time_req);
nflux = size(flux,2);
constraints_desc.flux_loop.measured = sprintf('from %s i=1:%d','tcv_idealloop("flux")[i,*]',nflux);
ip = mdsvalue('\magnetics::iplasma:trapeze[$1]',mag_time_req);
constraints_desc.ip.measured = sprintf('from %s','\magnetics::iplasma:trapeze');
diam = mdsvalue('\results::dmlcor[$1]',mag_time_req);
constraints_desc.diamagnetic_flux.measured = sprintf('from %s','\results::dmlcor');
% Coil currents since dim of constraints pf_current is IDS:pf_active/coil
dim_pol = {'OH_001','OH_002','OH_002','OH_002','OH_002','OH_002','OH_002',...
'E_001','E_002','E_003','E_004','E_005','E_006','E_007','E_008',...
......@@ -236,26 +244,38 @@ ipol = mdsvalue('\magnetics::ipol[$1,$2]',mag_time_req,dim_pol);
ipol(:,27:29) = -ipol(:,27:29); % Bottom G-coils
dim_pol(30:32) = {'TOR_001'};
ipol(:,30:32) = 0; % TOR_001 is not used in LIUQE
nipol = size(ipol,2);
constraints_desc.pf_current.measured = sprintf('from %s, ii from %s','\magnetics::ipol[t,ii]',cell2str(dim_pol,15));
% Reconstructed values
ipol_liuqe_order = [18,19*ones(1,6),1:16,17*ones(1,6)]; % LIUQE order is E F G OH
bpol_liuqe = mdsvalue('tcv_eq("b_probe","liuqe.m")');
constraints_desc.bpol_probe.reconstructed = sprintf('%s','tcv_eq("b_probe","liuqe.m")');
flux_liuqe = mdsvalue('tcv_eq("psi_loop","liuqe.m")');
diam_liuqe = mdsvalue('tcv_eq("tor_flux_dml","liuqe.m")');
constraints_desc.flux_liuqe.reconstructed = sprintf('%s','tcv_eq("psi_loop","liuqe.m")');
ip_liuqe = mdsvalue('tcv_eq("i_pl","liuqe.m")');
constraints_desc.ip.reconstructed = sprintf('%s','tcv_eq("i_pl","liuqe.m")');
diam_liuqe = mdsvalue('tcv_eq("tor_flux_dml","liuqe.m")');
constraints_desc.diamagnetic_flux.reconstructed = sprintf('%s','tcv_eq("tor_flux_dml","liuqe.m")');
ipol_liuqe = mdsvalue('tcv_eq("i_pol","liuqe.m")');
ipol_liuqe = ipol_liuqe(ipol_liuqe_order,:);
ipol_liuqe(27:29,:) = -ipol_liuqe(27:29,:); % Bottom G-coils
ipol_liuqe(30:32,:) = 0; % ... TOR
constraints_desc.ipol_liuqe.reconstructed = sprintf('%s','tcv_eq("i_pol","liuqe.m")');
% Weights (using old parameters tree for now)
bpol_err = mdsvalue('\results::parameters:berr')./mdsvalue('\results::parameters:vvv[0:37]');
constraints_desc.bpol_probe.weight = sprintf('(%s/%s)^2','\results::parameters:vvv[0:37]','\results::parameters:berr');
flux_err = mdsvalue('\results::parameters:ferr')./mdsvalue('\results::parameters:www[0:37]')*2*pi;
diam_err = 0.13e-3./mdsvalue('\results::parameters:idml');
constraints_desc.flux_loop.weight = sprintf('(%s/%s)^2','\results::parameters:www[0:37]','\results::parameters:ferr');
ip_err = mdsvalue('\results::parameters:plcerr')*1e3;
constraints_desc.ip.weight = sprintf('(1e-3/%s)^2','\results::parameters:plcerr');
diam_err = 0.13e-3./mdsvalue('\results::parameters:idml');
constraints_desc.diamagnetic_flux.weight = sprintf('(%s/0.13e-3)^2','\results::parameters:idml');
ipol_err = mdsvalue('\results::parameters:cerr')./mdsvalue('\results::parameters:uuu[0:18]')*1e3;
ipol_err = ipol_err(ipol_liuqe_order);
ipol_err(30:32) = NaN;
constraints_desc.pf_current.weight = sprintf('(1e-3*%s/%s)^2','\results::parameters:uuu[0:18]','\results::parameters:cerr');
if ntime > 0
constraints_orig = ids_equilibrium.time_slice{1}.constraints;
......@@ -263,15 +283,16 @@ if ntime > 0
ununsed_constraints = {'faraday_angle','mse_polarisation_angle','iron_core_segment',...
'n_e','n_e_line','pressure','q','x_point'};
for name = ununsed_constraints, constraints_orig.(name{1})={}; end
constraints_desc.ununsed_constraints = ununsed_constraints;
end
keyboard
for it = 1:ntime
constraints = constraints_orig;
% bpol_probe
nbpol = size(bpol,2);
bpol_probe(1:nbpol) = constraints.bpol_probe(1);
for ib = 1:nbpol
bpol_probe{ib}.measured = bpol(it,ib);
bpol_probe{ib}.source = sprintf('IDS:magnetics/bpol_probe[%02d]/field',ib);
bpol_probe{ib}.source = sprintf('IDS:equilibrium/../constraints/bpol_probe[%02d]',ib);
bpol_probe{ib}.time_measurement = mag_time(itime(it));
bpol_probe{ib}.exact = 0;
bpol_probe{ib}.weight = 1/(bpol_err(ib)).^2;
......@@ -279,11 +300,10 @@ for it = 1:ntime
end
constraints.bpol_probe = bpol_probe;
% flux_loop
nflux = size(flux,2);
flux_loop(1:nflux) = constraints.flux_loop(1);
for il = 1:nflux
flux_loop{il}.measured = flux(it,il);
flux_loop{il}.source = sprintf('IDS:magnetics/flux_loop[%02d]/flux',il);
flux_loop{il}.source = sprintf('IDS:equilibrium/../constraints/flux_loop[%02d]',il);
flux_loop{il}.time_measurement = mag_time(itime(it));
flux_loop{il}.exact = 0;
flux_loop{il}.weight = 1/(flux_err(il)).^2;
......@@ -292,24 +312,23 @@ for it = 1:ntime
constraints.flux_loop = flux_loop;
% ip
constraints.ip.measured = ip(it);
constraints.ip.source = 'IDS:magnetics/method[1]/ip';
constraints.ip.source = 'IDS:equilibrium/../constraints/ip';
constraints.ip.time_measurement = mag_time(itime(it));
constraints.ip.exact = 0;
constraints.ip.weight = 1/(ip_err).^2;
constraints.ip.reconstructed = ip_liuqe(it);
% diamagnetic_flux
constraints.diamagnetic_flux.measured = diam(it);
constraints.diamagnetic_flux.source = 'IDS:magnetics/method[1]/diamagnetic_flux';
constraints.diamagnetic_flux.source = 'IDS:equilibrium/../constraints/diamagnetic_flux';
constraints.diamagnetic_flux.time_measurement = mag_time(itime(it));
constraints.diamagnetic_flux.exact = 0;
constraints.diamagnetic_flux.weight = 1/(diam_err).^2;
constraints.diamagnetic_flux.reconstructed = diam_liuqe(it);
% pf_current
nipol = size(ipol,2);
pf_current(1:nipol) = constraints.pf_current(1);
for ic = 1:nipol
pf_current{ic}.measured = ipol(it,ic);
pf_current{ic}.source = sprintf('IDS:pf_active/coil[%02d]/current',ic);
pf_current{ic}.source = sprintf('IDS:equilibrium/../constraints/pf_current[%02d]',ic);
pf_current{ic}.time_measurement = mag_time(itime(it));
if strcmp(dim_pol{ic},'TOR_001')
pf_current{ic}.source = [pf_current{ic}.source,' replaced with 0'];
......@@ -465,6 +484,8 @@ for it=1:ntime
end
end
ids_equilibrium_description.profiles_1d = profiles_1d_desc;
% special cases
for it=1:ntime
ids_equilibrium.time_slice{it}.global_quantities.magnetic_axis.b_field_tor = ids_equilibrium.time_slice{it}.profiles_1d.f(1) ...
......@@ -496,9 +517,13 @@ profiles_2d.grid_type.description = 'Cylindrical R,Z ala eqdsk';
params_eff.data_request = 'psi';
profiles_2d.psi = gdat(params_equilibrium.shot,params_eff); % add psi_bound in a second step in special cases
profiles_2d_desc.psi = [params_eff.data_request ' adding psi_bound in a 2nd step'];
% r = gdat(params_equilibrium.shot,'r','machine',gdat_params.machine); % not to be filled since in grid.dim1
%profiles_2d.r = profiles_2d.psi;
profiles_2d.r.data = repmat(repmat(profiles_2d.psi.dim{1},1,65),1,1,1299);
profiles_2d_desc.r = 'from dim{1} of ''psi'' repeated';
profiles_2d.z.data = repmat(repmat(profiles_2d.psi.dim{2}',28,1),1,1,1299);
profiles_2d_desc.z = 'from dim{2} of ''psi'' repeated';
% theta = gdat(params_equilibrium.shot,'theta','machine',gdat_params.machine);
% z = gdat(params_equilibrium.shot,'z','machine',gdat_params.machine); % not to be filled since in grid.dim2
profiles_2d_fieldnames = fieldnames(profiles_2d);
special_fields = {'grid', 'grid_type'}; % fields needing non-automatic treatments
......@@ -529,6 +554,8 @@ for it=1:ntime
global_quantities.psi_boundary.data(it);
end
ids_equilibrium_description.profiles_2d = profiles_2d_desc;
% make arrays not filled in empty:
ids_equilibrium.grids_ggd = {};
for it=1:numel(ids_equilibrium.time_slice)
......
......@@ -124,7 +124,7 @@ if all(isfield(gdat_data,{'data','t'})) && ~isempty(gdat_data.data) && ~isempty(
zoom on;
end
maxnblines = 1;
if strcmp(gdat_data.gdat_params.data_request,'powers') && length(ab)==length(gdat_data.label)
if any(strcmp(gdat_data.gdat_params.data_request,'powers')) && length(ab)==length(gdat_data.label)
% keep legend from label
else
for i=1:numel(linehandles)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment