From a141e0a9b89efd568aa1be5f8547cc5399718a27 Mon Sep 17 00:00:00 2001 From: Olivier Sauter <Olivier.Sauter@epfl.ch> Date: Thu, 21 Nov 2019 11:28:40 +0100 Subject: [PATCH] replace ec_antennas by ec_launchers --- matlab/TCV/gdat_tcv.m | 1 + matlab/TCV_IMAS/ids2database.m | 2 +- matlab/TCV_IMAS/tcv2ids.m | 4 +- matlab/TCV_IMAS/tcv2ids2database.m | 6 +- matlab/TCV_IMAS/tcv_get_ids_ec_antennas.m | 124 --------------------- matlab/TCV_IMAS/tcv_get_ids_ec_launchers.m | 124 +++++++++++++++++++++ 6 files changed, 131 insertions(+), 130 deletions(-) delete mode 100644 matlab/TCV_IMAS/tcv_get_ids_ec_antennas.m create mode 100644 matlab/TCV_IMAS/tcv_get_ids_ec_launchers.m diff --git a/matlab/TCV/gdat_tcv.m b/matlab/TCV/gdat_tcv.m index 6d6c6986..345182ed 100644 --- a/matlab/TCV/gdat_tcv.m +++ b/matlab/TCV/gdat_tcv.m @@ -1251,6 +1251,7 @@ elseif strcmp(mapping_for_tcv.method,'switchcase') assert(~~exist(fname,'file'),'file %s does not exist in %s',fname,ids_empty_path); ids_empty = eval(fname); + disp(['use structure in .mat file: ' ids_empty_path '/' fname]); rmpath(ids_empty_path); catch ME fprintf('Could not load empty template for %s\n',ids_top_name); diff --git a/matlab/TCV_IMAS/ids2database.m b/matlab/TCV_IMAS/ids2database.m index 0ed705e6..f9e12a7d 100644 --- a/matlab/TCV_IMAS/ids2database.m +++ b/matlab/TCV_IMAS/ids2database.m @@ -76,7 +76,7 @@ ids_names=fieldnames(ids2put); try ids_full_list = IDS_list; catch - ids_full_list = {'equilibrium', 'magnetics', 'tf', 'pf_active','wall','core_profiles','ec_antennas','nbi'}; + ids_full_list = {'equilibrium', 'magnetics', 'tf', 'pf_active','wall','core_profiles','ec_launchers','nbi'}; warning(['IDS_list not available, quick fix introducing list of ids ready for TCV: ' fprintf('%s ',ids_full_list{:}) char(10)]); end ids_names_notok = setdiff(ids_names,ids_full_list); diff --git a/matlab/TCV_IMAS/tcv2ids.m b/matlab/TCV_IMAS/tcv2ids.m index 9b121c6e..69786d1f 100644 --- a/matlab/TCV_IMAS/tcv2ids.m +++ b/matlab/TCV_IMAS/tcv2ids.m @@ -11,7 +11,7 @@ function [ids_from_tcv,varargout] = tcv2ids(shot,varargin); % mdsconnect('localhost:5555') % % varargin: 'ids_names': cell, idss to load, by default all defined so far (if empty or empty string or not given) -% {'equilibrium', 'magnetics', 'pf_active','wall','core_profiles','ec_antennas','nbi'} or a subset +% {'equilibrium', 'magnetics', 'pf_active','wall','core_profiles','ec_launchers','nbi'} or a subset % 'error_bar': type (string) % empty or 'delta' (default): meaning difference in upper is set (standard error_bar % 'added': errorbar is added: upper=data+delta and lower=data-delta @@ -32,7 +32,7 @@ p = inputParser; % no required inputs here so one can call with empty args and get defaults parameters % effectively required inputs should have defaults as empty p.addOptional('shot', [], @(x) (isnumeric(x) && isscalar(x) && (x == round(x)))); % integer -p.addOptional('ids_names', {'equilibrium', 'magnetics', 'pf_active','wall', 'tf','core_profiles','ec_antennas','nbi'}, @(x) isempty(x) || iscell(x) ); % char or cell array +p.addOptional('ids_names', {'equilibrium', 'magnetics', 'pf_active','wall', 'tf','core_profiles','ec_launchers','nbi'}, @(x) isempty(x) || iscell(x) ); % char or cell array p.addOptional('error_bar', 'delta', @(x) isempty(x) || ischar(x) ); % char or cell array p.addOptional('cocos_out', 11, @(x) isempty(x) || isnumeric(x) ); % char p.addOptional('ipsign_out', 0, @(x) isempty(x) || (x==0 | x==-1 | x==+1) ); % char diff --git a/matlab/TCV_IMAS/tcv2ids2database.m b/matlab/TCV_IMAS/tcv2ids2database.m index 3079e2a3..52bc6058 100644 --- a/matlab/TCV_IMAS/tcv2ids2database.m +++ b/matlab/TCV_IMAS/tcv2ids2database.m @@ -9,7 +9,7 @@ function [ids_from_tcv,varargout] = tcv2ids2database(shot,run_out,varargin); % % varargin: 'occurence': occurence value % varargin: 'ids_names': cell, ids to load, by default all defined so far (if empty or empty string or not given) -% {'equilibrium', 'magnetics', 'tf', 'pf_active','wall','core_profiles','ec_antennas','nbi'} or a subset +% {'equilibrium', 'magnetics', 'tf', 'pf_active','wall','core_profiles','ec_launchers','nbi'} or a subset % varargin: 'error_bar': type (string) % 'delta' or empty (default): meaning difference in upper is set (standard error_bar % 'added': errorbar is added: upper=data+delta and lower=data-delta @@ -47,7 +47,7 @@ p = inputParser; p.addOptional('shot', [], @(x) (isnumeric(x) && isscalar(x) && (x == round(x)))); % integer p.addOptional('run_out', [], @(x) (isnumeric(x) && isscalar(x) && (x == round(x)))); % integer p.addOptional('occurence', 0, @(x) isempty(x) || (isnumeric(x) && isscalar(x) && (x == round(x)))); % integer -p.addOptional('ids_names', {'equilibrium', 'magnetics', 'pf_active','wall', 'tf','core_profiles','ec_antennas','nbi'}, @(x) isempty(x) || iscell(x)); % char or cell array +p.addOptional('ids_names', {'equilibrium', 'magnetics', 'pf_active','wall', 'tf','core_profiles','ec_launchers','nbi'}, @(x) isempty(x) || iscell(x)); % char or cell array p.addOptional('error_bar', 'delta', @(x) isempty(x) || ischar(x) ); % char or cell array p.addOptional('tree_user', getenv('USER'), @(x) isempty(x) || ischar(x) ); % char p.addOptional('tree_tokamak', 'tcv', @(x) isempty(x) || ischar(x) ); % char @@ -136,5 +136,5 @@ ids_from_tcv.ids_put_status = ids_put_status; % tic;[TTTp,idsp]=evalc('ids_get(expIdx, ''pf_active'')');toc % tic;[TTTt,idst]=evalc('ids_get(expIdx, ''tf'')');toc % tic;[TTTw,idsw]=evalc('ids_get(expIdx, ''wall'')');toc -% tic;[TTTw,idsw]=evalc('ids_get(expIdx, ''ec_antennas'')');toc +% tic;[TTTw,idsw]=evalc('ids_get(expIdx, ''ec_launchers'')');toc % tic;[TTTw,idsw]=evalc('ids_get(expIdx, ''nbi'')');toc diff --git a/matlab/TCV_IMAS/tcv_get_ids_ec_antennas.m b/matlab/TCV_IMAS/tcv_get_ids_ec_antennas.m deleted file mode 100644 index 4985b651..00000000 --- a/matlab/TCV_IMAS/tcv_get_ids_ec_antennas.m +++ /dev/null @@ -1,124 +0,0 @@ -function [ids_ec_antennas,ids_ec_antennas_description,varargout] = tcv_get_ids_ec_antennas(shot,ids_ec_antennas_empty, gdat_params,varargin); -% -% [ids_ec_antennas,ids_ec_antennas_description,varargout] = tcv_get_ids_ec_antennas(shot,ids_ec_antennas_empty,varargin); -% -% -% gdat_params: gdat_data.gdat_params to get all params passed from original call, in particular error_bar options -% - -if exist('gdat_params') - [ids_ec_antennas, params_ec_antennas] = tcv_ids_headpart(shot,ids_ec_antennas_empty,'ec_antennas','homogeneous_time',0, ... - 'gdat_params',gdat_params,varargin{:}); -else - [ids_ec_antennas, params_ec_antennas] = tcv_ids_headpart(shot,ids_ec_antennas_empty,'ec_antennas','homogeneous_time',0,varargin{:}); - aa=gdat_tcv; - gdat_params = aa.gdat_params; % to get default params -end -params_eff_ref = gdat_params; params_eff_ref.doplot=0; -try;params_eff_ref=rmfield(params_eff_ref,'source');catch;end % make sure no source (from ids def) - -% As a general rule, for a new substructure under the main ids, construct a local structure like: -% "global_quantities" with subfields being the relevant data to get and a local structure: -% "global_quantities_desc" which contains the same subfields themselves containing the gdat string aftre shot used -% - -params_eff = params_eff_ref; -params_eff.data_request = 'powers'; -pow=gdat_tcv(shot,params_eff); -pow_desc = params_eff.data_request; -if isempty(pow.ec.t) || isempty(pow.ec.data) || max(pow.ec.data(:,end))<1e-10 - ids_ec_antennas_description.comment = 'no power'; - return -end - -nb_antennas = size(pow.ec.data,2)-1; % at this stage keep same numbering as standard TCV launchers before mid-2019 - -ids_ec_antennas.antenna(1:nb_antennas) = ids_ec_antennas.antenna(1); % copy empty structure for all units, then fill in -ids_ec_antennas_description.comment = ['assume ' num2str(nb_antennas) ' launchers']; - -if shot>=63000 - warning('not sure if set-up correct for new launchers, beams, gyrotrons. Check with O. Sauter') - % return -end - -% $$$ ids_ec_antennas.time = pow.ec.t; if homogeneous time -% $$$ ids_ec_antennas_description.time = 'time from power'; -[r_phi0,z_phi0,r1,z1,rc,zc,thetphi_L,thetphi_tor,raysbylauncher,powers,fname,z_axis,launch_params] = ... - toray_raygeom_TCV(shot,pow.ec.t(1:10:end)); -ids_ec_antennas_description.launch_params = launch_params; - - -for iant=1:nb_antennas - ids_ec_antennas.antenna{iant}.identifier = ['L' num2str(iant)]; - switch iant - case {1,4} - ids_ec_antennas.antenna{iant}.name = 'LFS equatorial launcher'; - case {2, 3, 5, 6} - ids_ec_antennas.antenna{iant}.name = 'LFS top launcher'; - otherwise - ids_ec_antennas.antenna{iant}.name = 'TOP launcher'; - end - if any(isfinite(pow.ec.data(:,iant))) - ids_ec_antennas.antenna{iant}.power_launched.data = pow.ec.data(:,iant); - ids_ec_antennas.antenna{iant}.power_launched.time = pow.ec.t; - ids_ec_antennas_description.antenna{iant}.power_launched = 'from gdat powers .ec'; - ids_ec_antennas_description.antenna{iant}.launching_position = 'from launch_params obtained from toray_raygeom_TCV'; - else - ids_ec_antennas_description.antenna{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 - it_ok{iant} = []; - for it=1:length(launch_params{iant}) - if ~isempty(launch_params{iant}{it}) - it_ok{iant}(end+1) = it; - end - end - % non time-dependent quantities, take 1st ok values - ids_ec_antennas.antenna{iant}.frequency =launch_params{iant}{it_ok{iant}(1)}.freq; - ids_ec_antennas.antenna{iant}.mode.time = [pow.ec.t(1) pow.ec.t(end)]; - ids_ec_antennas.antenna{iant}.mode.data = [-1 -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_antennas.antenna{iant}.launching_position.r.data(i) = r0; - ids_ec_antennas.antenna{iant}.launching_position.z.data(i) = launch_params{iant}{it_ok{iant}(i)}.z0/100.; - ids_ec_antennas.antenna{iant}.launching_position.phi.data(i) = atan2(launch_params{iant}{it_ok{iant}(i)}.y0/100,r0); - ids_ec_antennas.antenna{iant}.launching_position.r.time(i) = time_launch; - ids_ec_antennas.antenna{iant}.launching_position.z.time(i) = time_launch; - ids_ec_antennas.antenna{iant}.launching_position.phi.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_antennas.antenna{iant}.launching_angle_pol.data(i) = 0.; - else - ids_ec_antennas.antenna{iant}.launching_angle_pol.data(i) = atan2(-kz,kmr); - end - ids_ec_antennas.antenna{iant}.launching_angle_pol.time(i) = time_launch; - ids_ec_antennas.antenna{iant}.launching_angle_tor.data(i) = asin(kphi); - ids_ec_antennas.antenna{iant}.launching_angle_tor.time(i) = time_launch; -% $$$ ids_ec_antennas.antenna{iant}.beam.spot.size.data(i,1) = 0.023; -% $$$ ids_ec_antennas.antenna{iant}.beam.spot.size.data(i,2) = 0.012; - ids_ec_antennas.antenna{iant}.beam.spot.size.data(1,i) = 0.023; - ids_ec_antennas.antenna{iant}.beam.spot.size.data(2,i) = 0.012; - ids_ec_antennas.antenna{iant}.beam.spot.size.time(i) = time_launch; - ids_ec_antennas.antenna{iant}.beam.spot.angle.data(i) = 0.0; - ids_ec_antennas.antenna{iant}.beam.spot.angle.time(i) = time_launch; -% $$$ ids_ec_antennas.antenna{iant}.beam.phase.curvature.data(i,1) = 1./1.88; -% $$$ ids_ec_antennas.antenna{iant}.beam.phase.curvature.data(i,2) = 1./-0.95; % negative in launch_params... - ids_ec_antennas.antenna{iant}.beam.phase.curvature.data(1,i) = 1./1.88; - ids_ec_antennas.antenna{iant}.beam.phase.curvature.data(2,i) = 1./-0.95; % negative in launch_params... - ids_ec_antennas.antenna{iant}.beam.phase.angle.data(i) = 0.0; - ids_ec_antennas.antenna{iant}.beam.phase.angle.time(i) = time_launch; - ids_ec_antennas.antenna{iant}.beam.phase.curvature.time(i) = time_launch; - end - end -end - -% cocos automatic transform -if exist('ids_generic_cocos_nodes_transformation_symbolic') == 2 - [ids_ec_antennas,cocoscoeff]=ids_generic_cocos_nodes_transformation_symbolic(ids_ec_antennas,'ec_antennas',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); -end diff --git a/matlab/TCV_IMAS/tcv_get_ids_ec_launchers.m b/matlab/TCV_IMAS/tcv_get_ids_ec_launchers.m new file mode 100644 index 00000000..680350bb --- /dev/null +++ b/matlab/TCV_IMAS/tcv_get_ids_ec_launchers.m @@ -0,0 +1,124 @@ +function [ids_ec_launchers,ids_ec_launchers_description,varargout] = tcv_get_ids_ec_launchers(shot,ids_ec_launchers_empty, gdat_params,varargin); +% +% [ids_ec_launchers,ids_ec_launchers_description,varargout] = tcv_get_ids_ec_launchers(shot,ids_ec_launchers_empty,varargin); +% +% +% gdat_params: gdat_data.gdat_params to get all params passed from original call, in particular error_bar options +% + +if exist('gdat_params') + [ids_ec_launchers, params_ec_launchers] = tcv_ids_headpart(shot,ids_ec_launchers_empty,'ec_launchers','homogeneous_time',0, ... + 'gdat_params',gdat_params,varargin{:}); +else + [ids_ec_launchers, params_ec_launchers] = tcv_ids_headpart(shot,ids_ec_launchers_empty,'ec_launchers','homogeneous_time',0,varargin{:}); + aa=gdat_tcv; + gdat_params = aa.gdat_params; % to get default params +end +params_eff_ref = gdat_params; params_eff_ref.doplot=0; +try;params_eff_ref=rmfield(params_eff_ref,'source');catch;end % make sure no source (from ids def) + +% As a general rule, for a new substructure under the main ids, construct a local structure like: +% "global_quantities" with subfields being the relevant data to get and a local structure: +% "global_quantities_desc" which contains the same subfields themselves containing the gdat string aftre shot used +% + +params_eff = params_eff_ref; +params_eff.data_request = 'powers'; +pow=gdat_tcv(shot,params_eff); +pow_desc = params_eff.data_request; +if isempty(pow.ec.t) || isempty(pow.ec.data) || max(pow.ec.data(:,end))<1e-10 + ids_ec_launchers_description.comment = 'no power'; + return +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_description.comment = ['assume ' num2str(nb_launchers) ' launchers']; + +if shot>=63000 + warning('not sure if set-up correct for new launchers, beams, gyrotrons. Check with O. Sauter') + % return +end + +% $$$ ids_ec_launchers.time = pow.ec.t; if homogeneous time +% $$$ ids_ec_launchers_description.time = 'time from power'; +[r_phi0,z_phi0,r1,z1,rc,zc,thetphi_L,thetphi_tor,raysbylauncher,powers,fname,z_axis,launch_params] = ... + toray_raygeom_TCV(shot,pow.ec.t(1:10:end)); +ids_ec_launchers_description.launch_params = launch_params; + +for iant=1:nb_launchers + ids_ec_launchers.launcher{iant}.identifier = ['L' num2str(iant)]; + switch iant + case {1,4} + ids_ec_launchers.launcher{iant}.name = 'LFS equatorial launcher'; + case {2, 3, 5, 6} + ids_ec_launchers.launcher{iant}.name = 'LFS top launcher'; + otherwise + ids_ec_launchers.launcher{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'; + else + ids_ec_launchers_description.launcher{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 + it_ok{iant} = []; + for it=1:length(launch_params{iant}) + if ~isempty(launch_params{iant}{it}) + it_ok{iant}(end+1) = it; + 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 + 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.data(i) = r0; + ids_ec_launchers.launcher{iant}.launching_position.z.data(i) = launch_params{iant}{it_ok{iant}(i)}.z0/100.; + ids_ec_launchers.launcher{iant}.launching_position.phi.data(i) = atan2(launch_params{iant}{it_ok{iant}(i)}.y0/100,r0); + ids_ec_launchers.launcher{iant}.launching_position.r.time(i) = time_launch; + ids_ec_launchers.launcher{iant}.launching_position.z.time(i) = time_launch; + ids_ec_launchers.launcher{iant}.launching_position.phi.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.; + else + ids_ec_launchers.launcher{iant}.steering_angle_pol.data(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; + 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); +end -- GitLab