diff --git a/crpptbx/AUG/aug_requests_mapping.m b/crpptbx/AUG/aug_requests_mapping.m index e92eeaa3edab890fb700b782f3a722d338c3e25f..b3f424b29f81c5aa1a88d4db4308d976a36e98d9 100644 --- a/crpptbx/AUG/aug_requests_mapping.m +++ b/crpptbx/AUG/aug_requests_mapping.m @@ -216,6 +216,8 @@ switch lower(data_request) mapping.method = 'signal'; mapping.expression = [{'FPG'},{'Rmag'},{'AUGD'}]; case 'sxr' + mapping.timedim = 2; + mapping.gdat_timedim = 2; mapping.method = 'switchcase'; case 'te' mapping.label = 'Te'; diff --git a/crpptbx/AUG/gdat_aug.m b/crpptbx/AUG/gdat_aug.m index eb2bf0cc8071e21ae72fee1d7a68bb6345d16cd9..ccdbe90314f78e247082e1956b7cb838813033a0 100644 --- a/crpptbx/AUG/gdat_aug.m +++ b/crpptbx/AUG/gdat_aug.m @@ -33,9 +33,11 @@ function [gdat_data,gdat_params,error_status,varargout] = gdat_aug(shot,data_req % gdat_data.machine: machine providing the data % gdat_data.gdat_request: keyword for gdat if relevant % gdat_data.data_fullpath: full path to the data node if known and relevant, or relevant expression called if relevant -% gdat_data.gdat_params: copy gdat_params for completeness +% gdat_data.gdat_params: copy gdat_params for completeness (gdat_params contains a .help structure detailing each parameter) % gdat_data.xxx: any other relevant information % +% gdat_params contains the options relevant for the called data_request. It also contains a help structure for each option +% eg.: param1 in gdat_params.param1 and help in gdat_params.help.param1 % % Examples: % (should add working examples for various machines (provides working shot numbers for each machine...)) @@ -58,9 +60,8 @@ function [gdat_data,gdat_params,error_status,varargout] = gdat_aug(shot,data_req varargout{1}=cell(1,1); error_status=1; -nverbose = 1; -% construct default parameters structure +% construct main default parameters structure gdat_params.data_request = ''; default_machine = 'aug'; @@ -68,6 +69,7 @@ gdat_params.machine=default_machine; gdat_params.doplot = 0; gdat_params.exp_name = 'AUGD'; gdat_params.equil = 'EQI'; +gdat_params.nverbose = 1; % construct list of keywords from global set of keywords and specific AUG set % get data_request names from centralized table @@ -107,6 +109,9 @@ data_request_eff = ''; if nargin>=2 && ischar(data_request); data_request = lower(data_request); end gdat_data.gdat_request = data_request_names_all; % so if return early gives list of possible request names +gdat_data.gdat_params.help = aug_help_parameters(fieldnames(gdat_data.gdat_params)); +gdat_params = gdat_data.gdat_params; + % no inputs if nargin==0 % return defaults and list of keywords @@ -127,7 +132,7 @@ if nargin>=1 elseif ischar(shot) ivarargin_first_char = 1; else - warning('type of 1st argument unexpected, should be numeric or char') + if gdat_params.nverbose>=1; warning('type of 1st argument unexpected, should be numeric or char'); end error_status=2; return end @@ -144,7 +149,7 @@ if nargin>=2 && ivarargin_first_char~=1 % 2nd arg can be a structure with all options except shot_number, or a string for the pathname or keyword, or the start of pairs string/value for the parameters if isstruct(data_request) if ~isfield(data_request,'data_request') - warning('expects field data_request in input parameters structure') + if gdat_params.nverbose>=1; warning('expects field data_request in input parameters structure'); end error_status=3; return end @@ -190,13 +195,13 @@ if (nargin>=ivarargin_first_char) gdat_params.(lower(varargin_eff{i})) = varargin_eff{i+1}; end else - warning(['input argument nb: ' num2str(i) ' is incorrect, expects a character string']) + if gdat_params.nverbose>=1; warning(['input argument nb: ' num2str(i) ' is incorrect, expects a character string']); end error_status=401; return end end else - warning('number of input arguments incorrect, cannot make pairs of parameters') + if gdat_params.nverbose>=1; warning('number of input arguments incorrect, cannot make pairs of parameters'); end error_status=402; return end @@ -259,7 +264,7 @@ if strcmp(mapping_for_aug.method,'signal') gdat_data.gdat_params.exp_name = exp_location; [aatmp,error_status]=rdaAUG_eff(shot,mapping_for_aug.expression{1},mapping_for_aug.expression{2},exp_location); if error_status~=0 - if nverbose>=3; disp(['error after rdaAUG in signal with data_request_eff= ' data_request_eff]); end + if gdat_params.nverbose>=3; disp(['error after rdaAUG in signal with data_request_eff= ' data_request_eff]); end return end gdat_data.data = aatmp.data; @@ -327,6 +332,8 @@ if strcmp(mapping_for_aug.method,'signal') end gdat_data.dim = aatmp.dim(inew); % gdat_data.dimunits = aatmp.dimunits(inew); + else + mapping_for_aug.gdat_timedim = mapping_for_aug.timedim; end gdat_data.data_fullpath=mapping_for_aug.expression; % end of method "signal" @@ -334,18 +341,18 @@ if strcmp(mapping_for_aug.method,'signal') %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% elseif strcmp(mapping_for_aug.method,'expression') % 2nd: method="expression" - % assume expression contains an expression to evaluate and which cretaes a local structure into variable gdat_tmp + % assume expression contains an expression to evaluate and which creates a local structure into variable gdat_tmp % we copy the structure, to make sure default nodes are defined and to avoid if return is an closed object like tdi % eval_expr = [mapping_for_aug.expression ';']; eval([mapping_for_aug.expression ';']); if isempty(gdat_tmp) || (~isstruct(gdat_tmp) & ~isobject(gdat_tmp)) - warning(['expression does not create a gdat_tmp structure: ' mapping_for_aug.expression]) + if (gdat_params.nverbose>=1); warning(['expression does not create a gdat_tmp structure: ' mapping_for_aug.expression]); end error_status=801; return end tmp_fieldnames = fieldnames(gdat_tmp); if sum(strcmp(tmp_fieldnames,'data'))==0 % note: cannot do isfield since gdat_tmp might be an object - warning(['expression does not return a child name ''data'' for ' data_request_eff]) + if (gdat_params.nverbose>=1); warning(['expression does not return a child name ''data'' for ' data_request_eff]); end end for i=1:length(tmp_fieldnames) gdat_data.(tmp_fieldnames{i}) = gdat_tmp.(tmp_fieldnames{i}); @@ -404,7 +411,7 @@ elseif strcmp(mapping_for_aug.method,'switchcase') % vrot [a,error_status]=rdaAUG_eff(shot,diag_name,'vrot',exp_name_eff); if isempty(a.data) || isempty(a.t) || error_status>0 - if nverbose>=3; + if gdat_params.nverbose>=3; a disp(['with data_request= ' data_request_eff]) end @@ -434,7 +441,7 @@ elseif strcmp(mapping_for_aug.method,'switchcase') params_equil.data_request = 'equil'; [equil,params_equil,error_status] = gdat_aug(shot,params_equil); if error_status>0 - if nverbose>=3; disp(['problems with ' params_equil.data_request]); end + if gdat_params.nverbose>=3; disp(['problems with ' params_equil.data_request]); end return end gdat_data.gdat_params.equil = params_equil.equil; @@ -563,7 +570,7 @@ elseif strcmp(mapping_for_aug.method,'switchcase') params_equil.data_request = 'equil'; [equil,params_equil,error_status] = gdat_aug(shot,params_equil); if error_status>0 - if nverbose>=3; disp(['problems with ' params_equil.data_request]); end + if gdat_params.nverbose>=3; disp(['problems with ' params_equil.data_request]); end return end gdat_data.gdat_params.equil = params_equil.equil; @@ -631,7 +638,7 @@ elseif strcmp(mapping_for_aug.method,'switchcase') params_equil.data_request = 'equil'; [equil,params_equil,error_status] = gdat_aug(shot,params_equil); if error_status>0 - if nverbose>=3; disp(['problems with ' params_equil.data_request]); end + if gdat_params.nverbose>=3; disp(['problems with ' params_equil.data_request]); end return end gdat_data.gdat_params = params_equil; @@ -698,9 +705,9 @@ elseif strcmp(mapping_for_aug.method,'switchcase') % It seems the first NTIME points are correct, so use this explicitely NTIME_Lpf = length(Lpf_par.value); if (NTIME < NTIME_Lpf) - if nverbose>=3; disp('WARNING: nb of times points smaller then equil results, use first NTIME points'); end + if gdat_params.nverbose>=3; disp('WARNING: nb of times points smaller then equil results, use first NTIME points'); end elseif (NTIME > NTIME_Lpf) - if nverbose >= 1 + if gdat_params.nverbose >= 1 disp('ERROR: nb of times points LARGER then equil results') disp('this is unexpected, so stop there and ask Olivier.Sauter@epfl.ch') end @@ -887,7 +894,7 @@ elseif strcmp(mapping_for_aug.method,'switchcase') node_child_nameeff = [upper(data_request_eff(1)) 'e_core']; [a,error_status]=rdaAUG_eff(shot,'VTA',nodenameeff,exp_name_eff); if isempty(a.data) || isempty(a.t) || error_status>0 - if nverbose>=3; + if gdat_params.nverbose>=3; a disp(['with data_request= ' data_request_eff]) end @@ -951,14 +958,14 @@ elseif strcmp(mapping_for_aug.method,'switchcase') % get raw data [gdat_data,params_kin,error_status]=gdat_aug(shot,params_eff); if error_status>0 - if nverbose>=3; disp(['problems with ' params_eff.data_request]); end + if gdat_params.nverbose>=3; disp(['problems with ' params_eff.data_request]); end return end % add rho coordinates params_eff.data_request='equil'; [equil,params_equil,error_status]=gdat_aug(shot,params_eff); if error_status>0 - if nverbose>=3; disp(['problems with ' params_eff.data_request]); end + if gdat_params.nverbose>=3; disp(['problems with ' params_eff.data_request]); end return end gdat_data.gdat_params.equil = params_equil.equil; @@ -1032,19 +1039,138 @@ elseif strcmp(mapping_for_aug.method,'switchcase') gdat_data.dimunits{1} = 'rhopsinorm'; gdat_data.data_fullpath = [gdat_data.data_fullpath ' projected on equilibrium ' gdat_data.gdat_params.equil]; + %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + case {'sxr'} + % sxr from B by default or else if 'source','else' is provided + if ~isfield(gdat_data.gdat_params,'freq')|| isempty(gdat_data.gdat_params.freq) + gdat_data.gdat_params.freq = 'slow'; + end + if ~isfield(gdat_data.gdat_params,'source') || isempty(gdat_data.gdat_params.source) + gdat_data.gdat_params.source = 'G'; + elseif length(gdat_data.gdat_params.source)>1 || ... + upper(gdat_data.gdat_params.source)<'F' || upper(gdat_data.gdat_params.source)>'M' + if gdat_data.gdat_params.nverbose>=1 + warning(['source = ' gdat_data.gdat_params.source ' not expected with data_request= ' data_request_eff]) + end + return + end + dim1_len = 'from_chord_nb'; % thus up to max(chords_ok_nb) + if ~isfield(gdat_data.gdat_params,'camera') || isempty(gdat_data.gdat_params.camera) + gdat_data.gdat_params.camera = []; + elseif ischar(gdat_data.gdat_params.camera) && strcmp(gdat_data.gdat_params.camera,'central') + gdat_data.gdat_params.source = 'J'; + gdat_data.gdat_params.camera = 49; + elseif isnumeric(gdat_data.gdat_params.camera) + % ok keep the array, but first dim to contain just the related chords + dim1_len='nb_of_chords'; + else + if gdat_data.gdat_params.nverbose>=1 + warning(['camera = ' gdat_data.gdat_params.camera ' not expected with data_request= ' data_request_eff]) + end + return + end + if length(gdat_data.gdat_params.camera)==1; dim1_len='nb_of_chords'; end + gdat_data.gdat_params.source = upper(gdat_data.gdat_params.source); + % + if ~isfield(gdat_data.gdat_params,'time_interval') + gdat_data.gdat_params.time_interval = []; + end + [aa,bb]=unix(['ssh ' 'sxaug22.aug.ipp.mpg.de WhichSX ' num2str(shot) ' ' ... + upper(gdat_data.gdat_params.source)]); + chords_ok_diags=regexpi(bb,'(?<chord>[A-Z]_[0-9]+)\saddress:\s[0-9]+\sDiag:\s(?<diag>[A-Z]+)','names'); + for i=1:length(chords_ok_diags) + chords_ok_nb(i) = str2num(chords_ok_diags(i).chord(3:end)); + end + if isempty(gdat_data.gdat_params.camera); + gdat_data.gdat_params.camera = chords_ok_nb; + else + for i=1:length(gdat_data.gdat_params.camera) + ij=find(chords_ok_nb==gdat_data.gdat_params.camera(i)); + if ~isempty(ij) + chords_ok_diags_tmp(i) = chords_ok_diags(ij); + else + % chord not in use + chords_ok_diags_tmp(i).chord = []; + chords_ok_diags_tmp(i).diag = []; + end + end + chords_ok_diags = chords_ok_diags_tmp; + chords_ok_nb = gdat_data.gdat_params.camera; + end + exp_name_eff = 'AUGD'; + icount = 0; + nnth = 1; + if isnumeric(gdat_data.gdat_params.freq) && gdat_data.gdat_params.freq>1; + nnth = floor(gdat_data.gdat_params.freq+0.5); + gdat_data.gdat_params.freq = nnth; + end + for i=1:length(gdat_data.gdat_params.camera) + if ischar(gdat_data.gdat_params.freq) && strcmp(gdat_data.gdat_params.freq,'slow'); chords_ok_diags(i).diag = 'SSX'; end + if ~isempty(chords_ok_diags(i).diag) && ~isempty(chords_ok_diags(i).chord) + [a,e]=rdaAUG_eff(shot,chords_ok_diags(i).diag,chords_ok_diags(i).chord,exp_name_eff,gdat_data.gdat_params.time_interval); + else + a.data = []; + a.t = []; + end + if ~isempty(a.data) + icount = icount + 1; + if icount == 1 + % first time has data + % assume all chords have same time base even if from different shotfile + % time missing one point + if length(a.value) == length(a.t)+1 + a.t=linspace(a.range(1),a.range(2),length(a.value)); + a_time.index(2) = length(a.value); + end + gdat_data.t = a.t(1:nnth:end); + gdat_data.units = a.units; + if strcmp(dim1_len,'from_chord_nb') + gdat_data.data = NaN*ones(max(chords_ok_nb),length(gdat_data.t)); + gdat_data.dim{1} = [1:max(chords_ok_nb)]; % simpler to have index corresponding to chord number, except for central + else + gdat_data.data = NaN*ones(length(chords_ok_nb),length(gdat_data.t)); + gdat_data.dim{1} = chords_ok_nb; + end + gdat_data.dim{2} = gdat_data.t; + gdat_data.dimunits = [{'chord nb'}; {'s'}]; + gdat_data.data_fullpath = ['sxr from source=''' gdat_data.gdat_params.source ' uses shotfiles SX' ... + setdiff(unique(strvcat(chords_ok_diags(:).diag)),'SX')']; + gdat_data.label = ['SXR/' upper(gdat_data.gdat_params.source)]; + end + try + if strcmp(dim1_len,'from_chord_nb') + gdat_data.data(chords_ok_nb(i),:) = a.data(1:nnth:end); + else + gdat_data.data(i,:) = a.data(1:nnth:end); + end + catch + if (gdat_params.nverbose>=1); disp(['problem with ' chords_ok_diags(i).diag ' ; ' chords_ok_diags(i).chord]); end + + end + else + % add fields not yet defined in case all cases have empty data + end + end + gdat_data.chords = chords_ok_nb; + if length(gdat_data.dim)>=1 + gdat_data.x = gdat_data.dim{1}; + end + otherwise - warning(['switchcase= ' data_request_eff ' not known in gdat_aug']) + if (gdat_params.nverbose>=1); warning(['switchcase= ' data_request_eff ' not known in gdat_aug']); end error_status=901; return end else - warning(['AUG method=' mapping_for_aug.method ' not known yet, contact Olivier.Sauter@epfl.ch']) + if (gdat_params.nverbose>=1); warning(['AUG method=' mapping_for_AUG.method ' not known yet, contact Olivier.Sauter@epfl.ch']); end error_status=602; return end -gdat_data.mapping_for_aug = mapping_for_aug; +gdat_data.gdat_params.help = aug_help_parameters(fieldnames(gdat_data.gdat_params)); +gdat_data.mapping_for.aug = mapping_for_aug; +gdat_params = gdat_data.gdat_params; error_status=0; return diff --git a/crpptbx/TCV/gdat_tcv.m b/crpptbx/TCV/gdat_tcv.m index 5dec42a3ecf7ce3d117cff409233e47d647694ef..1ad7e662b7bcb4d3d269edd6dd3d009392838423 100644 --- a/crpptbx/TCV/gdat_tcv.m +++ b/crpptbx/TCV/gdat_tcv.m @@ -1281,7 +1281,7 @@ elseif strcmp(mapping_for_tcv.method,'switchcase') gdat_data.data_request = data_request_eff; gdat_data.gdat_params.source = 'mpx'; end - % sxr from Xtomo by default or dmpx if 'camera','dmpx' is provided + % sxr from dmpx by default or xtomo if 'camera','xtomo' is provided if ~isfield(gdat_data.gdat_params,'source') || isempty(gdat_data.gdat_params.source) gdat_data.gdat_params.source = 'mpx'; elseif ~strcmp(lower(gdat_data.gdat_params.source),'xtomo') && ~strcmp(lower(gdat_data.gdat_params.source),'mpx')