From 98f475a9679414e5f368af783b370e2922377077 Mon Sep 17 00:00:00 2001 From: Olivier Sauter <olivier.sauter@epfl.ch> Date: Wed, 8 May 2019 14:57:49 +0000 Subject: [PATCH] make 3 options for errorbar: 'delta' (default), 'delta_with_lower' and 'added' git-svn-id: https://spcsvn.epfl.ch/repos/TCV/gdat/trunk@11837 d63d8f72-b253-0410-a779-e742ad2e26cf --- crpptbx/TCV/gdat_tcv.m | 12 ++++++------ crpptbx/TCV_IMAS/tcv2ids.m | 2 +- crpptbx/TCV_IMAS/tcv2ids2database.m | 2 +- crpptbx/TCV_IMAS/tcv_get_ids_pf_active.m | 2 +- crpptbx/TCV_IMAS/tcv_get_ids_wall.m | 4 ++-- crpptbx/TCV_IMAS/tcv_ids_bpol_probe.m | 16 ++++++++++++---- crpptbx/TCV_IMAS/tcv_ids_flux_loop.m | 18 ++++++++++++++---- crpptbx/TCV_IMAS/tcv_ids_ip.m | 5 +++-- ...ription.m => tcv_ids_wall_description_2d.m} | 7 +++---- 9 files changed, 43 insertions(+), 25 deletions(-) rename crpptbx/TCV_IMAS/{tcv_ids_wall_description.m => tcv_ids_wall_description_2d.m} (53%) diff --git a/crpptbx/TCV/gdat_tcv.m b/crpptbx/TCV/gdat_tcv.m index c03c33ed..c11a752b 100644 --- a/crpptbx/TCV/gdat_tcv.m +++ b/crpptbx/TCV/gdat_tcv.m @@ -1099,7 +1099,7 @@ elseif strcmp(mapping_for_tcv.method,'switchcase') disp('check substructure gdat_params.source_available for an ids list'); end ids_gen_ok = exist('ids_gen'); - equil_empty = struct([]); + ids_empty = struct([]); if ids_gen_ok ~= 2 ids_struct_saved = '/home/sauter/matlab/gdat_develop/crpptbx/TCV_IMAS/ids_structures_20190312.mat'; if ~exist(ids_struct_saved,'file') @@ -1108,7 +1108,7 @@ elseif strcmp(mapping_for_tcv.method,'switchcase') else eval(['load ' ids_struct_saved]) if isfield(ids_structures,ids_top_name) - equil_empty = ids_structures.(ids_top_name); + ids_empty = ids_structures.(ids_top_name); else if ~isempty(ids_top_name); warning(['ids ''' ids_top_name ''' does not exist in ids_structures saved in ' ids_struct_saved]); @@ -1118,22 +1118,22 @@ elseif strcmp(mapping_for_tcv.method,'switchcase') end end else - equil_empty = ids_gen(ids_top_name); + ids_empty = ids_gen(ids_top_name); end try if ~isempty(shot) - eval(['[ids_top,ids_top_description]=tcv_get_ids_' ids_top_name '(shot,equil_empty);']) + eval(['[ids_top,ids_top_description]=tcv_get_ids_' ids_top_name '(shot,ids_empty,gdat_data.gdat_params);']) gdat_data.(ids_top_name) = ids_top; gdat_data.([ids_top_name '_description']) = ids_top_description; else - gdat_data.(ids_top_name) = equil_empty; + gdat_data.(ids_top_name) = ids_empty; gdat_data.([ids_top_name '_description']) = ['shot empty so return default empty structure for ' ids_top_name]; end catch ME_tcv_get_ids getReport(ME_tcv_get_ids) disp(['there is a problem with: tcv_get_ids_' ids_top_name ... ' , may be check if it exists in your path or test it by itself']) - gdat_data.(ids_top_name) = equil_empty; + gdat_data.(ids_top_name) = ids_empty; gdat_data.([ids_top_name '_description']) = getReport(ME_tcv_get_ids); end diff --git a/crpptbx/TCV_IMAS/tcv2ids.m b/crpptbx/TCV_IMAS/tcv2ids.m index 1e6ea138..69df85e4 100644 --- a/crpptbx/TCV_IMAS/tcv2ids.m +++ b/crpptbx/TCV_IMAS/tcv2ids.m @@ -80,7 +80,7 @@ end for i=1:length(params_tcv2ids.ids_names) ids_to_get = params_tcv2ids.ids_names{i}; - tmp = gdat(shot,'ids','source',ids_to_get,'machine','tcv'); + tmp = gdat(shot,'ids','source',ids_to_get,'machine','tcv','error_bar','added'); ids_from_tcv.(ids_to_get) = tmp.(ids_to_get); ids_from_tcv.([ids_to_get '_description']) = tmp.([ids_to_get '_description']); end diff --git a/crpptbx/TCV_IMAS/tcv2ids2database.m b/crpptbx/TCV_IMAS/tcv2ids2database.m index 677a4ea2..791edd51 100644 --- a/crpptbx/TCV_IMAS/tcv2ids2database.m +++ b/crpptbx/TCV_IMAS/tcv2ids2database.m @@ -10,7 +10,7 @@ end shot=40000; shot=62745; -run_out=1; +run_out=2; occurence=0; ids2get = {'equilibrium', 'magnetics', 'pf_active','wall','core_profiles'}; % default will load all defined so far diff --git a/crpptbx/TCV_IMAS/tcv_get_ids_pf_active.m b/crpptbx/TCV_IMAS/tcv_get_ids_pf_active.m index 92a5cae6..13edd4f9 100644 --- a/crpptbx/TCV_IMAS/tcv_get_ids_pf_active.m +++ b/crpptbx/TCV_IMAS/tcv_get_ids_pf_active.m @@ -9,7 +9,7 @@ function [ids_pf_active,ids_description,varargout] = tcv_get_ids_pf_active(shot, % Get subfield [ids_pf_active.coil]= tcv_ids_coil(params.shot, ids_pf_active.coil(1)); [ids_pf_active.circuit]= tcv_ids_circuit(params.shot, ids_pf_active.circuit(1)); -[ids_pf_active.supply]= tcv_get_ids_supply(params.shot, ids_pf_active.supply(1)); +[ids_pf_active.supply]= tcv_ids_supply(params.shot, ids_pf_active.supply(1)); % make arrays not filled in empty: not the case for magnetics ids_pf_active.vertical_force = {}; diff --git a/crpptbx/TCV_IMAS/tcv_get_ids_wall.m b/crpptbx/TCV_IMAS/tcv_get_ids_wall.m index 2196f69d..c65f0e28 100644 --- a/crpptbx/TCV_IMAS/tcv_get_ids_wall.m +++ b/crpptbx/TCV_IMAS/tcv_get_ids_wall.m @@ -1,4 +1,4 @@ -function [ids_wall,ids_description,varargout] = tcv_get_ids_wall(shot, ids_wall_empty, gdat_params, varargin) +function [ids_wall,ids_wall_description,varargout] = tcv_get_ids_wall(shot, ids_wall_empty, gdat_params, varargin) % % % gdat_params: gdat_data.gdat_params to get all params passed from original call, in particular error_bar options @@ -8,7 +8,7 @@ function [ids_wall,ids_description,varargout] = tcv_get_ids_wall(shot, ids_wall_ [ids_wall, params] = tcv_ids_headpart(shot, ids_wall_empty,'wall','homogeneous_time',0,varargin{:}); % Get data of outline -[ids_wall.description_2d]= tcv_ids_wall_description_2d(params.shot, ids_wall.description_2d(1)); +[ids_wall.description_2d,ids_wall_description.description_2d]= tcv_ids_wall_description_2d(params.shot, ids_wall.description_2d(1)); % make arrays not filled in empty: not the case for magnetics ids_wall.global_quantities.neutral = {}; % wall does not work with Antoine's addpath diff --git a/crpptbx/TCV_IMAS/tcv_ids_bpol_probe.m b/crpptbx/TCV_IMAS/tcv_ids_bpol_probe.m index 73af32fc..16e07c44 100644 --- a/crpptbx/TCV_IMAS/tcv_ids_bpol_probe.m +++ b/crpptbx/TCV_IMAS/tcv_ids_bpol_probe.m @@ -5,11 +5,12 @@ function [sub_ids_struct_out,sub_ids_struct_out_description, varargout] = tcv_i % Get magnetics.bpol_probe % % error_bar: from gdat_params.error_bar -% 'relative' (default): value to be added -% 'added': value already added to data: data +- error_bar +% 'delta' (default): error_bar to be added inserted in "upper" only as mentioned in description +% 'delta_with_lower' : error_bar (abs) inserted in both lower and upper +% 'added': value already added to data: upper/lower = data +/- error_bar % -error_bar = 'relative'; +error_bar = 'delta'; if exist('gdat_params') && isfield(gdat_params,'error_bar') && ~isempty(gdat_params.error_bar) error_bar = gdat_params.error_bar; end @@ -45,12 +46,19 @@ end fixed_error = 0.009999999776483; switch error_bar - case 'relative' + case 'delta' for ii=1:Nprobes sub_ids_struct_out{ii}.field.data_error_upper = fixed_error.*ones(size(sub_ids_struct_out{ii}.field.data));% TO BE FOUND; sub_ids_struct_out_description{ii}.field_data_error_upper = ['from fixed error value in case ' error_bar]; sub_ids_struct_out_description{ii}.field_data_error_lower = ['not provided since symmetric']; end + case 'delta_with_lower' + for ii=1:Nprobes + sub_ids_struct_out{ii}.field.data_error_upper = fixed_error.*ones(size(sub_ids_struct_out{ii}.field.data)); + sub_ids_struct_out{ii}.field.data_error_lower = sub_ids_struct_out{ii}.field.data_error_upper; + sub_ids_struct_out_description{ii}.field_data_error_upper = ['from fixed error value in case ' error_bar]; + sub_ids_struct_out_description{ii}.field_data_error_lower = ['from fixed error value in case ' error_bar]; + end case 'added' for ii=1:Nprobes sub_ids_struct_out{ii}.field.data_error_upper = sub_ids_struct_out{ii}.field.data + fixed_error.*ones(size(sub_ids_struct_out{ii}.field.data)); diff --git a/crpptbx/TCV_IMAS/tcv_ids_flux_loop.m b/crpptbx/TCV_IMAS/tcv_ids_flux_loop.m index ffb338de..a108da40 100644 --- a/crpptbx/TCV_IMAS/tcv_ids_flux_loop.m +++ b/crpptbx/TCV_IMAS/tcv_ids_flux_loop.m @@ -5,11 +5,12 @@ function [sub_ids_struct_out,sub_ids_struct_out_description] = tcv_ids_flux_loop % Get ids field magnetics.flux_loop % % error_bar: from gdat_params.error_bar -% 'relative' (default): value to be added -% 'added': value already added to data: data +- error_bar +% 'delta' (default): error_bar to be added inserted in "upper" only as mentioned in description +% 'delta_with_lower' : error_bar (abs) inserted in both lower and upper +% 'added': value already added to data: upper/lower = data +/- error_bar % -error_bar = 'relative'; +error_bar = 'delta'; if exist('gdat_params') && isfield(gdat_params,'error_bar') && ~isempty(gdat_params.error_bar) error_bar = gdat_params.error_bar; end @@ -34,17 +35,26 @@ for ii=1:Nprobes sub_ids_struct_out_description{ii}.position_z = ['from ''STATIC("Z_F" )[' sub_ids_struct_out{ii}.name ']''']; sub_ids_struct_out{ii}.flux.data = data(:,ii); sub_ids_struct_out_description{ii}.flux_data = 'from ''tcv_idealloop("FLUX")'''; + sub_ids_struct_out{ii}.flux.time = time; % sub_ids_struct_out{ii}.position.phi = 0; % TO BE FOUND end switch error_bar - case 'relative' + case 'delta' for ii=1:Nprobes sub_ids_struct_out{ii}.flux.data_error_upper = 0.001200000056997.*ones(size(sub_ids_struct_out{ii}.flux.data)); sub_ids_struct_out_description{ii}.flux_data_error_upper = ['from fixed error value in case ' error_bar]; sub_ids_struct_out_description{ii}.flux_data_error_lower = ['not provided since symmetric']; %(not filled if symmetric) sub_ids_struct_out{ii}.flux.data_error_lower = 0.0012;%.*ones(size(sub_ids_struct_out{ii}.flux.data)); end + case 'delta_with_lower' + for ii=1:Nprobes + sub_ids_struct_out{ii}.flux.data_error_upper = 0.001200000056997.*ones(size(sub_ids_struct_out{ii}.flux.data)); + sub_ids_struct_out{ii}.flux.data_error_lower = sub_ids_struct_out{ii}.flux.data_error_upper; + sub_ids_struct_out_description{ii}.flux_data_error_upper = ['from fixed error value in case ' error_bar]; + sub_ids_struct_out_description{ii}.flux_data_error_lower = ['from fixed error value in case ' error_bar]; + %(not filled if symmetric) sub_ids_struct_out{ii}.flux.data_error_lower = 0.0012;%.*ones(size(sub_ids_struct_out{ii}.flux.data)); + end case 'added' for ii=1:Nprobes sub_ids_struct_out{ii}.flux_data_error_upper = sub_ids_struct_out{ii}.flux.data + 0.001200000056997.*ones(size(sub_ids_struct_out{ii}.flux.data)); diff --git a/crpptbx/TCV_IMAS/tcv_ids_ip.m b/crpptbx/TCV_IMAS/tcv_ids_ip.m index 90b3f003..e53f5322 100644 --- a/crpptbx/TCV_IMAS/tcv_ids_ip.m +++ b/crpptbx/TCV_IMAS/tcv_ids_ip.m @@ -5,8 +5,9 @@ function [ids_struct_out,ids_struct_out_description] = tcv_ids_ip(shot, ids_stru % Get magnetics.method{1}.ip % % error_bar: from gdat_params.error_bar -% 'relative' (default): value to be added -% 'added': value already added to data: data +- error_bar +% 'delta' (default): error_bar to be added inserted in "upper" only as mentioned in description +% 'delta_with_lower' : error_bar (abs) inserted in both lower and upper +% 'added': value already added to data: upper/lower = data +/- error_bar % error_bar = 'relative'; diff --git a/crpptbx/TCV_IMAS/tcv_ids_wall_description.m b/crpptbx/TCV_IMAS/tcv_ids_wall_description_2d.m similarity index 53% rename from crpptbx/TCV_IMAS/tcv_ids_wall_description.m rename to crpptbx/TCV_IMAS/tcv_ids_wall_description_2d.m index 80c403ca..ae069ced 100644 --- a/crpptbx/TCV_IMAS/tcv_ids_wall_description.m +++ b/crpptbx/TCV_IMAS/tcv_ids_wall_description_2d.m @@ -1,6 +1,5 @@ -function [ids_struct_out] = tcv_get_ids_descprition_2d(shot, ids_structures) +function [ids_struct_out,ids_struct_out_description] = tcv_ids_wall_description_2d(shot, ids_structures) -mdsopen(shot) %% r_l = mdsdata('STATIC("R_T")'); z_l = mdsdata('STATIC("Z_T")'); @@ -8,12 +7,12 @@ z_l = mdsdata('STATIC("Z_T")'); % There might be many 2d descriptions ids_struct_out = ids_structures; ids_struct_out{1}.limiter.unit{1}.outline.r = r_l; +ids_struct_out_description{1}.limiter.unit{1}.outline_r = ['from ''STATIC("R_T")']; ids_struct_out{1}.limiter.unit{1}.outline.z = z_l; +ids_struct_out_description{1}.limiter.unit{1}.outline_z = ['from ''STATIC("Z_T")']; %% TODO Add the other description of the wall and the input pharser -end - -- GitLab