diff --git a/crpptbx/TCV/gdat_tcv.m b/crpptbx/TCV/gdat_tcv.m index 0c02f70198c4b1d0a3a52d699ae998d28cb92875..671d1f625877e7b7b5bfc0f41173348fedeb75ea 100644 --- a/crpptbx/TCV/gdat_tcv.m +++ b/crpptbx/TCV/gdat_tcv.m @@ -1120,6 +1120,9 @@ elseif strcmp(mapping_for_tcv.method,'switchcase') else ids_empty = ids_gen(ids_top_name); end + if ~isfield(gdat_data.gdat_params,'error_bar') || isempty(gdat_data.gdat_params.error_bar) + gdat_data.gdat_params.error_bar = 'delta'; + end try if ~isempty(shot) [ids_top,ids_top_description] = feval(['tcv_get_ids_' ids_top_name],shot,ids_empty,gdat_data.gdat_params); @@ -1130,11 +1133,11 @@ elseif strcmp(mapping_for_tcv.method,'switchcase') 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) = ids_empty; gdat_data.([ids_top_name '_description']) = getReport(ME_tcv_get_ids); + rethrow(ME_tcv_get_ids) end %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% diff --git a/crpptbx/TCV/tcv_help_parameters.m b/crpptbx/TCV/tcv_help_parameters.m index db22c4ebb7cd51caf11b25d1dc1b7f226370c921..670d22938c2a33f460029e8b4ba1fff91bd2b692 100644 --- a/crpptbx/TCV/tcv_help_parameters.m +++ b/crpptbx/TCV/tcv_help_parameters.m @@ -44,9 +44,14 @@ help_struct_all.source = sprintf('%s\n','cxrs: [1 2 3] (default systems);', ... 'mhd request: ''23'':23 LFS/HFS (default), ''23full'': 23cm sector 3 and 11, ''0'':z=0 LFS/HFS, ''0full'': 0cm sector 3 and 11', ... 'powers: ohmic in any case + ''ec'', ''nbi'', ''rad'' ', ... 'rtc: defined, all, adcs', ... - 'icds: ''ec'', ''nbi'' '); + 'icds: ''ec'', ''nbi'' ', ... + 'ids_names for request ''ids'' like magnetics, equilibrium, etc'); help_struct_all.source_ec = sprintf('%s\n','toray (for toray nodes), no other source for eccd yet implemented'); help_struct_all.source_nbi = sprintf('%s\n','nbi_output_matfilename containing out structure, to be added astra nodes'); +help_struct_all.error_bar = sprintf('%s\n','for ids: choice of nodes fill in and how:', ... + '''delta'' (default): only upper fill in with the abs(value) to add or subtract to data to get upper and lower values (symmetric)', ... + '''delta_with_lower'': same as delta but fill in lower node as well (with delta as well, same as upper)', ... + '''added'': add the delta values (old cpo style), so upper=data+error_bar and lower=data+error_bar'); help_struct_all.camera = ['sxr: for MPX: ''central'', ''top'' (default), ''bottom'' or ''both'' ; ' ... ' for XTOMO: ''central'' (a central chord only), defaults if empty, [1 3 5] if only camera 1, 3 and 5 are desired']; help_struct_all.freq = '''slow'', default, lower sampling; ''fast'' full samples for both mpx and xtomo'; diff --git a/crpptbx/TCV_IMAS/tcv_get_ids_core_profiles.m b/crpptbx/TCV_IMAS/tcv_get_ids_core_profiles.m index 647a05eb592e85a81265adb78f33047a9ee5688f..f76fe53cc9203fe586555064bcdba07f469f59ec 100644 --- a/crpptbx/TCV_IMAS/tcv_get_ids_core_profiles.m +++ b/crpptbx/TCV_IMAS/tcv_get_ids_core_profiles.m @@ -5,6 +5,17 @@ function [ids_cores_profiles,ids_cores_profiles_description,varargout] = tcv_get % % gdat_params: gdat_data.gdat_params to get all params passed from original call, in particular error_bar options % +% +% error_bar: from gdat_params.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 = 'delta'; +if exist('gdat_params') && isfield(gdat_params,'error_bar') && ~isempty(gdat_params.error_bar) + error_bar = gdat_params.error_bar; +end machine = 'tcv'; tens_time = -1; @@ -23,7 +34,6 @@ temp_1d.fit.te_rho.shot = temp_1d.te_rho.shot; temp_1d.fit.te_rho = get_grids_1d(temp_1d.fit.te_rho,1,1); temp_1d.fit.ne_rho = temp_1d.ne_rho.fit; - ids_cores_profiles.time = temp_1d.te_rho.fit.t; ids_cores_profiles_description.time = ['.t subfield from: [''te_rho'',''subnode'',''fit.t''] thus from ' temp_1d.te_rho.fit.data_fullpath]; @@ -74,6 +84,8 @@ global_quantities_desc.beta_pol = 'betap'; global_quantities.energy_diamagnetic = gdat(params_cores_profiles.shot,'w_mhd','machine',machine); global_quantities_desc.energy_diamagnetic = 'w_mhd'; +ids_cores_profiles_description.global_quantities = global_quantities_desc; + global_quantities_fieldnames = fieldnames(global_quantities); special_fields = {''}; % fields needing non-automatic treatments for i=1:length(global_quantities_fieldnames) @@ -113,13 +125,11 @@ for it=1:length(ids_cores_profiles.time) ids_cores_profiles.profiles_1d{it}.time = ids_cores_profiles.time(it); ids_cores_profiles.profiles_1d{it}.electrons.temperature = temp_1d.fit.te_rho.data(:,it); ids_cores_profiles.profiles_1d{it}.electrons.temperature_fit.measured = temp_1d.te_rho.data(:,it_thom(it)); - ids_cores_profiles.profiles_1d{it}.electrons.temperature_fit.measured_error_upper = temp_1d.te_rho.error_bar(:,it_thom(it)); ids_cores_profiles.profiles_1d{it}.electrons.temperature_fit.time_measurement = temp_1d.te_rho.t(it_thom(it)); ids_cores_profiles.profiles_1d{it}.electrons.temperature_fit.rho_tor_norm = temp_1d.te_rho.grids_1d.rhotornorm(:,it_thom(it)); ids_cores_profiles.profiles_1d{it}.electrons.temperature_fit.source = {'Thomson, interpos fit'}; ids_cores_profiles.profiles_1d{it}.electrons.density = temp_1d.fit.ne_rho.data(:,it); ids_cores_profiles.profiles_1d{it}.electrons.density_fit.measured = temp_1d.ne_rho.data(:,it_thom(it)); - ids_cores_profiles.profiles_1d{it}.electrons.density_fit.measured_error_upper = temp_1d.ne_rho.error_bar(:,it_thom(it)); ids_cores_profiles.profiles_1d{it}.electrons.density_fit.time_measurement = temp_1d.ne_rho.t(it_thom(it)); ids_cores_profiles.profiles_1d{it}.electrons.density_fit.rho_tor_norm = temp_1d.ne_rho.grids_1d.rhotornorm(:,it_thom(it)); ids_cores_profiles.profiles_1d{it}.electrons.density_fit.source = {'Thomson, interpos fit'}; @@ -127,6 +137,40 @@ for it=1:length(ids_cores_profiles.time) .* ids_cores_profiles.profiles_1d{it}.electrons.temperature; end +switch error_bar + case 'delta' + for it=1:length(ids_cores_profiles.time) + ids_cores_profiles.profiles_1d{it}.electrons.temperature_fit.measured_error_upper = temp_1d.te_rho.error_bar(:,it_thom(it)); + ids_cores_profiles.profiles_1d{it}.electrons.density_fit.measured_error_upper = temp_1d.ne_rho.error_bar(:,it_thom(it)); + end + case 'delta_with_lower' + for it=1:length(ids_cores_profiles.time) + ids_cores_profiles.profiles_1d{it}.electrons.temperature_fit.measured_error_upper = temp_1d.te_rho.error_bar(:,it_thom(it)); + ids_cores_profiles.profiles_1d{it}.electrons.temperature_fit.measured_error_lower = ... + ids_cores_profiles.profiles_1d{it}.electrons.temperature_fit.measured_error_upper; + ids_cores_profiles.profiles_1d{it}.electrons.density_fit.measured_error_upper = temp_1d.ne_rho.error_bar(:,it_thom(it)); + ids_cores_profiles.profiles_1d{it}.electrons.density_fit.measured_error_lower = ... + ids_cores_profiles.profiles_1d{it}.electrons.density_fit.measured_error_upper; + end + case 'added' + for it=1:length(ids_cores_profiles.time) + ids_cores_profiles.profiles_1d{it}.electrons.temperature_fit.measured_error_upper = ... + ids_cores_profiles.profiles_1d{it}.electrons.temperature_fit.measured ... + + temp_1d.te_rho.error_bar(:,it_thom(it)); + ids_cores_profiles.profiles_1d{it}.electrons.temperature_fit.measured_error_lower = ... + ids_cores_profiles.profiles_1d{it}.electrons.temperature_fit.measured ... + - temp_1d.te_rho.error_bar(:,it_thom(it)); + ids_cores_profiles.profiles_1d{it}.electrons.density_fit.measured_error_upper = ... + ids_cores_profiles.profiles_1d{it}.electrons.density_fit.measured ... + + temp_1d.te_rho.error_bar(:,it_thom(it)); + ids_cores_profiles.profiles_1d{it}.electrons.density_fit.measured_error_lower = ... + ids_cores_profiles.profiles_1d{it}.electrons.density_fit.measured ... + - temp_1d.te_rho.error_bar(:,it_thom(it)); + end + otherwise + error(['tcv_ids_bpol_loop: error_bar option not known: ' error_bar]) +end + % ion, assume only D if no CXRS (need to ask how to check if H...) temp_1d.cxrs_rho = gdat(params_cores_profiles.shot,'cxrs','machine',machine,'fit',1); temp_1d.ti_conf_rho = gdat(params_cores_profiles.shot,'results.conf:ti','machine',machine,'fit',1); diff --git a/crpptbx/TCV_IMAS/tcv_ids_ip.m b/crpptbx/TCV_IMAS/tcv_ids_ip.m index b6210a3520d0a278b561df96d4296795f86611c0..147398034f84422ccc0e0cf7cbd62352bd03fee1 100644 --- a/crpptbx/TCV_IMAS/tcv_ids_ip.m +++ b/crpptbx/TCV_IMAS/tcv_ids_ip.m @@ -10,7 +10,7 @@ function [ids_struct_out,ids_struct_out_description] = tcv_ids_ip(shot, ids_stru % '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 @@ -19,7 +19,7 @@ end tmp = gdat_tcv( shot, 'ip_trapeze'); time = tmp.dim{1}; data = tmp.data; -tmpdml = gdat_tcv( shot, '\results::dmlcore'); +tmpdml = gdat_tcv( shot, '\results::dmlcor'); % Preallocate dimension ids_struct_out = ids_structures; @@ -31,7 +31,7 @@ ids_struct_out{1}.ip.time = time; ids_struct_out{1}.diamagnetic_flux.data = tmpdml.data; ids_struct_out_description{1}.diamagnetic_flux = ['from ' tmpdml.data_fullpath]; -ids_struct_out{1}.diamagnetic_flux.time = tmpdml.time; +ids_struct_out{1}.diamagnetic_flux.time = tmpdml.t; fixed_error_ip = 2.4e3; fixed_error_diamagnetic_flux = 0.1; diff --git a/crpptbx/gdat.m b/crpptbx/gdat.m index 45798f79e4409921b68de68279dfa1a2061370ef..15c07947db62df3a9aceed694da1332506ee45e3 100644 --- a/crpptbx/gdat.m +++ b/crpptbx/gdat.m @@ -195,7 +195,7 @@ catch ME_gdat if ~exist('gdat_params','var'); gdat_params.plot = []; end if ~exist('error_status','var'); error_status = 998; end if exist('ME_gdat','var') - getReport(ME_gdat) + rethrow(ME_gdat) end return end @@ -219,5 +219,5 @@ if gdat_data.gdat_params.doplot end if exist('ME_gdat_plot','var') - getReport(ME_gdat_plot) + rethrow(ME_gdat_plot) end diff --git a/crpptbx/gdat_plot.m b/crpptbx/gdat_plot.m index 5b16e5f268ab956a5d015d838cd37f8dd8bf0789..e50819bf8bf96fa805012fff11478a57c86e81b0 100644 --- a/crpptbx/gdat_plot.m +++ b/crpptbx/gdat_plot.m @@ -74,7 +74,7 @@ if all(isfield(gdat_data,{'data','t'})) && ~isempty(gdat_data.data) && ~isempty( catch ME if exist('ME','var') disp('Problem in gdat_plot') - getReport(ME) + rethrow(ME) end return end diff --git a/crpptbx/test_all_requestnames.m b/crpptbx/test_all_requestnames.m index 0a733e1d05b6180594fb123049b1c1381b51c033..67b6df9113991aa0b1281d70fba5326d3809b96a 100644 --- a/crpptbx/test_all_requestnames.m +++ b/crpptbx/test_all_requestnames.m @@ -146,9 +146,9 @@ tic try [gdat_result,~,err] = eval(gdat_call); catch ME - warning('Caught matlab error. Report:\n\n%s',getReport(ME,'extended')); err = -1; gdat_result.data = []; + rethrow(ME,'extended'); end telaps = toc; % elapsed time