diff --git a/matlab/IMAS/gdat_imas.m b/matlab/IMAS/gdat_imas.m index 1547090fb7b478270201d9acf8d9e8c31290a8c1..5850cc9ac9fb88125ac6b39f3f10a8b04fa8f02a 100644 --- a/matlab/IMAS/gdat_imas.m +++ b/matlab/IMAS/gdat_imas.m @@ -7,7 +7,7 @@ function [gdat_data,gdat_params,error_status,varargout] = gdat_imas(shot,data_re % % If no inputs are provided, return the list of available pre-defined data_request in gdat_data and default parameters gdat_params % -% IMAS means assume access data from IDS database ala IMAS with tokamakname and dataversion and run_number using imas_open_env and ids_get calls +% IMAS means assume access data from IDS database ala IMAS with run_number, database_user, tokamak_name, data_major_version and using imas_open_env and ids_get calls % Should be the same on ITER hpc and gateway, to be checked % % At first only "ids" request implemented, but keywords like ip etc should relate to specific IDS as for any machine @@ -394,7 +394,8 @@ elseif strcmp(mapping_for_imas.method,'switchcase') params_eff = gdat_data.gdat_params; if isfield(params_eff,'source') && ~isempty(params_eff.source) - ids_top_name = params_eff.source; + ids_top_names = params_eff.source; + if ischar(ids_top_names); ids_top_names = {ids_top_names}; end else ids_top_name = []; warning('gdat:EmptyIDSName','Need an ids name in ''source'' parameter\n check substructure gdat_params.sources_available for an ids list'); @@ -405,29 +406,6 @@ elseif strcmp(mapping_for_imas.method,'switchcase') return end ids_gen_ok = ~~exist('ids_gen','file'); - - if ids_gen_ok - ids_empty = ids_gen(ids_top_name); % generate ids from gateway function ids_gen - else - % load empty ids structure from template file - fname = sprintf('ids_empty_%s',ids_top_name); - - try - assert(~~exist(ids_empty_path,'dir'),'folder %s not found',ids_empty_path); - addpath(ids_empty_path); - 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); - fprintf('Available templates:\n'); - disp(dir(ids_empty_path)); - rmpath(ids_empty_path); - rethrow(ME); - end - end if ~isfield(gdat_data.gdat_params,'error_bar') || isempty(gdat_data.gdat_params.error_bar) gdat_data.gdat_params.error_bar = 'delta'; end @@ -445,37 +423,68 @@ elseif strcmp(mapping_for_imas.method,'switchcase') end if ~isfield(gdat_data.gdat_params,'ipsign_in') || isempty(gdat_data.gdat_params.ipsign_in) if gdat_data.gdat_params.ipsign_out~=0 - gdat_data.gdat_params.ipsign_in = mdsvalue('\pcs::data:iohfb'); + gdat_data.gdat_params.ipsign_in = -1; else - gdat_data.gdat_params.ipsign_in = 0; + gdat_data.gdat_params.ipsign_in = 0; end end if ~isfield(gdat_data.gdat_params,'b0sign_in') || isempty(gdat_data.gdat_params.b0sign_in) if gdat_data.gdat_params.b0sign_out~=0 - gdat_data.gdat_params.b0sign_in = mdsvalue('\pcs::data:if36fb'); + gdat_data.gdat_params.b0sign_in = -1; else - gdat_data.gdat_params.b0sign_in = 0; + gdat_data.gdat_params.b0sign_in = 0; end end - try - if isfield(gdat_data.gdat_params,'idx_imas_open_env') && gdat_data.gdat_params.idx_imas_open_env >= 0 - if gdat_data.gdat_params.occurence == 0 - ids_top = ids_get(gdat_data.gdat_params.idx_imas_open_env,ids_top_name); + for i=1:length(ids_top_names) + ids_top_name = ids_top_names{i}; + if ids_gen_ok + ids_empty = ids_gen(ids_top_name); % generate ids from gateway function ids_gen + else + % load empty ids structure from template file + fname = sprintf('ids_empty_%s',ids_top_name); + try + assert(~~exist(ids_empty_path,'dir'),'folder %s not found',ids_empty_path); + addpath(ids_empty_path); + 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); + fprintf('Available templates:\n'); + disp(dir(ids_empty_path)); + rmpath(ids_empty_path); + rethrow(ME); + end + end + % load data + try + if isfield(gdat_data.gdat_params,'idx_imas_open_env') && gdat_data.gdat_params.idx_imas_open_env >= 0 + if gdat_data.gdat_params.occurence == 0 + ids_top = ids_get(gdat_data.gdat_params.idx_imas_open_env,ids_top_name); + else + ids_top = ids_get(gdat_data.gdat_params.idx_imas_open_env,[ids_top_name '/' num2str(gdat_data.gdat_params.occurence)]); + end + gdat_data.(ids_top_name) = ids_top; else - ids_top = ids_get(gdat_data.gdat_params.idx_imas_open_env,[ids_top_name '/' num2str(gdat_data.gdat_params.occurence)]); + gdat_data.(ids_top_name) = ids_empty; end - gdat_data.(ids_top_name) = ids_top; - else - gdat_data.(ids_top_name) = ids_empty; + catch ME_imas_ids_get + disp(['there is a problem with: imas_get_ids_' ids_top_name ... + ' , may be check if it exists in your path or test it by itself']) + gdat_data.(ids_top_name) = ids_empty; + gdat_data.([ids_top_name '_help']) = getReport(ME_imas_ids_get); + rethrow(ME_imas_ids_get) + end + % Perform cocos transformation if cocos_out ~= cocos_in + if gdat_data.gdat_params.cocos_in ~= gdat_data.gdat_params.cocos_out + [ids_out,cocoscoeff]=ids_generic_cocos_nodes_transformation_symbolic(gdat_data.(ids_top_name),ids_top_name, ... + gdat_data.gdat_params.cocos_in, gdat_data.gdat_params.cocos_out, gdat_data.gdat_params.ipsign_out,gdat_data.gdat_params.b0sign_out, ... + gdat_data.gdat_params.ipsign_in, gdat_data.gdat_params.b0sign_in); end - catch ME_imas_ids_get - disp(['there is a problem with: imas_get_ids_' ids_top_name ... - ' , may be check if it exists in your path or test it by itself']) - gdat_data.(ids_top_name) = ids_empty; - gdat_data.([ids_top_name '_help']) = getReport(ME_imas_ids_get); - rethrow(ME_imas_ids_get) end - + %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% otherwise if (gdat_params.nverbose>=1); warning(['switchcase= ' data_request_eff ' not known in gdat_imas']); end diff --git a/matlab/TCV/gdat_tcv.m b/matlab/TCV/gdat_tcv.m index 345182edebf19f6143c02b12e11e2e772c8f6a11..16014647adbc3c95ef8938bd335a7042902a3363 100644 --- a/matlab/TCV/gdat_tcv.m +++ b/matlab/TCV/gdat_tcv.m @@ -137,8 +137,12 @@ do_mdsopen_mdsclose = 1; % treat 1st arg if nargin>=1 if isempty(shot) - % means mdsopen(shot) already performed - shot_mds = mdsipmex(2,'$SHOT'); + % means mdsopen(shot) already performed or not shot asked for + try + shot_mds = mdsipmex(2,'$SHOT'); + catch + shot_mds = shot; + end if isnumeric(shot_mds); shot = shot_mds; end gdat_data.shot = shot; do_mdsopen_mdsclose = 0; diff --git a/matlab/TCV_IMAS/ids2database.m b/matlab/TCV_IMAS/ids2database.m index f9e12a7dcb4c3dba660452f13e4b0378c199d0f2..f9e2d2551389b95278dcbc2fa25a068262e9d8eb 100644 --- a/matlab/TCV_IMAS/ids2database.m +++ b/matlab/TCV_IMAS/ids2database.m @@ -74,9 +74,13 @@ params_ids2database = params; % check ids_names ids_names=fieldnames(ids2put); try - ids_full_list = IDS_list; + if exist('ids_list') + ids_full_list = ids_list; + else + ids_full_list = IDS_list; + end catch - ids_full_list = {'equilibrium', 'magnetics', 'tf', 'pf_active','wall','core_profiles','ec_launchers','nbi'}; + ids_full_list = {'equilibrium', 'magnetics', 'tf', 'pf_active','wall','core_profiles','ec_launchers','nbi','pf_passive'}; 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/gdatpaths.m b/matlab/gdatpaths.m index 108aff2e5173e732213c6a997a1ca8d88f89835e..9d3cd1d92410ac56fc56f6f9efc82bfa35221fb0 100644 --- a/matlab/gdatpaths.m +++ b/matlab/gdatpaths.m @@ -19,7 +19,7 @@ a = fileparts(a); % machines=[{'JET'} {'TCV'} {'AUG'} {'D3D'}]; % machines=[{'JET'} {'TCV'} {'AUG'} {'KSTAR'}]; -machines=[{'JET'} {'TCV'} {'AUG'} {'D3D'} {'KSTAR'} {'TCV_IMAS'} {'AUG_IMAS'} {'CHDF'}]; +machines=[{'JET'} {'TCV'} {'AUG'} {'D3D'} {'KSTAR'} {'TCV_IMAS'} {'AUG_IMAS'} {'CHDF'} {'IMAS'}]; add_paths = cell(1,length(machines)); for i=1:length(machines) diff --git a/matlab/get_data_request_names_from_gdat_xxx.m b/matlab/get_data_request_names_from_gdat_xxx.m index 133f1b20f1ea75f5dbc8a8921a1e34cb5b916657..728e15104fa01f798cd407f731b7715b54e364c4 100644 --- a/matlab/get_data_request_names_from_gdat_xxx.m +++ b/matlab/get_data_request_names_from_gdat_xxx.m @@ -7,7 +7,7 @@ function [data_request_names] = get_data_request_names_from_gdat_xxx(machine_in) data_request_names = []; -expected_machines = [{'aug'}, {'d3d'}, {'jet'}, {'tcv'}]; % substrutures created for these at this stage (all means all of these) +expected_machines = [{'aug'}, {'d3d'}, {'jet'}, {'tcv'} {'chdf'} {'imas'}]; % substrutures created for these at this stage (all means all of these) try machine_in = validatestring(machine_in,expected_machines); catch ME, disp(ME.message);