diff --git a/matlab/TCV/gdat_tcv.m b/matlab/TCV/gdat_tcv.m index fda7a801c21e87218c88222b3a80b122f40a79a4..6f1d4ca357eae595f3045a08fa2bd732480e56f1 100644 --- a/matlab/TCV/gdat_tcv.m +++ b/matlab/TCV/gdat_tcv.m @@ -829,23 +829,29 @@ elseif strcmp(mapping_for_tcv.method,'switchcase') if strcmp(lower(gdat_data.gdat_params.source),'iphi') nodenameeff=['\magnetics::iphi']; tracetdi=tdi(nodenameeff); - gdat_data.data=192.E-07 * 0.996 *tracetdi.data/r0exp; + added_correction = 0.996; % correction already in liuqe.f + added_correction_str = ['96*mu0/2piR0 * ' num2str(added_correction) ' * ']; + gdat_data.data=192.E-07 * added_correction *tracetdi.data/r0exp; else if liuqe_matlab==0 + added_correction = 1.0; % correction already in liuqe.f + added_correction_str = ['']; nodenameeff = ['tcv_eq(''BZERO'',''LIUQE' substr_liuqe_tcv_eq ''')']; else if isempty(substr_liuqe); substr_liuqe = '_1'; end nodenameeff=['tcv_eq(''BZERO'',''LIUQE.M' substr_liuqe_tcv_eq ''')']; + added_correction = 0.996; % correction removed in liuqe.m at this stage + added_correction_str = [num2str(added_correction) ' * ']; end tracetdi=tdi(nodenameeff); - gdat_data.data = tracetdi.data; + gdat_data.data = tracetdi.data .* added_correction; end end if isempty(tracetdi.data) || isempty(tracetdi.dim) % || ischar(tracetdi.data) (to add?) if (gdat_params.nverbose>=1); warning(['problems loading data for ' nodenameeff ' for data_request= ' data_request_eff]); end return end - gdat_data.data_fullpath=[nodenameeff]; + gdat_data.data_fullpath=[added_correction_str nodenameeff]; gdat_data.dim = tracetdi.dim; gdat_data.t = gdat_data.dim{1}; if any(strcmp(fieldnames(tracetdi),'units')) @@ -862,7 +868,7 @@ elseif strcmp(mapping_for_tcv.method,'switchcase') end %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - case {'betan'} + case {'betan', 'beta_tor_norm'} % 100*beta / |Ip[MA] * B0[T]| * a[m] % get B0 from gdat_tcv, without re-opening the shot and using the same parameters except data_request % easily done thanks to structure call for options @@ -1260,9 +1266,49 @@ elseif strcmp(mapping_for_tcv.method,'switchcase') gdat_data.request_description = ['data=psi, x=(R,Z), eqdsk contains eqdsk structure with which ' ... 'plot_eqdsk, write_eqdsk, read_eqdsk can be used']; + %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + case {'gas', 'gas_flux', 'gas_request', 'gas_feedforward'} + params_eff = gdat_data.gdat_params; + params_eff.data_request = '\diagz::flux_gaz:piezo_1:flux'; + gasflux = gdat_tcv(gdat_data.shot,params_eff); + gdat_data.gas_flux = gasflux; + params_eff.data_request = '\hybrid::mat_m_signals:output_019'; + gasrequest = gdat_tcv(gdat_data.shot,params_eff); + gdat_data.gas_request_volt = gasrequest; + %volt_to_mlpers = max(0.,(in_volt-0.6879)*(72.41/(4.2673-0.6879)) + gdat_data.gas_request_flux = gasrequest; + gdat_data.gas_request_flux.data = max(0.,72.41.*(gasrequest.data-0.6879)./(4.2673-0.6879)); + gdat_data.gas_request_flux.units = gasflux.units; + params_eff.data_request = '\draw_feedfor_gas:alim_001'; + gasrequest_ref = gdat_tcv(gdat_data.shot,params_eff); gasrequest_ref.units = 'V'; + gdat_data.gas_feedforward_volt = gasrequest_ref; + gdat_data.gas_feedforward_flux = gasrequest_ref; + gdat_data.gas_feedforward_flux.data = max(0.,72.41.*(gasrequest_ref.data-0.6879)./(4.2673-0.6879)); + gdat_data.label = data_request_eff; + switch data_request_eff + case {'gas', 'gas_flux'} + gdat_data.data = gdat_data.gas_flux.data; + gdat_data.units = gdat_data.gas_flux.units; + gdat_data.t = gdat_data.gas_flux.t; + case {'gas_request'} + gdat_data.data = gdat_data.gas_request_volt.data; + gdat_data.units = gdat_data.gas_request_volt.units; + gdat_data.t = gdat_data.gas_request_volt.t; + case {'gas_feedforward'} + gdat_data.data = gdat_data.gas_feedforward_volt.data; + gdat_data.units = gdat_data.gas_feedforward_volt.units; + gdat_data.t = gdat_data.gas_feedforward_volt.t; + otherwise + error('gas option not defined') + end + gdat_data.dim{1} = gdat_data.t; + gdat_data.dimunits{1} = 's'; + if isfield(gdat_data.gdat_params,'time_out') && ~isempty(gdat_data.gdat_params.time_out) + [gdat_data] = gdat2time_out(gdat_data,1); + end + %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% case {'halphas'} - mapping.expression = '\base::pd:pd_001'; channels = [1:18]; if isfield(gdat_data.gdat_params,'channels') && ~isempty(gdat_data.gdat_params.channels) channels = gdat_data.gdat_params.channels; diff --git a/matlab/TCV/tcv_requests_mapping.m b/matlab/TCV/tcv_requests_mapping.m index 90f5c9e82c7ad5082dedbec20bdffc74fbe22f24..d010ce02c19c67d6c95d5b3de07b9638d2bab44c 100644 --- a/matlab/TCV/tcv_requests_mapping.m +++ b/matlab/TCV/tcv_requests_mapping.m @@ -69,18 +69,18 @@ switch lower(data_request) mapping.label = 'B_0'; mapping.method = 'switchcase'; mapping.expression = ''; - case 'beta' + case {'beta', 'beta_tor'} mapping.timedim = 1; mapping.label = '\beta'; mapping.method = 'tdiliuqe'; mapping.expression = '\results::beta_tor'; mapping.expression = 'tcv_eq(''''beta_tor'''',''''LIUQE.M'''')'; - case 'betan' + case {'betan', 'beta_tor_norm'} mapping.timedim = 1; mapping.label = '\beta_N'; mapping.method = 'switchcase'; mapping.expression = ''; - case 'betap' + case {'beta_pol', 'betap'} mapping.timedim = 1; mapping.label = '\beta_p'; mapping.method = 'tdiliuqe'; @@ -132,6 +132,11 @@ switch lower(data_request) mapping.timedim = 0; mapping.method = 'switchcase'; % could use function make_eqdsk directly? mapping.expression = ''; + case {'gas', 'gas_flux', 'gas_request', 'gas_feedforward'} + mapping.timedim = 1; + mapping.label = 'gas flux'; + mapping.method = 'switchcase'; + mapping.expression = ''; case 'halpha' mapping.timedim = 1; mapping.label = 'Halpha'; diff --git a/matlab/TCV_IMAS/tcv_get_ids_summary.m b/matlab/TCV_IMAS/tcv_get_ids_summary.m new file mode 100644 index 0000000000000000000000000000000000000000..0f543994d58054a57bc172c26f22c37dd82be2c9 --- /dev/null +++ b/matlab/TCV_IMAS/tcv_get_ids_summary.m @@ -0,0 +1,286 @@ +function [ids_summary,ids_summary_description,varargout] = tcv_get_ids_summary(shot,ids_equil_empty, gdat_params,varargin) +% +% [ids_summary,ids_summary_description,varargout] = tcv_get_ids_summary(shot,ids_equil_empty,varargin); +% +% +% gdat_params: gdat_data.gdat_params to get all params passed from original call, in particular error_bar and cocos_out options +% + +if exist('gdat_params','var') + [ids_summary, params_summary] = tcv_ids_headpart(shot,ids_equil_empty,'summary','gdat_params',gdat_params,varargin{:}); +else + [ids_summary, params_summary] = tcv_ids_headpart(shot,ids_equil_empty,'summary',varargin{:}); + aa=gdat_tcv; + gdat_params = aa.gdat_params; % to get default params +end + +% 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 +% +% vacuum_toroidal_field and time, using homogeneous +% +%% liuqe.m at this stage is missing correction 0.996, so use std source by time of default liuqe to make sure +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) + +% code description +[abcpath,abcfile,abcext]=fileparts(mfilename('fullpath')); +[aa1,aa2]=unix(['cd ' abcpath '; git describe --tags --first-parent --abbrev=11 --long --dirty --always']); +git_release_hash='gdat git hash not found'; +if aa1==0; git_release_hash = aa2(1:end-1); end % avoid newline +[aa1,aa2]=unix(['cd ' abcpath '; git config --get remote.origin.url']); +git_url = 'gdat git url not found'; +if aa1==0; git_url = aa2(1:end-1); end +ids_summary.code.name = 'gdat'; +ids_summary.code.version = git_release_hash; +ids_summary.code.repository = git_url; + +% use equilibrium time as reference, so load first elongation(time) + +params_eff = params_eff_ref; +params_eff.data_request='ip_trapeze'; +ip_trapeze = gdat(params_summary.shot,params_eff); +ipsign = mdsvalue('\pcs::data:iohfb'); +i_t_end = find(ipsign.*ip_trapeze.data(end:-1:1) > 5e3); % an offset might cause a problem... +i_t_end = length(ip_trapeze.t)-i_t_end(1)+2; +t_end = ip_trapeze.t(i_t_end); +b0sign = mdsvalue('\pcs::data:if36fb'); +params_eff = params_eff_ref; +params_eff.data_request='kappa'; +kappa = gdat(params_summary.shot,params_eff); +% to get liuqe time array for main time, but add points before and after according to ip_trapeze, to have other data when available +dt_caract = 1e-3; +ids_summary.time = unique([[0:dt_caract:kappa.t(1)]'; kappa.t; [kappa.t(end):dt_caract:t_end]']); +ids_summary_description.time = 'time from gdat(shot,''kappa'') and adding from 0 up to t(ip_trapeze(end))'; + +params_eff = params_eff_ref; +% boundary: +boundary.elongation = kappa; +boundary_desc.elongation = kappa.gdat_params.data_request; +params_eff.data_request = 'r_geom'; +boundary.geometric_axis_r = gdat(params_summary.shot,params_eff); +boundary_desc.geometric_axis_r = params_eff.data_request; +params_eff.data_request = 'z_geom'; +boundary.geometric_axis_z = gdat(params_summary.shot,params_eff); +boundary_desc.geometric_axis_z = params_eff.data_request; +params_eff.data_request = 'r_mag'; +boundary.magnetic_axis_r = gdat(params_summary.shot,params_eff); +boundary_desc.magnetic_axis_r = params_eff.data_request; +params_eff.data_request = 'z_mag'; +boundary.magnetic_axis_z = gdat(params_summary.shot,params_eff); +boundary_desc.magnetic_axis_z = params_eff.data_request; +params_eff.data_request = 'a_minor'; +boundary.minor_radius = gdat(params_summary.shot,params_eff); +boundary_desc.minor_radius = params_eff.data_request; +params_eff.data_request = 'delta_bottom'; +boundary.triangularity_lower = gdat(params_summary.shot,params_eff); +boundary_desc.triangularity_lower = params_eff.data_request; +params_eff.data_request = 'delta_top'; +boundary.triangularity_upper = gdat(params_summary.shot,params_eff); +boundary_desc.triangularity_upper = params_eff.data_request; +% $$$ params_eff.data_request = 'tcv_eq(''''n_xpts'''',''''liuqe.m'''')'; +% $$$ temp.n_x_point = gdat(params_summary.shot,params_eff); +% $$$ temp_desc.n_x_point = params_eff.data_request; +% $$$ params_eff.data_request = 'tcv_eq(''''r_xpts'''',''''liuqe.m'''')'; +% $$$ temp.r_x_point = gdat(params_summary.shot,params_eff); +% $$$ temp_desc.r_x_point = params_eff.data_request; +% $$$ params_eff.data_request = 'tcv_eq(''''z_xpts'''',''''liuqe.m'''')'; +% $$$ temp.z_x_point = gdat(params_summary.shot,params_eff); +% $$$ temp_desc.z_x_point = params_eff.data_request; + +boundary_fieldnames = fieldnames(boundary); +special_fields = {}; % fields needing non-automatic treatments +for i=1:numel(boundary_fieldnames) + if ~any(strcmp(boundary_fieldnames{i},special_fields)) + if ~isstruct(ids_summary.boundary.(boundary_fieldnames{i}).value) + ids_summary.boundary.(boundary_fieldnames{i}).value = boundary.(boundary_fieldnames{i}).data; + ids_summary.boundary.(boundary_fieldnames{i}).value = interp1(boundary.(boundary_fieldnames{i}).t, ... + boundary.(boundary_fieldnames{i}).data,ids_summary.time,'linear',NaN); + ids_summary.boundary.(boundary_fieldnames{i}).source = ['gdat request: ' boundary_desc.(boundary_fieldnames{i})]; + else + special_fields{end+1} = boundary_fieldnames{i}; + end + end +end + +% special case +if ~isempty(special_fields) +% $$$ for it=1:ntime +% $$$ ids_summary.time_slice{it}.boundary.magnetic_axis.r = temp.r_magnetic_axis.data(it); +% $$$ ids_summary.time_slice{it}.boundary.magnetic_axis.z = temp.z_magnetic_axis.data(it); +% $$$ ids_summary.time_slice{it}.boundary.psi_axis = temp.psi_axis.data(it) + ... +% $$$ ids_summary.time_slice{it}.boundary.psi_boundary; +% $$$ [zz,izz]=min(temp.q_rho.data(:,it)); +% $$$ ids_summary.time_slice{it}.boundary.q_min.value = zz; +% $$$ ids_summary.time_slice{it}.boundary.q_min.rho_tor_norm = temp.q_rho.grids_1d.rhotornorm(izz); +% $$$ end +end + +% disruption, use specific function +% to be decided if changes only ids_summary_out.disruption or also elsewhere..., if ids_summary_out.time is changed, +% then all the other data should be related, thus call this first? + +[ids_summary_out,ids_summary_out_description] = ids_summary_disruption(shot, ids_summary, gdat_params); + +% gas: bottom/top?, deuterium, helium_xx, ? +params_eff.data_request = 'gas_flux'; +gas_injection_rates.deuterium = gdat(params_summary.shot,params_eff); +gas_injection_rates_desc.deuterium = params_eff.data_request; + +gas_injection_rates_fieldnames = fieldnames(gas_injection_rates); +special_fields = {}; % fields needing non-automatic treatments +% assume all gas_injection_rates have same time base since called with same gdat_params for liuqe +for i=1:numel(gas_injection_rates_fieldnames) + if ~any(strcmp(gas_injection_rates_fieldnames{i},special_fields)) + if ~isstruct(ids_summary.gas_injection_rates.(gas_injection_rates_fieldnames{i}).value) + ids_summary.gas_injection_rates.(gas_injection_rates_fieldnames{i}).value = interp1( ... + gas_injection_rates.(gas_injection_rates_fieldnames{i}).t,gas_injection_rates.(gas_injection_rates_fieldnames{i}).data, ... + ids_summary.time,'linear',NaN); + ids_summary.gas_injection_rates.(gas_injection_rates_fieldnames{i}).source = ['gdat request: ' gas_injection_rates_desc.(gas_injection_rates_fieldnames{i})]; + else + special_fields{end+1} = gas_injection_rates_fieldnames{i}; + end + end +end +%params_eff.doplot=1; +% global_quantities: +params_eff.data_request = 'b0'; +global_quantities.b0 = gdat(params_summary.shot,params_eff); % do not add 'source','liuqe' to get all times +global_quantities_desc.b0 = [params_eff.data_request ' ; ' global_quantities.b0.data_fullpath]; +params_eff.data_request = 'beta_pol'; +global_quantities.beta_pol = gdat(params_summary.shot,params_eff); +global_quantities_desc.beta_pol = [params_eff.data_request ' ; ' global_quantities.beta_pol.data_fullpath]; +params_eff.data_request = 'beta_pol'; +global_quantities.beta_pol_mhd = gdat(params_summary.shot,params_eff); +global_quantities_desc.beta_pol_mhd = [params_eff.data_request ' ; ' global_quantities.beta_pol_mhd.data_fullpath]; +params_eff.data_request = 'beta_tor'; +global_quantities.beta_tor = gdat(params_summary.shot,params_eff); +global_quantities_desc.beta_tor = [params_eff.data_request ' ; ' global_quantities.beta_tor.data_fullpath]; +params_eff.data_request = 'beta_tor'; +global_quantities.beta_tor_mhd = gdat(params_summary.shot,params_eff); +global_quantities_desc.beta_tor_mhd = [params_eff.data_request ' ; ' global_quantities.beta_tor_mhd.data_fullpath]; +params_eff.data_request = 'betan'; +global_quantities.beta_tor_norm = gdat(params_summary.shot,params_eff); +global_quantities_desc.beta_tor_norm = [params_eff.data_request ' ; ' global_quantities.beta_tor_norm.data_fullpath]; +params_eff.data_request = 'betan'; +global_quantities.beta_tor_norm_mhd = gdat(params_summary.shot,params_eff); +global_quantities_desc.beta_tor_norm_mhd = [params_eff.data_request ' ; ' global_quantities.beta_tor_norm_mhd.data_fullpath]; +params_eff.data_request = 'betan'; +global_quantities.beta_tor_thermal_norm = gdat(params_summary.shot,params_eff); +global_quantities_desc.beta_tor_thermal_norm = [params_eff.data_request ' ; ' global_quantities.beta_tor_thermal_norm.data_fullpath]; +params_eff.data_request = '\tcv_shot::top.results.ibs:ibs'; +global_quantities.current_bootstrap = gdat(params_summary.shot,params_eff); +global_quantities_desc.current_bootstrap = [params_eff.data_request ' ; ' global_quantities.current_bootstrap.data_fullpath]; +params_eff.data_request = '\tcv_shot::top.results.ibs:icd'; +global_quantities.current_non_inductive = gdat(params_summary.shot,params_eff); +global_quantities_desc.current_non_inductive = [params_eff.data_request ' ; ' global_quantities.current_non_inductive.data_fullpath]; +params_eff.data_request = 'w_mhd'; +global_quantities.energy_diamagnetic = gdat(params_summary.shot,params_eff); +global_quantities_desc.energy_diamagnetic = [params_eff.data_request ' ; ' global_quantities.energy_diamagnetic.data_fullpath]; +params_eff.data_request = '\tcv_shot::top.results.conf:we'; +global_quantities.energy_electrons_thermal = gdat(params_summary.shot,params_eff); +global_quantities_desc.energy_electrons_thermal = [params_eff.data_request ' ; ' global_quantities.energy_electrons_thermal.data_fullpath]; +params_eff.data_request = '\tcv_shot::top.results.conf:wi'; +global_quantities.energy_ion_total_thermal = gdat(params_summary.shot,params_eff); +global_quantities_desc.energy_ion_total_thermal = [params_eff.data_request ' ; ' global_quantities.energy_ion_total_thermal.data_fullpath]; +params_eff.data_request = 'w_mhd'; +global_quantities.energy_mhd = gdat(params_summary.shot,params_eff); +global_quantities_desc.energy_mhd = [params_eff.data_request ' ; ' global_quantities.energy_mhd.data_fullpath]; +params_eff.data_request = '.conf:we + .conf:wi'; +global_quantities.energy_thermal = global_quantities.energy_electrons_thermal; +global_quantities.energy_thermal.data = global_quantities.energy_thermal.data + global_quantities.energy_ion_total_thermal.data; +global_quantities.energy_thermal.data_fullpath = [global_quantities.energy_thermal.data_fullpath ' + wi']; +global_quantities_desc.energy_thermal = [params_eff.data_request ' ; ' global_quantities.energy_thermal.data_fullpath]; +params_eff.data_request = 'ngf'; +global_quantities.greenwald_fraction = gdat(params_summary.shot,params_eff); +global_quantities_desc.greenwald_fraction = [params_eff.data_request ' ; ' global_quantities.greenwald_fraction.data_fullpath]; +params_eff.data_request = 'h98y2'; +global_quantities.h_98 = gdat(params_summary.shot,params_eff); +global_quantities_desc.h_98 = [params_eff.data_request ' ; ' global_quantities.h_98.data_fullpath]; +params_eff.data_request = 'ip'; +global_quantities.ip = gdat(params_summary.shot,params_eff); +global_quantities_desc.ip = [params_eff.data_request ' ; ' global_quantities.ip.data_fullpath]; +params_eff.data_request = 'li'; +global_quantities.li = gdat(params_summary.shot,params_eff); +global_quantities_desc.li = [params_eff.data_request ' ; ' global_quantities.li.data_fullpath]; +params_eff.data_request = '\tcv_shot::top.results.conf:ptot_ohm'; +global_quantities.power_ohm = gdat(params_summary.shot,params_eff); +global_quantities_desc.power_ohm = [params_eff.data_request ' ; ' global_quantities.power_ohm.data_fullpath]; +params_eff.data_request = '\results::bolo:prad:total'; +global_quantities.power_radiated = gdat(params_summary.shot,params_eff); +if strcmp(lower(global_quantities.power_radiated.units),'kw') + global_quantities.power_radiated.data = global_quantities.power_radiated.data*1e3; %in kW +end +global_quantities_desc.power_radiated = [params_eff.data_request ' ; ' global_quantities.power_radiated.data_fullpath]; +params_eff.data_request = 'q95'; +global_quantities.q_95 = gdat(params_summary.shot,params_eff); +global_quantities_desc.q_95 = [params_eff.data_request ' ; ' global_quantities.q_95.data_fullpath]; +params_eff.data_request = 'b0'; +global_quantities.b0 = gdat(params_summary.shot,params_eff); +global_quantities_desc.b0 = [params_eff.data_request ' ; ' global_quantities.b0.data_fullpath]; +params_eff.data_request = 'r0'; +global_quantities.r0 = global_quantities.b0; +global_quantities.r0.data = global_quantities.r0.r0; +global_quantities.r0.dim = [];global_quantities.r0.t=[]; global_quantities.r0.dimunits = []; +global_quantities.r0.units = 'm'; +global_quantities.r0.data_fullpath = ['gdat(b0).r0']; +global_quantities_desc.r0 = [params_eff.data_request ' ; ' global_quantities.r0.data_fullpath]; +% $$$ params_eff.data_request = 'tau_tot'; +% $$$ global_quantities.tau_energy = gdat(params_summary.shot,params_eff); +% $$$ global_quantities_desc.tau_energy = [params_eff.data_request ' ; ' global_quantities.tau_energy.data_fullpath]; +params_eff.data_request = 'vloop'; +global_quantities.v_loop = gdat(params_summary.shot,params_eff); +tensvloop=-1e3; +global_quantities.v_loop.data = interpos(global_quantities.v_loop.t,-global_quantities.v_loop.data,tensvloop); +global_quantities_desc.v_loop = [params_eff.data_request ' ; -1* interpos of ' global_quantities.v_loop.data_fullpath ... + ' with tens=' num2str(tensvloop)]; +params_eff.data_request = 'volume'; +global_quantities.volume = gdat(params_summary.shot,params_eff); +global_quantities_desc.volume = [params_eff.data_request ' ; ' global_quantities.volume.data_fullpath]; + +special_fields = {'r0'}; % fields needing non-automatic treatments +global_quantities_fieldnames = fieldnames(global_quantities); +for i=1:numel(global_quantities_fieldnames) + if ~any(strcmp(global_quantities_fieldnames{i},special_fields)) + if ~isstruct(ids_summary.global_quantities.(global_quantities_fieldnames{i}).value) + ids_summary.global_quantities.(global_quantities_fieldnames{i}).value = interp1( ... + global_quantities.(global_quantities_fieldnames{i}).t,global_quantities.(global_quantities_fieldnames{i}).data, ... + ids_summary.time,'linear',NaN); + ids_summary.global_quantities.(global_quantities_fieldnames{i}).source = ['gdat request: ' global_quantities_desc.(global_quantities_fieldnames{i})]; + else + special_fields{end+1} = global_quantities_fieldnames{i}; + end + end +end + +% special case +ids_summary.global_quantities.global_quantities.r0.value = global_quantities.r0.data; +ids_summary.global_quantities.global_quantities.r0.source = ['gdat request: ' global_quantities_desc.r0]; + +% cst zeff +params_eff.data_request = '\tcv_shot::top.results.ibs:z_eff'; +volume_average.zeff = gdat(params_summary.shot,params_eff); +volume_average_desc.zeff = [params_eff.data_request ' ; ' volume_average.zeff.data_fullpath ' (not vol avrg but to match Iohm)']; + +special_fields = {}; % fields needing non-automatic treatments +volume_average_fieldnames = fieldnames(volume_average); +for i=1:numel(volume_average_fieldnames) + if ~any(strcmp(volume_average_fieldnames{i},special_fields)) + if ~isstruct(ids_summary.volume_average.(volume_average_fieldnames{i}).value) + ids_summary.volume_average.(volume_average_fieldnames{i}).value = interp1( ... + volume_average.(volume_average_fieldnames{i}).t,volume_average.(volume_average_fieldnames{i}).data, ... + ids_summary.time,'linear',NaN); + ids_summary.volume_average.(volume_average_fieldnames{i}).source = ['gdat request: ' volume_average_desc.(volume_average_fieldnames{i})]; + else + special_fields{end+1} = volume_average_fieldnames{i}; + end + end +end + +% cocos automatic transform +if ~isempty(which('ids_generic_cocos_nodes_transformation_symbolic')) + [ids_summary,cocoscoeff]=ids_generic_cocos_nodes_transformation_symbolic(ids_summary,'summary',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_ids_headpart.m b/matlab/TCV_IMAS/tcv_ids_headpart.m index d1d45e6e5983132a9f3955a21d04363fa9a75cab..fa90b8cf836577146f499ba9cbe0ff7e2a53d311 100644 --- a/matlab/TCV_IMAS/tcv_ids_headpart.m +++ b/matlab/TCV_IMAS/tcv_ids_headpart.m @@ -53,25 +53,7 @@ ids_generic = ids_in; % ids_properties % subcall=''; -% $$$ if nargin>=5 && ~isempty(varargin) -% $$$ for i=1:length(varargin) -% $$$ if ~isempty(varargin{i}) -% $$$ if ischar(varargin{i}) -% $$$ subcall_add = [',' varargin{i}]; -% $$$ elseif isnumeric(varargin{i}) -% $$$ subcall_add = [',' num2str(varargin{i})]; -% $$$ elseif isstruct(varargin{i}) -% $$$ subcall_add = [',' 'struct_in']; -% $$$ elseif iscell(varargin{i}) -% $$$ subcall_add = [',' 'cell_in']; -% $$$ end -% $$$ else -% $$$ subcall_add = [',[]']; -% $$$ end -% $$$ subcall(end+1:end+length(subcall_add)) = subcall_add; -% $$$ end -% $$$ subcall(end+1:end+2) = '; '; -% $$$ end + ids_generic.ids_properties.comment = params_ids_generic.comment; if ~isempty(subcall) add_to_comment = ['varargin: ' subcall]; @@ -82,7 +64,13 @@ if ~isempty(subcall) end end -ids_generic.ids_properties.provider = ['tcv_get_ids_' ids_name]; +%get gdat version +[abcpath,abcfile,abcext]=fileparts(mfilename('fullpath')); +[aa1,aa2]=unix(['cd ' abcpath '; git describe --tags --first-parent --abbrev=11 --long --dirty --always']); +git_release_hash='gdat git hash not found'; +if aa1==0; git_release_hash = aa2(1:end-1); end % avoid newline + +ids_generic.ids_properties.provider = ['gdat_git: ' git_release_hash '; tcv_get_ids_' ids_name]; if ~isempty(params_ids_generic.gdat_params) if isfield(params_ids_generic.gdat_params,'cocos_in') && isfield(params_ids_generic.gdat_params,'cocos_out') comment_add = ['from TCV cocos_in=' num2str(params_ids_generic.gdat_params.cocos_in) ' transformed to cocos_out=' num2str(params_ids_generic.gdat_params.cocos_out)]; diff --git a/matlab/ids_summary_disruption.m b/matlab/ids_summary_disruption.m new file mode 100644 index 0000000000000000000000000000000000000000..bed33a8e8e2d3b064e67cf85e5b1266737117bc4 --- /dev/null +++ b/matlab/ids_summary_disruption.m @@ -0,0 +1,30 @@ +function [ids_summary_out,ids_summary_out_description] = ids_summary_disruption(shot, ids_summary_in, gdat_params, varargin) +% +% [ids_summary_out,ids_summary_out_description] = tcv_ids_ip(shot, ids_summary_in, gdat_params, varargin); +% +% fill in subnode "disruption" expected by ids_summary, for machine gdat_params.machine +% +% 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','var') && isfield(gdat_params,'error_bar') && ~isempty(gdat_params.error_bar) + error_bar = gdat_params.error_bar; +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) + +% Get data +switch lower(params_eff_ref.machine) + case 'tcv' + otherwise +end + +% Preallocate dimension +ids_summary_out = ids_summary_in; +ids_summary_out_description.disruption.time = 'time of disruption obtained from...to fill in description per subnode'; + +% Put data into ids structure