Newer
Older
function mapping = aug_requests_mapping(data_request)

Olivier Sauter
committed
%
% Information pre-defined for gdat_aug, you can add cases here to match official cases in gdat_aug, allowing backward compatibility
%
% Defaults
mapping = struct(...
'label', '', ...
'method', '', ...
'expression','', ...

Olivier Sauter
committed
'timedim', -1, ... % dim which is the time is the database, to copy in .t, the other dims are in .x (-1 means last dimension)
'gdat_timedim',[], ... % if need to reshape data and dim orders to have timedim as gdat_timedim (shifting time to gdat_timedim)

Olivier Sauter
committed
% Note that gdat_timedim is set to timedim at end of this function if empty
% gdat_timedim should have effective index of the time dimension in gdat
if ~exist('data_request') || isempty(data_request)
return
end
% default label: data_request keyword itself
mapping.label = data_request;
% for AUG, following choices are set so far:

Olivier Sauter
committed
% method = 'signal' then expression contains the shotfile, diagnostic and if needed the experiment
% expression is a cell array
% method = 'expression', then expression is the expression to return gdat_tmp...
% method = 'switchcase', then there will be a specific case within gdat_aug (usual case when not directly a signal)
%
% label is used for plotting

Olivier Sauter
committed
if iscell(data_request) % || (~ischar(data_request) && length(data_request)>1)
mapping.label = data_request;
mapping.method = 'signal'; % assume a full tracename is given, so just try with tdi (could check there are some ":", etc...)
mapping.expression = data_request;
mapping.gdat_timedim = mapping.timedim;
return
end

Olivier Sauter
committed
case 'a_minor'
mapping.timedim = 1;
mapping.label = 'a\_minor';
mapping.method = 'expression';
mapping.expression = ['params_eff = gdat_data.gdat_params;params_eff.data_request=''r_inboard'';' ...
'gdat_tmp=gdat_aug(shot,params_eff);gdat_tmp.r_inboard=gdat_tmp.data;' ...
'params_eff.data_request=''r_outboard'';' ...
'gdat_tmp2=gdat_aug(shot,params_eff);gdat_tmp.r_outboard=gdat_tmp2.data;' ...
'gdat_tmp.data = 0.5.*(gdat_tmp2.data-gdat_tmp.data);gdat_tmp.label=''' mapping.label ''';' ...
'gdat_tmp.gdat_request=''' data_request ''';'];

Olivier Sauter
committed
mapping.timedim = 1;

Olivier Sauter
committed
mapping.method = 'signal';
mapping.expression = [{'FPC'},{'BTF'}];
case 'beta'
mapping.timedim = 1;
mapping.label = '\beta';
mapping.method = 'signal';
mapping.expression = [{'TOT'},{'beta'}];
mapping.method = 'expression';
mapping.expression = ['params_eff = gdat_data.gdat_params;params_eff.data_request=''betan'';' ...
'gdat_tmp=gdat_aug(shot,params_eff);' ...
'params_eff.data_request=''ip'';gdat_tmp2=gdat_aug(shot,params_eff);' ...
'params_eff.data_request=''b0'';gdat_tmp3=gdat_aug(shot,params_eff);' ...
'params_eff.data_request=''a_minor'';gdat_tmp4=gdat_aug(shot,params_eff);' ...
'tmp_data_ip=interp1(gdat_tmp2.t,gdat_tmp2.data,gdat_tmp.t,[],NaN);' ...
'tmp_data_b0=interp1(gdat_tmp3.t,gdat_tmp3.data,gdat_tmp.t,[],NaN);' ...
'tmp_data_a=interp1(gdat_tmp4.t,gdat_tmp4.data,gdat_tmp.t,[],NaN);' ...
'gdat_tmp.data = 0.01.*abs(gdat_tmp.data.*tmp_data_ip./1e6./tmp_data_a./tmp_data_b0);' ...
'gdat_tmp.label=''' mapping.label ''';gdat_tmp.gdat_request=''' data_request ''';'];

Olivier Sauter
committed
mapping.timedim = 1;

Olivier Sauter
committed
mapping.method = 'signal';
mapping.expression = [{'TOT'},{'beta_N'}];

Olivier Sauter
committed
mapping.timedim = 1;

Olivier Sauter
committed
mapping.method = 'signal';
mapping.expression = [{'FPG'},{'betpol'}];

Olivier Sauter
committed
mapping.timedim = 2;
mapping.label = 'cxrs';
mapping.method = 'switchcase';
mapping.expression = '';
case 'delta'

Olivier Sauter
committed
mapping.timedim = 1;
mapping.label = 'delta';
mapping.method = 'expression';
mapping.expression = ['params_eff = gdat_data.gdat_params;params_eff.data_request=''delta_bottom''; ' ...
'gdat_tmp=gdat_aug(shot,params_eff);params_eff.data_request=''delta_top'';' ...
'gdat_tmp2=gdat_aug(shot,params_eff);gdat_tmp.data = 0.5.*(gdat_tmp.data+gdat_tmp2.data);'];
case 'delta_top'
mapping.label = 'delta\_top';

Olivier Sauter
committed
mapping.timedim = 1;
mapping.method = 'signal';
mapping.expression = [{'FPG'},{'delRoben'}];
case 'delta_bottom'
mapping.label = 'delta\_bottom';

Olivier Sauter
committed
mapping.timedim = 1;
mapping.method = 'signal';
mapping.expression = [{'FPG'},{'delRuntn'}];
case {'ece', 'eced', 'ece_rho', 'eced_rho'}

Olivier Sauter
committed
mapping.timedim = 2;
mapping.method = 'switchcase';
mapping.expression = '';
case 'eqdsk'

Olivier Sauter
committed
mapping.timedim = 2;
mapping.method = 'switchcase'; % could use function make_eqdsk directly?
mapping.expression = '';
case 'equil'
mapping.gdat_timedim = 2;
mapping.method = 'switchcase'; % could use function make_eqdsk directly?
mapping.expression = '';
case 'halpha'

Olivier Sauter
committed
mapping.timedim = 1;

Olivier Sauter
committed
mapping.method = 'signal';
mapping.expression = [{'POT'},{'ELMa-Han'}];

Olivier Sauter
committed
mapping.timedim = 1;

Olivier Sauter
committed
mapping.method = 'signal';
mapping.expression = [{'MBI'},{'IOH'}];

Olivier Sauter
committed
mapping.timedim = 1;

Olivier Sauter
committed
mapping.method = 'signal';
mapping.expression = [{'MAG'},{'Ipa'}];

Olivier Sauter
committed
mapping.label = '\kappa';
mapping.method = 'signal';
mapping.expression = [{'FPG'},{'k'}];

Olivier Sauter
committed
mapping.timedim = 1;
mapping.label = 'n=1,2, etc';
mapping.method = 'switchcase';
mapping.expression = '';
case 'ne'

Olivier Sauter
committed
mapping.timedim = 2;
mapping.method = 'switchcase';
case 'neint'

Olivier Sauter
committed
mapping.timedim = 1;
mapping.label = 'line integrated el. density';

Olivier Sauter
committed
mapping.method = 'signal';
mapping.expression = [{'DCN'},{'H-1'},{'AUGD'}];

Olivier Sauter
committed
mapping.timedim = 1;
mapping.label = 'line-averaged el. density';

Olivier Sauter
committed
mapping.expression = [{'FPG'},{'lenH-1'},{'AUGD'}];
mapping.method = 'expression';
mapping.expression = ['params_eff = gdat_data.gdat_params;params_eff.data_request=''neint'';' ...
'gdat_tmp=gdat_aug(shot,params_eff);params_eff.data_request=[{''FPG''},{''lenH-1''},{''AUGD''}];' ...
'gdat_tmp2=gdat_aug(shot,params_eff);ij=find(gdat_tmp2.data==0);gdat_tmp2.data(ij)=NaN;' ...
'tmp_data=interp1(gdat_tmp2.t,gdat_tmp2.data,gdat_tmp.t,[],NaN);' ...
'gdat_tmp.data = gdat_tmp.data./(tmp_data+1e-5);'];
case 'ne_rho'
mapping.timedim = 2;
mapping.label = 'ne';
mapping.method = 'switchcase';
case 'nete_rho'
mapping.timedim = 2;
mapping.label = 'ne and Te';
mapping.method = 'switchcase';
case 'ni'
mapping.method = 'switchcase'; % especially since might have option fit, etc
case 'powers'
mapping.label = 'various powers';
mapping.method = 'switchcase';
case 'q0'

Olivier Sauter
committed
mapping.timedim = 1;
mapping.label = 'q_0';
mapping.method = 'signal';
mapping.expression = [{'FPG'},{'q0'},{'AUGD'}];

Olivier Sauter
committed
mapping.timedim = 1;
mapping.label = 'q_{95}';
mapping.method = 'signal';
mapping.expression = [{'FPG'},{'q95'},{'AUGD'}];
case 'q_edge'
mapping.timedim = 1;
mapping.label = 'q_{edge}}';
mapping.method = 'expression';
mapping.method = 'switchcase';
mapping.expression = [{'FPG'},{'q95'},{'AUGD'}];
mapping.expression = [];
case 'q_rho'
mapping.timedim = 2;
mapping.gdat_timedim = 2;
mapping.label = 'q';
mapping.method = 'switchcase';
case 'rgeom'
mapping.label = 'Rgeom';

Olivier Sauter
committed
mapping.timedim = 1;
mapping.method = 'expression';
mapping.expression = ['params_eff = gdat_data.gdat_params;params_eff.data_request=''r_inboard'';' ...
'gdat_tmp=gdat_aug(shot,params_eff);gdat_tmp.r_inboard=gdat_tmp.data;' ...
'params_eff.data_request=''r_outboard'';' ...
'gdat_tmp2=gdat_aug(shot,params_eff);gdat_tmp.r_outboard=gdat_tmp2.data;' ...
'gdat_tmp.data = 0.5.*(gdat_tmp2.data+gdat_tmp.data);gdat_tmp.label=''' mapping.label ''';' ...
'gdat_tmp.gdat_request=''' data_request ''';'];
case 'r_inboard'
mapping.label = 'R\_inboard';
mapping.timedim = 1;
mapping.method = 'signal';
mapping.expression = [{'FPG'},{'Rin'},{'AUGD'}];
case 'r_outboard'
mapping.label = 'R\_outboard';
mapping.timedim = 1;
mapping.method = 'signal';
mapping.expression = [{'FPG'},{'Raus'},{'AUGD'}];
case 'rhovol'
mapping.label = 'rhovol\_norm';
mapping.method = 'switchcase'; % from conf if exist otherwise computes it
case 'rmag'
mapping.label = 'R\_magaxis';

Olivier Sauter
committed
mapping.timedim = 1;
mapping.method = 'signal';
mapping.expression = [{'FPG'},{'Rmag'},{'AUGD'}];
mapping.timedim = 1;

Olivier Sauter
committed
mapping.gdat_timedim = 2;
mapping.method = 'switchcase';
case 'te'
mapping.label = 'Te';
mapping.method = 'switchcase';

Olivier Sauter
committed
case 'te_rho'
mapping.label = 'Te';
mapping.method = 'switchcase';
case 'ti'
mapping.label = 'Ti';
mapping.method = 'switchcase';
case 'vloop'

Olivier Sauter
committed
mapping.label = 'Vloop';
mapping.timedim = 1;
% mapping.method = 'signal';
% mapping.expression = [{'MAG'},{'ULid12'},{'AUGD'}];
mapping.method = 'expression';
mapping.expression = ['params_eff = gdat_data.gdat_params;params_eff.data_request=[{''MAG''},{''ULid12''},{''AUGD''}];' ...
'gdat_tmp=gdat_aug(shot,params_eff);ij=find(~isnan(gdat_tmp.data));' ...
'tmp_data=interpos(gdat_tmp.t,gdat_tmp.data,-3e4);' ...
'gdat_tmp.data_smooth = tmp_data;gdat_tmp.gdat_request=''vloop'';gdat_tmp.gdat_params.data_request=gdat_tmp.gdat_request;'];
case 'volume'

Olivier Sauter
committed
mapping.timedim = 1;
mapping.method = 'signal';
mapping.expression = [{'FPG'},{'Vol'},{'AUGD'}];

Olivier Sauter
committed
mapping.label = 'zeff from cxrs';
mapping.timedim = 1;
mapping.method = 'signal';
mapping.expression = [{'ZES'},{'Zeff'},{'AUGD'}];
case 'zgeom'
mapping.label = 'Zgeom';

Olivier Sauter
committed
mapping.timedim = 1;
mapping.method = 'expression';
mapping.expression = ['params_eff = gdat_data.gdat_params;params_eff.data_request=[{''FPG''},{''Zoben''},{''AUGD''}];' ...
'gdat_tmp=gdat_aug(shot,params_eff);gdat_tmp.z_top=gdat_tmp.data;' ...
'params_eff.data_request=[{''FPG''},{''Zunt''},{''AUGD''}];' ...
'gdat_tmp2=gdat_aug(shot,params_eff);gdat_tmp.z_bottom=gdat_tmp2.data;' ...
'gdat_tmp.data = 0.5.*(gdat_tmp2.data+gdat_tmp.data);gdat_tmp.label=''' mapping.label ''';' ...
'gdat_tmp.gdat_request=''' data_request ''';'];

Olivier Sauter
committed
mapping.label = 'Z\_magaxis';
mapping.timedim = 1;
mapping.method = 'signal';
mapping.expression = [{'FPG'},{'Zmag'},{'AUGD'}];
%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% extra AUG cases (not necessarily in official data_request name list)
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
case 'transp'
mapping.label = 'transp output';
mapping.method = 'switchcase';
otherwise
mapping.label = data_request;

Olivier Sauter
committed
mapping.method = 'signal'; % assume a full tracename is given, so just try with tdi (could check there are some ":", etc...)
mapping.expression = data_request;
end

Olivier Sauter
committed
if isempty(mapping.gdat_timedim)
mapping.gdat_timedim = mapping.timedim;
end