diff --git a/matlab/TCV/gdat_tcv.m b/matlab/TCV/gdat_tcv.m index ef503dc46e61947ac144d6e5c21ff0aa4948970c..43a7b34b78067a271255050f71e197dc3ec2a5fa 100644 --- a/matlab/TCV/gdat_tcv.m +++ b/matlab/TCV/gdat_tcv.m @@ -1278,9 +1278,13 @@ elseif strcmp(mapping_for_tcv.method,'switchcase') 'plot_eqdsk, write_eqdsk, read_eqdsk can be used']; %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - case {'gas', 'gas_flux', 'gas_request', 'gas_feedforward','gas_valve'} + case {'gas', 'gas_flux', 'gas_request', 'gas_feedforward','gas_valve', 'gas_fluxes'} params_eff = gdat_data.gdat_params; - params_eff.data_request = '\diagz::flux_gaz:piezo_1:flux'; + if shot <= 82919 + params_eff.data_request = '\diagz::flux_gaz:piezo_1:flux'; + else + params_eff.data_request = '\atlas::top.system.gas.valve_001:flow' + end gasflux = gdat_tcv(gdat_data.shot,params_eff); gdat_data.gas_flux = gasflux; params_eff.data_request = '\hybrid::mat_m_signals:output_019'; @@ -1353,6 +1357,40 @@ elseif strcmp(mapping_for_tcv.method,'switchcase') end end end + case {'gas_fluxes'} + try + if shot > 82186 + for i=1:20 + params_eff.data_request = sprintf('\\draw_refs_gas:ref_0%.2d',i); + try + gasrequest_ref = gdat_tcv(gdat_data.shot,params_eff); + gdat_data_data_refs{i}.data = gasrequest_ref.data; + gdat_data_data_refs{i}.t = gasrequest_ref.t; + gdat_data_data_refs{i}.data_fullpath = gasrequest_ref.data_fullpath; + catch + gdat_data_data_refs{i}.data = []; + gdat_data_data_refs{i}.t = []; + gdat_data_data_refs{i}.data_fullpath = params_eff.data_request; + end + params_eff.data_request = sprintf('\\atlas::top.system.gas.valve_0%.2d:flow',i); + gasrequest = gdat_tcv(gdat_data.shot,params_eff); + gdat_data_data{i} = gasrequest; + if ~isempty(gasrequest.t) && isempty(gdat_data.t) % copy 1st non-empty + gdat_data.units = gasrequest.units; + if isempty(strtrim(gdat_data.units)), gdat_data.units = 'particles/s'; end + gdat_data.t = gasrequest.t; + gdat_data.data_fullpath = gasrequest.data_fullpath; + end + end + gdat_data.data = gdat_data_data; + gdat_data.data_refs = gdat_data_data_refs; + else + if (gdat_params.nverbose>=1) + disp('available only for shot > 82186, but can try gdat(shot,''\atlas::top.system.gas.valve_001:flow'',1)') + end + end + catch + end otherwise error('gas option not defined') end @@ -3321,13 +3359,17 @@ elseif strcmp(mapping_for_tcv.method,'switchcase') if isempty(aaa) error('no path for get_scd_mems') end - - aa = get_scd_mems(shot,gdat_data.gdat_params.source); - if isstruct(aa) - scd_names = fieldnames(aa); - for i=1:length(scd_names) - gdat_data.scd_mems.(scd_names{i}) = aa.(scd_names{i}); + try + aa = get_scd_mems(shot,gdat_data.gdat_params.source); + if isstruct(aa) + scd_names = fieldnames(aa); + for i=1:length(scd_names) + gdat_data.scd_mems.(scd_names{i}) = aa.(scd_names{i}); + end end + gdat_data.data_fullpath = sprintf('used %s with patterns specified in source gdat_params',aaa); + catch + % to make sure close and disconnect even if error, since connects to scd end mdsclose; mdsdisconnect; diff --git a/matlab/TCV/tcv_requests_mapping.m b/matlab/TCV/tcv_requests_mapping.m index e2b0fbdbea5dfe03a7b716950e9fa450c0f0f96f..ce8a01441a5d585848dde445379a870f69c3b106 100644 --- a/matlab/TCV/tcv_requests_mapping.m +++ b/matlab/TCV/tcv_requests_mapping.m @@ -144,7 +144,7 @@ switch lower(data_request) 'gdat_tmp=gdat_tcv([],params_eff);aa_data(1,:)=min(gdat_tmp.data,[],1)-0.624;aa_data(1,[aa_data(1,:)<0]) = 0.;' ... 'aa_data(2,:)=1.1376-max(gdat_tmp.data,[],1);aa_data(2,[aa_data(2,:)<0]) = 0.;gdat_tmp.data=aa_data;gdat_tmp.x=[1:2];gdat_tmp.dim{1}=gdat_tmp.x;' ... 'gdat_tmp.dimunits{1}={''HFS'',''LFS''};gdat_tmp.units=''m'';']; - case {'gas', 'gas_flux', 'gas_request', 'gas_feedforward','gas_valve'} + case {'gas', 'gas_flux', 'gas_request', 'gas_feedforward','gas_valve', 'gas_fluxes'} mapping.timedim = 1; mapping.label = 'gas flux'; mapping.method = 'switchcase'; diff --git a/matlab/TCV_IMAS/tcv_get_ids_ec_launchers.m b/matlab/TCV_IMAS/tcv_get_ids_ec_launchers.m index a132f2a36158e03bcf83d202fdbd5c31f773ef66..e6f3b040e8ce238e03ed89f3baaeb51aebaa838a 100644 --- a/matlab/TCV_IMAS/tcv_get_ids_ec_launchers.m +++ b/matlab/TCV_IMAS/tcv_get_ids_ec_launchers.m @@ -33,7 +33,7 @@ end nb_launchers = size(pow.ec.data,2)-1; % at this stage keep same numbering as standard TCV launchers before mid-2019 -ids_ec_launchers.launcher(1:nb_launchers) = ids_ec_launchers.launcher(1); % copy empty structure for all units, then fill in +ids_ec_launchers.beam(1:nb_launchers) = ids_ec_launchers.beam(1); % copy empty structure for all units, then fill in ids_ec_launchers_description.comment = ['assume ' num2str(nb_launchers) ' launchers']; if shot>=63000 @@ -48,22 +48,22 @@ end ids_ec_launchers_description.launch_params = launch_params; for iant=1:nb_launchers - ids_ec_launchers.launcher{iant}.identifier = ['L' num2str(iant)]; + ids_ec_launchers.beam{iant}.identifier = ['L' num2str(iant)]; switch iant case {1,4} - ids_ec_launchers.launcher{iant}.name = 'LFS equatorial launcher'; + ids_ec_launchers.beam{iant}.name = 'LFS equatorial launcher'; case {2, 3, 5, 6} - ids_ec_launchers.launcher{iant}.name = 'LFS top launcher'; + ids_ec_launchers.beam{iant}.name = 'LFS top launcher'; otherwise - ids_ec_launchers.launcher{iant}.name = 'TOP launcher'; + ids_ec_launchers.beam{iant}.name = 'TOP launcher'; end if any(isfinite(pow.ec.data(:,iant))) - ids_ec_launchers.launcher{iant}.power_launched.data = pow.ec.data(:,iant); - ids_ec_launchers.launcher{iant}.power_launched.time = pow.ec.t; - ids_ec_launchers_description.launcher{iant}.power_launched = 'from gdat powers .ec'; - ids_ec_launchers_description.launcher{iant}.launching_position = 'from launch_params obtained from toray_raygeom_TCV'; + ids_ec_launchers.beam{iant}.power_launched.data = pow.ec.data(:,iant); + ids_ec_launchers.beam{iant}.power_launched.time = pow.ec.t; + ids_ec_launchers_description.beam{iant}.power_launched = 'from gdat powers .ec'; + ids_ec_launchers_description.beam{iant}.launching_position = 'from launch_params obtained from toray_raygeom_TCV'; else - ids_ec_launchers_description.launcher{iant}.power_launched = 'no power for this launcher from gdat powers .ec'; + ids_ec_launchers_description.beam{iant}.power_launched = 'no power for this launcher from gdat powers .ec'; end if length(launch_params)>=iant && ~isempty(launch_params{iant}) % find 1st non-empty data @@ -74,48 +74,41 @@ for iant=1:nb_launchers end end % non time-dependent quantities, take 1st ok values - ids_ec_launchers.launcher{iant}.frequency.time = [pow.ec.t(1) pow.ec.t(end)]; - ids_ec_launchers.launcher{iant}.frequency.data =[launch_params{iant}{it_ok{iant}(1)}.freq launch_params{iant}{it_ok{iant}(end)}.freq]; - ids_ec_launchers.launcher{iant}.mode.time = [pow.ec.t(1) pow.ec.t(end)]; - ids_ec_launchers.launcher{iant}.mode.data = [-1 -1]; % at this stage assume X mode always, to change when available + ids_ec_launchers.beam{iant}.frequency.time = [pow.ec.t(1) pow.ec.t(end)]; + ids_ec_launchers.beam{iant}.frequency.data =[launch_params{iant}{it_ok{iant}(1)}.freq launch_params{iant}{it_ok{iant}(end)}.freq]; + % ids_ec_launchers.beam{iant}.mode.time = [pow.ec.t(1) pow.ec.t(end)]; + % ids_ec_launchers.beam{iant}.mode.data = [-1 -1]; % at this stage assume X mode always, to change when available + % ids_ec_launchers.beam{iant}.time = [pow.ec.t(1) pow.ec.t(end)]; + ids_ec_launchers.beam{iant}.mode = -1; % at this stage assume X mode always, to change when available for i=1:length(it_ok{iant}) r0 = sqrt(launch_params{iant}{it_ok{iant}(i)}.x0.^2 + launch_params{iant}{it_ok{iant}(i)}.y0.^2) / 100.; % in [m] time_launch = launch_params{iant}{it_ok{iant}(i)}.time; - ids_ec_launchers.launcher{iant}.launching_position.r(i) = r0; - ids_ec_launchers.launcher{iant}.launching_position.z(i) = launch_params{iant}{it_ok{iant}(i)}.z0/100.; - ids_ec_launchers.launcher{iant}.launching_position.phi(i) = atan2(launch_params{iant}{it_ok{iant}(i)}.y0/100,r0); - ids_ec_launchers.launcher{iant}.launching_position.time(i) = time_launch; + ids_ec_launchers.beam{iant}.launching_position.r(i) = r0; + ids_ec_launchers.beam{iant}.launching_position.z(i) = launch_params{iant}{it_ok{iant}(i)}.z0/100.; + ids_ec_launchers.beam{iant}.launching_position.phi(i) = atan2(launch_params{iant}{it_ok{iant}(i)}.y0/100,r0); + ids_ec_launchers.beam{iant}.time(i) = time_launch; kz = cos(launch_params{iant}{it_ok{iant}(i)}.theta_toray*pi/180.); kmr = -sin(launch_params{iant}{it_ok{iant}(i)}.theta_toray*pi/180.).*cos(launch_params{iant}{it_ok{iant}(i)}.phi_toray*pi/180.); kphi = sin(launch_params{iant}{it_ok{iant}(i)}.theta_toray*pi/180.).*sin(launch_params{iant}{it_ok{iant}(i)}.phi_toray*pi/180.); %*sigma_Rphiz (=+1 for TCV cocos=17) if (kz==0 && kmr==0) - ids_ec_launchers.launcher{iant}.steering_angle_pol.data(i) = 0.; + ids_ec_launchers.beam{iant}.steering_angle_pol(i) = 0.; else - ids_ec_launchers.launcher{iant}.steering_angle_pol.data(i) = atan2(-kz,kmr); + ids_ec_launchers.beam{iant}.steering_angle_pol(i) = atan2(-kz,kmr); end - ids_ec_launchers.launcher{iant}.steering_angle_pol.time(i) = time_launch; - ids_ec_launchers.launcher{iant}.steering_angle_tor.data(i) = asin(kphi); - ids_ec_launchers.launcher{iant}.steering_angle_tor.time(i) = time_launch; -% $$$ ids_ec_launchers.launcher{iant}.beam.spot.size.data(i,1) = 0.023; -% $$$ ids_ec_launchers.launcher{iant}.beam.spot.size.data(i,2) = 0.012; - ids_ec_launchers.launcher{iant}.beam.spot.size.data(1,i) = 0.023; - ids_ec_launchers.launcher{iant}.beam.spot.size.data(2,i) = 0.012; - ids_ec_launchers.launcher{iant}.beam.spot.size.time(i) = time_launch; - ids_ec_launchers.launcher{iant}.beam.spot.angle.data(i) = 0.0; - ids_ec_launchers.launcher{iant}.beam.spot.angle.time(i) = time_launch; -% $$$ ids_ec_launchers.launcher{iant}.beam.phase.curvature.data(i,1) = 1./1.88; -% $$$ ids_ec_launchers.launcher{iant}.beam.phase.curvature.data(i,2) = 1./-0.95; % negative in launch_params... - ids_ec_launchers.launcher{iant}.beam.phase.curvature.data(1,i) = 1./1.88; - ids_ec_launchers.launcher{iant}.beam.phase.curvature.data(2,i) = 1./-0.95; % negative in launch_params... - ids_ec_launchers.launcher{iant}.beam.phase.angle.data(i) = 0.0; - ids_ec_launchers.launcher{iant}.beam.phase.angle.time(i) = time_launch; - ids_ec_launchers.launcher{iant}.beam.phase.curvature.time(i) = time_launch; + ids_ec_launchers.beam{iant}.steering_angle_tor(i) = asin(kphi); + ids_ec_launchers.beam{iant}.spot.size(1,i) = 0.023; + ids_ec_launchers.beam{iant}.spot.size(2,i) = 0.012; + ids_ec_launchers.beam{iant}.spot.angle(i) = 0.0; + ids_ec_launchers.beam{iant}.phase.curvature(1,i) = 1./1.88; + ids_ec_launchers.beam{iant}.phase.curvature(2,i) = 1./-0.95; % negative in launch_params... + ids_ec_launchers.beam{iant}.phase.angle(i) = 0.0; end end end % cocos automatic transform if exist('ids_generic_cocos_nodes_transformation_symbolic') == 2 + [ids_ec_launchers,cocoscoeff]=ids_generic_cocos_nodes_transformation_symbolic(ids_ec_launchers,'ec_launchers',gdat_params.cocos_in, ... gdat_params.cocos_out,gdat_params.ipsign_out,gdat_params.b0sign_out,gdat_params.ipsign_in,gdat_params.b0sign_in, ... gdat_params.error_bar,gdat_params.nverbose); diff --git a/matlab/interpos_nan.m b/matlab/interpos_nan.m deleted file mode 100644 index 1b2e116bd62439cc3011c1cefab5d6cd84395be5..0000000000000000000000000000000000000000 --- a/matlab/interpos_nan.m +++ /dev/null @@ -1,38 +0,0 @@ -function [varargout] = interpos_nan(var1, var2, var3, varargin); -% -% see help interpos for details -% -% pre-exclude non-finite values from either xin or yin before calling interpos -% -nverbose = 1; % warnings -% -if nargin < 3 - error('xin and yin required'); -else - if isscalar(var1) - xin = var2; - yin = var3; - kopt_provided = 1; - else - xin = var1; - yin = var2; - kopt_provided = 0; - end - if nverbose >= 1 && (any(~isfinite(xin)) || any(~isfinite(yin))), warning('NaNs removed by interpos_nan'); end -end - -ij = find(isfinite(xin) & isfinite(yin)); -if ~isempty(ij) - xin_eff = xin(ij); - yin_eff = yin(ij); - if kopt_provided == 1 - [varargout{1:nargout}] = interpos(var1, xin_eff, yin_eff, varargin{:}); - else - [varargout{1:nargout}] = interpos(xin_eff, yin_eff, var3, varargin{:}); - end -else - if nargout > 0 - varargout = cell(nargout,1); - warning('Only NaNs in xin/yin'); - end -end diff --git a/matlab/tests/test_requestnames.m b/matlab/tests/test_requestnames.m index b37be7905a8ece0d820a0a1309424de60ee4909d..840646fb881d27f60d282be1a1f4832ca9deb222 100644 --- a/matlab/tests/test_requestnames.m +++ b/matlab/tests/test_requestnames.m @@ -32,6 +32,10 @@ classdef (SharedTestFixtures={... case 'eqdsk' % avoid writing files in /tmp, may not be allowed gdat_call = sprintf(['gdat_%s(%s,''%s'',''write'',0)'],lower(testCase.Machine),shot,request); + case 'gas_fluxes' + % test new gas flow entries + shot = 83173; % (GV1=GV2 case) + gdat_call = sprintf(['gdat_' lower(testCase.Machine) '(%s,''%s'')'],shot,request); case 'radcam' % need a newer shot for tcv radcam shot = 81102; @@ -60,6 +64,8 @@ classdef (SharedTestFixtures={... switch request case {'ece', 'expcode', 'ids', 'ni', 'ti', 'transp'} % tests not yet fully implemented and empty + case 'gas_fluxes' + testCase.assertTrue(iscell(gdat_out.data) && ~isempty(gdat_out.data{1})) case 'rtc' % in this case .data is empty, all in .scd_mems testCase.assertTrue(isfield(gdat_out,'scd_mems') && isstruct(gdat_out.scd_mems));