From c5146a949223c7686cf495b1c477b5075badc709 Mon Sep 17 00:00:00 2001 From: Olivier Sauter <Olivier.Sauter@epfl.ch> Date: Fri, 17 Feb 2023 16:57:12 +0100 Subject: [PATCH] consistent port nb in gdat_d3d example --- matlab/D3D/gdat_d3d.m | 67 +++++++++++++++++++++---------------------- 1 file changed, 33 insertions(+), 34 deletions(-) diff --git a/matlab/D3D/gdat_d3d.m b/matlab/D3D/gdat_d3d.m index be93b419..a4fe1657 100644 --- a/matlab/D3D/gdat_d3d.m +++ b/matlab/D3D/gdat_d3d.m @@ -2,7 +2,7 @@ function [gdat_data,gdat_params,error_status,varargout] = gdat_d3d(shot,data_req % % function [gdat_data,gdat_params,error_status,varargout] = gdat(shot,data_request,varargin) % -% Aim: get data from a given machine using full path or keywords. +% Aim: get data from a given machine using full path or keywords. % data_request are and should be case independent (transformed in lower case in the function and outputs) % % If no inputs are provided, return the list of available pre-defined data_request in gdat_data and default parameters gdat_params @@ -41,7 +41,7 @@ function [gdat_data,gdat_params,error_status,varargout] = gdat_d3d(shot,data_req % % Examples: % (should add working examples for various machines (provides working shot numbers for each machine...)) -% +% % [a1,a2]=gdat; % a2.data_request = 'Ip'; % a3=gdat(32827,a2); % gives input parameters as a structure, allows to call the same for many shots @@ -52,7 +52,7 @@ function [gdat_data,gdat_params,error_status,varargout] = gdat_d3d(shot,data_req % From remote: % ssh -p 2039 -C -l sautero -L 8002:atlas.gat.com:8000 cybele.gat.com % And in another session in matlab: -% mdsconnect('localhost:8001'); mdsvalue('1+3') % to test connection to server +% mdsconnect('localhost:8002'); mdsvalue('1+3') % to test connection to server % sh=mdsopen('efit01',193400); (instead of no connect and sh=mdsopen('atlas.gat.com::efit01',193400); from iris % @@ -214,7 +214,7 @@ else ij=[]; end -if ~isempty(ij); +if ~isempty(ij); gdat_data.gdat_request = data_request_names_all{ij}; if isfield(data_request_names.all.(data_request_names_all{ij}),'description') && ~isempty(data_request_names.all.(data_request_names_all{ij}).description) % copy description of keyword @@ -332,7 +332,7 @@ elseif strcmp(mapping_for_d3d.method,'expression') ijdim=find(strcmp(tmp_fieldnames,'dim')==1); if ~isempty(ijdim) nbdims = length(gdat_data.dim); - if mapping_for_d3d.timedim==-1; + if mapping_for_d3d.timedim==-1; mapping_for_d3d.timedim = nbdims; if (size(gdat_data.data,nbdims)==1 && nbdims>1); mapping_for_d3d.timedim = nbdims-1; end end @@ -557,7 +557,7 @@ elseif strcmp(mapping_for_d3d.method,'switchcase') end end end - + %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% case {'ece', 'ece_rho'} nth_points = 13; @@ -633,7 +633,7 @@ elseif strcmp(mapping_for_d3d.method,'switchcase') % $$$ gdat_data.rhos.rhovolnorm = rhovolnorm_out; % $$$ gdat_data.rhos.t = gdat_data.rz.t; % $$$ end - + %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% case {'eqdsk'} % @@ -682,7 +682,7 @@ elseif strcmp(mapping_for_d3d.method,'switchcase') else eqdsk_cocosout = eqdskD3D; end - % for several times, use array of structure for eqdsks, + % for several times, use array of structure for eqdsks, % cannot use it for psi(R,Z) in .data and .x since R, Z might be different at different times, % so project psi(R,Z) on Rmesh, Zmesh of 1st time if length(time_eqdsks) > 1 @@ -712,7 +712,7 @@ elseif strcmp(mapping_for_d3d.method,'switchcase') gdat_data.dimunits = {'m','m','s'}; gdat_data.request_description = ['data=psi, x=(R,Z), eqdsk contains eqdsk structure with which ' ... 'plot_eqdsk, write_eqdsk, read_eqdsk can be used']; - + %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% case {'equil'} if ~isfield(gdat_data.gdat_params,'equil') || isempty(gdat_data.gdat_params.equil) || ~ischar(gdat_data.gdat_params.equil) @@ -739,11 +739,11 @@ elseif strcmp(mapping_for_d3d.method,'switchcase') gdat_data.psi_lcfs(it)= equil_all_t.gdata(it).ssibry; gdat_data.rhopolnorm(:,it) = sqrt(abs((gdat_data.psi(:,it)-gdat_data.psi_axis(it)) ./(gdat_data.psi_lcfs(it)-gdat_data.psi_axis(it)))); gdat_data.rhopolnorm(end,it) = 1.; - gdat_data.vol(:,it)=gdat_data.rhovolnorm(:,it).^2 .* eq.results.aeqdsk.volume(it); + gdat_data.vol(:,it)=gdat_data.rhovolnorm(:,it).^2 .* eq.results.aeqdsk.volume(it); gdat_data.Rmesh(:,it) = eq.results.geqdsk.r; gdat_data.Zmesh(:,it) = eq.results.geqdsk.z; gdat_data.psi2D(:,:,it) = equil_all_t.gdata(it).psirz; - gdat_data.pressure(:,it) = equil_all_t.gdata(it).pres; + gdat_data.pressure(:,it) = equil_all_t.gdata(it).pres; gdat_data.dpressuredpsi(:,it) = equil_all_t.gdata(it).pprime; % 2nd index are dV/dpsi gdat_data.ffprime(:,it) = equil_all_t.gdata(it).ffprim; gdat_data.rwall(:,it) = equil_all_t.gdata(it).xlim; @@ -778,12 +778,12 @@ elseif strcmp(mapping_for_d3d.method,'switchcase') gdat_data.units='q'; % not applicable gdat_data.data_fullpath = ... ['q(:,time) in .data, all from [equil_all_t,neq,eq,ier]=read_mds_eq_func(shot,gdat_data.gdat_params.equil,''d3d'');']; - gdat_data.cocos = 2; + gdat_data.cocos = 2; gdat_data.dim{1} = gdat_data.x; gdat_data.dim{2} = gdat_data.t; gdat_data.dimunits{1} = 'rhopolnorm'; gdat_data.dimunits{2} = 'time [s]'; - + %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% case {'ne','te'} exp_name_eff = gdat_data.gdat_params.exp_name; @@ -857,7 +857,7 @@ elseif strcmp(mapping_for_d3d.method,'switchcase') gdat_data.(lower(node_child_nameeff_e)).z = []; end gdat_data.x=gdat_data.dim{1}; - + %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% case {'ne_rho', 'te_rho', 'nete_rho'} if ~isfield(gdat_data.gdat_params,'fit') || isempty(gdat_data.gdat_params.fit) || ~isnumeric(gdat_data.gdat_params.fit) @@ -874,7 +874,7 @@ elseif strcmp(mapping_for_d3d.method,'switchcase') return end % add rho coordinates - params_eff.data_request='equil'; + params_eff.data_request='equil'; [equil,params_equil,error_status]=gdat_d3d(shot,params_eff); if error_status>0 if gdat_params.nverbose>=3; disp(['problems with ' params_eff.data_request]); end @@ -1091,12 +1091,12 @@ elseif strcmp(mapping_for_d3d.method,'switchcase') end end end - - + + %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% case {'pgyro'} % LOAD MULTI CHANNEL DATA ECS - % powers, frequencies, etc + % powers, frequencies, etc params_eff = gdat_data.gdat_params; params_eff.data_request={'rf' '\echpwrc'}; % $$$ gyro_names={'leia','luke','scarecrow','tinman','chewbacca','nasa'}; @@ -1187,7 +1187,7 @@ elseif strcmp(mapping_for_d3d.method,'switchcase') for i=1:length(labels) if ~isempty(labels{i}) icount=icount+1; - if icount==1 & ~iscell(gdat_data.label) + if icount==1 & ~iscell(gdat_data.label) gdat_data = rmfield(gdat_data,'label'); end gdat_data.label{icount} = labels{i}; @@ -1408,12 +1408,12 @@ elseif strcmp(mapping_for_d3d.method,'switchcase') qfit = zeros(size(gdat_data.rhopolnorm(:,it))); end gdat_data.qvalue(:,it) = qfit; - end + end % get rhotor values phi_it = phi_tree.value(it,Lpf1:-1:1)'; gdat_data.rhotornorm(:,it) = sqrt(abs(phi_it ./ phi_it(end))); % get rhovol values - vol_it=Vol.value(it,2*Lpf1-1:-2:1)'; + vol_it=Vol.value(it,2*Lpf1-1:-2:1)'; gdat_data.rhovolnorm(:,it) = sqrt(abs(vol_it ./ vol_it(end))); % Qpsi and similar data is on (time,radius) with radius being: LCFS..Lpf_points dummy LCFS..SOL part % change it to (radial,time) and use only Lpf+1 points up to LCFS @@ -1521,7 +1521,7 @@ elseif strcmp(mapping_for_d3d.method,'switchcase') max_points = 0; for i=channels aall{i} = gdat_d3d(shot,['\cerqrott' num2str(i)]); - if isnumeric(aall{i}.data) + if isnumeric(aall{i}.data) gdat_data.channels_ok(i) = 1; if numel(aall{i}.data) > max_points max_points = numel(aall{i}.data); @@ -1550,7 +1550,7 @@ elseif strcmp(mapping_for_d3d.method,'switchcase') %if any(strcmp(fieldnames(a),'units')); gdat_data.units=a.units; end gdat_data.data_fullpath = [diag_name '\tcerqrot' num2str(channels(1)) '...' num2str(channels(end))]; gdat_data.allchannels = aall; - + %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% case {'rhotor', 'rhotor_edge', 'rhotor_norm', 'rhovol', 'volume_rho'} if strcmp(upper(gdat_data.gdat_params.equil),'FPG') @@ -1589,7 +1589,7 @@ elseif strcmp(mapping_for_d3d.method,'switchcase') psi_axis(it)= psi_it(1); psi_lcfs(it)= psi_it(end); gdat_data.x(:,it) = sqrt(abs((psi_it-psi_axis(it)) ./(psi_lcfs(it)-psi_axis(it)))); - gdat_data.vol(:,it)=Vol.value(it,2*Lpf1-1:-2:1)'; + gdat_data.vol(:,it)=Vol.value(it,2*Lpf1-1:-2:1)'; % gdat_data.dvoldpsi(:,it)=Vol.value(it,2*Lpf1:-2:2)'; % 2nd index are dV/dpsi gdat_data.rhovolnorm(:,it) = sqrt(abs(gdat_data.vol(:,it) ./ gdat_data.vol(end,it))); end @@ -1660,7 +1660,7 @@ elseif strcmp(mapping_for_d3d.method,'switchcase') exp_name_eff = 'D3D'; icount = 0; nnth = 1; - if isnumeric(gdat_data.gdat_params.freq) && gdat_data.gdat_params.freq>1; + if isnumeric(gdat_data.gdat_params.freq) && gdat_data.gdat_params.freq>1; nnth = floor(gdat_data.gdat_params.freq+0.5); gdat_data.gdat_params.freq = nnth; end @@ -1689,11 +1689,11 @@ elseif strcmp(mapping_for_d3d.method,'switchcase') if (gdat_params.nverbose>=1); disp(['problem with ' gdat_data.gdat_params.source '...' num2str(ichord)]); end end else - % add fields not yet defined in case all cases have empty data + % add fields not yet defined in case all cases have empty data end end gdat_data.chords = gdat_data.gdat_params.camera; - + %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% case {'bolo', 'bolom'} % sxr from sx90rm1s by default or else if 'source' is provided @@ -1714,7 +1714,7 @@ elseif strcmp(mapping_for_d3d.method,'switchcase') exp_name_eff = 'D3D'; icount = 0; nnth = 1; - if isnumeric(gdat_data.gdat_params.freq) && gdat_data.gdat_params.freq>1; + if isnumeric(gdat_data.gdat_params.freq) && gdat_data.gdat_params.freq>1; nnth = floor(gdat_data.gdat_params.freq+0.5); gdat_data.gdat_params.freq = nnth; end @@ -1744,11 +1744,11 @@ elseif strcmp(mapping_for_d3d.method,'switchcase') if (gdat_params.nverbose>=1); disp(['problem with ' gdat_data.gdat_params.source '...' num2str(ichord)]); end end else - % add fields not yet defined in case all cases have empty data + % add fields not yet defined in case all cases have empty data end end gdat_data.chords = gdat_data.gdat_params.camera; - + %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% case {'transp'} % most of the times the exp for the shotfile should be provided @@ -1827,17 +1827,17 @@ elseif strcmp(mapping_for_d3d.method,'switchcase') end end else - % add fields not yet defined in case all cases have empty data + % add fields not yet defined in case all cases have empty data end end gdat_data.chords = gdat_data.gdat_params.camera; - + otherwise if (gdat_params.nverbose>=1); warning(['switchcase= ' data_request_eff ' not known in gdat_d3d']); end error_status=901; return end - + else if (gdat_params.nverbose>=1); warning(['D3D method=' mapping_for_D3D.method ' not known yet, contact Olivier.Sauter@epfl.ch']); end error_status=602; @@ -1854,4 +1854,3 @@ return %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % functions for portions called several times - -- GitLab