diff --git a/crpptbx_new/TCV/gdat_tcv.m b/crpptbx_new/TCV/gdat_tcv.m index 44155bf37c046e692e0a457b31dfe884858f7607..7740a261aca0cc019e17140ffc8c2fe06fb87724 100644 --- a/crpptbx_new/TCV/gdat_tcv.m +++ b/crpptbx_new/TCV/gdat_tcv.m @@ -65,6 +65,7 @@ default_machine = 'tcv'; gdat_params.machine=default_machine; gdat_params.doplot = 0; +gdat_params.liuqe = 1; % construct list of keywords from global set of keywords and specific TCV set % get data_request names from centralized function @@ -226,6 +227,15 @@ shot = gdat_data.shot; data_request_eff = gdat_data.gdat_params.data_request; error_status = 6; % at least reached this level +liuqe_version = 1; +if isfield(gdat_data.gdat_params,'liuqe') && ~isempty(gdat_data.gdat_params.liuqe) + liuqe_version = gdat_data.gdat_params.liuqe; +end +substr_liuqe = ''; +if liuqe_version==2 || liuqe_version==3 + substr_liuqe = ['_' num2str(liuqe_version)]; +end + %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % Specifications on how to get the data provided in tcv_requests_mapping @@ -243,26 +253,32 @@ if do_mdsopen_mdsclose end %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -% 1st treat the simplest method: "tdi" -if strcmp(mapping_for_tcv.method,'tdi') +% 1st treat the simplest method: "tdi" (and tdiliuqe) +if strcmp(mapping_for_tcv.method(1:3),'tdi') % need to treat liuqe2, model, etc from options.... + substr_tdi = ''; + if strcmp(mapping_for_tcv.method,'tdiliuqe'); substr_tdi = substr_liuqe; end if iscell(mapping_for_tcv.expression) if length(mapping_for_tcv.expression)>0 % series of arguments for tdi given in each cell - eval_expr = ['aatmp=tdi(''' mapping_for_tcv.expression{1} '''']; + eval_expr = ['tdi(''' mapping_for_tcv.expression{1} substr_tdi '''']; for i=2:length(mapping_for_tcv.expression) eval_expr = [eval_expr ',''' mapping_for_tcv.expression{i} '''']; end eval_expr = [eval_expr ');']; - eval(eval_expr); + aatmp = eval(eval_expr); else % empty or wrong expression error_status=701; return end else - eval_expr = ['aatmp=tdi(''' mapping_for_tcv.expression ''');']; - eval(eval_expr); + eval_expr = ['tdi(''' mapping_for_tcv.expression substr_tdi ''');']; + aatmp=eval(eval_expr); + end + if isempty(aatmp.data) || isempty(aatmp.dim) % || ischar(aatmp.data) (to add?) + warning(['problems loading data for ' eval_expr ' for data_request= ' data_request_eff]) + return end gdat_data.data = aatmp.data; gdat_data.dim = aatmp.dim; @@ -305,7 +321,8 @@ if strcmp(mapping_for_tcv.method,'tdi') gdat_data.dim = aatmp.dim(inew); gdat_data.dimunits = aatmp.dimunits(inew); end - gdat_data.data_fullpath=mapping_for_tcv.expression; + gdat_data.data_fullpath=[mapping_for_tcv.expression substr_tdi]; + % end of method "tdi" %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% @@ -313,10 +330,10 @@ elseif strcmp(mapping_for_tcv.method,'function') % 2nd: method="function" % assume expression contains function to call and which returns a structure % we copy the structure, to make sure default nodes are defined and to avoid if return is an closed object like tdi - eval_expr = ['aatmp=' mapping_for_tcv.expression ';']; - eval(eval_expr); + % eval_expr = ['aatmp=' mapping_for_tcv.expression ';']; + aatmp = eval(mapping_for_tcv.expression); if isempty(aatmp) || (~isstruct(aatmp) & ~isobject(aatmp)) - warning(['function expression does not return a structure: ' eval_expr]) + warning(['function expression does not return a structure: ' mapping_for_tcv.expression]) error_status=801; return end @@ -359,6 +376,78 @@ elseif strcmp(mapping_for_tcv.method,'function') %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% elseif strcmp(mapping_for_tcv.method,'switchcase') switch data_request_eff % not lower(...) since data_request_eff should be lower case already at this stage + % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + % First the request names valid for "all" machines: + % + case {'a_minor'} + nodenameeff=['\results::r_max_psi' substr_liuqe]; + rmaxpsi=tdi(nodenameeff); + nodenameeff2=['\results::r_min_psi' substr_liuqe]; + rminpsi=tdi(nodenameeff2); + ij=find(rmaxpsi.data<0.5 | rmaxpsi.data>1.2); + if ~isempty(ij); rmaxpsi.data(ij)=NaN; end + ij=find(rminpsi.data<0.5 | rminpsi.data>1.2); + if ~isempty(ij); rminpsi.data(ij)=NaN; end + gdat_data.data=0.5.*(rmaxpsi.data(end,:) - rminpsi.data(end,:)); + gdat_data.data_fullpath=[nodenameeff ' - ' nodenameeff2 ' /2']; + gdat_data.dim = rmaxpsi.dim(2); + gdat_data.t = gdat_data.dim{1}; + if any(strcmp(fieldnames(rmaxpsi),'units')) + gdat_data.units = rmaxpsi.units; + end + gdat_data.dimunits = rmaxpsi.dimunits(2); + + case {'b0'} + % B0 at R0=0.88 + R0EXP=0.88; + if liuqe_version==-1 + mdsopen( 'pcs', shot); %synthetic shot generated with FBT and MGAMS. + nodenameeff = 'tcv_eq("BZERO","FBTE")'; + tracetdi=tdi(nodenameeff); + gdat_data.data = tracetdi.data; + else + nodenameeff=['\magnetics::iphi']; + tracetdi=tdi(nodenameeff); + gdat_data.data=192.E-07 * 0.996 *tracetdi.data/R0EXP; + end + gdat_data.data_fullpath=[nodenameeff]; + gdat_data.dim = tracetdi.dim; + gdat_data.t = gdat_data.dim{1}; + if any(strcmp(fieldnames(tracetdi),'units')) + gdat_data.units = tracetdi.units; + end + gdat_data.dimunits = tracetdi.dimunits; + gdat_data.request_description = ['vacuum magnetic field at R0=' num2str(R0EXP) 'm']; + + case {'betan'} + % 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 + params_eff = gdat_data.gdat_params; + params_eff.data_request='b0'; + b0=gdat_tcv([],params_eff); + params_eff.data_request='ip'; + ip=gdat_tcv([],params_eff); + params_eff.data_request='beta'; + beta=gdat_tcv([],params_eff); + params_eff.data_request='a_minor'; + a_minor=gdat_tcv([],params_eff); + + nodenameeff = '\results::'; + if liuqe_version==2 || liuqe_version==3 + nodenameeff=['\magnetics::iphi']; + tracetdi=tdi(nodenameeff); + gdat_data.data=192.E-07 * 0.996 *tracetdi.data/R0EXP; + end + gdat_data.data_fullpath=[nodenameeff]; + gdat_data.dim = tracetdi.dim; + gdat_data.t = gdat_data.dim{1}; + if any(strcmp(fieldnames(tracetdi),'units')) + gdat_data.units = tracetdi.units; + end + gdat_data.dimunits = tracetdi.dimunits; + gdat_data.request_description = ['vacuum magnetic field at R0=' num2str(R0EXP) 'm']; + case {'ne','te'} % ne or Te from Thomson data on raw z mesh vs (z,t) mdsopen(shot); @@ -399,7 +488,6 @@ elseif strcmp(mapping_for_tcv.method,'switchcase') if any(strcmp(fieldnames(tracetdi),'units')) gdat_data.units=tracetdi.units; end - case 'nerho' diff --git a/crpptbx_new/TCV/tcv_requests_mapping.m b/crpptbx_new/TCV/tcv_requests_mapping.m index f2e3c7e1d5ac05731bc1dac90dfd21e70bc7ecb1..435b02ae4a27479304ed5a83161d0fcd791ddb31 100644 --- a/crpptbx_new/TCV/tcv_requests_mapping.m +++ b/crpptbx_new/TCV/tcv_requests_mapping.m @@ -20,39 +20,48 @@ mapping.label = data_request; % for TCV, following choices are set so far: % method = 'tdi' and then expression is the string within tdi (usual case when there is a direct link to an existing signal) % with tdi, if expression cell array, call tdi(cell{1},cell{2},...) -% method = 'function', then expression is the funtion to call which should return the correct structure +% method = 'tdiliuqe': same as tdi but adds "_2" or "_3" if 'liuqe',2 or 3 is asked for in options +% method = 'function', then expression is the funtion to call which should return a structure, which fields are copied to gdat_data % method = 'switchcase', then there will be a specific case within gdat_tcv (usual case when not directly a signal) % % label is used for plotting switch lower(data_request) + case 'a_minor' + mapping.label = 'a(LCFS)'; + mapping.method = 'switchcase'; + mapping.expression = ''; case 'b0' mapping.label = 'B_0'; mapping.method = 'switchcase'; mapping.expression = ''; + case 'beta' + mapping.label = '\beta'; + mapping.method = 'tdiliuqe'; + mapping.expression = '\results::beta_tor'; case 'betan' mapping.label = '\beta_N'; mapping.method = 'switchcase'; mapping.expression = ''; case 'betap' mapping.label = '\beta_p'; - mapping.method = 'tdi'; + mapping.method = 'tdiliuqe'; mapping.expression = '\results::beta_pol'; case 'cxrs' mapping.label = 'cxrs'; mapping.method = 'switchcase'; mapping.expression = ''; case 'delta' - mapping.method = 'tdi'; + mapping.method = 'tdiliuqe'; mapping.expression = '\results::delta_edge'; - mapping.method = 'function'; - mapping.expression = ['tdi(''\results::q_psi'');']; + % mapping.method = 'function'; + % mapping.expression = ['tdi(''\results::q_psi'');']; % for tests case 'delta_top' mapping.label = 'delta\_top'; - mapping.method = 'tdi'; + mapping.method = 'tdiliuqe'; mapping.expression = '\results::delta_ed_top'; case 'delta_bottom' mapping.label = 'delta\_bottom'; - mapping.method = 'tdi'; + mapping.method = 'tdiliuqe'; mapping.expression = '\results::delta_ed_bot'; case 'ece' mapping.method = 'switchcase'; @@ -73,7 +82,7 @@ switch lower(data_request) mapping.method = 'tdi'; mapping.expression = '\magnetics::iplasma:trapeze'; case 'kappa' - mapping.method = 'tdi'; + mapping.method = 'tdiliuqe'; mapping.expression = '\results::kappa_edge'; case 'mhd' mapping.label = 'n=1,2, etc'; @@ -101,13 +110,13 @@ switch lower(data_request) mapping.label = 'various powers'; mapping.method = 'switchcase'; case 'q0' - mapping.method = 'tdi'; + mapping.method = 'tdiliuqe'; mapping.expression = '\results::q_zero'; case 'q95' - mapping.method = 'tdi'; + mapping.method = 'tdiliuqe'; mapping.expression = '\results::q_95'; case 'qedge' - mapping.method = 'tdi'; + mapping.method = 'tdiliuqe'; mapping.expression = '\results::q_edge'; case 'qrho' mapping.label = 'q'; @@ -120,7 +129,7 @@ switch lower(data_request) mapping.method = 'switchcase'; % from conf if exist otherwise computes it case 'rmag' mapping.label = 'R\_magaxis'; - mapping.method = 'tdi'; + mapping.method = 'tdiliuqe'; mapping.expression = '\results::r_axis'; case 'sxr' mapping.method = 'switchcase'; @@ -153,7 +162,7 @@ switch lower(data_request) mapping.method = 'switchcase'; case 'zmag' mapping.label = 'Zmagaxis'; - mapping.method = 'tdi'; + mapping.method = 'tdiliuqe'; mapping.expression = '\results::z_axis'; % $$$ case '' % $$$ mapping.label = ''; diff --git a/crpptbx_new/gdat_data_request_names.xlsx b/crpptbx_new/gdat_data_request_names.xlsx index 419bf48dcfa4eec850ba8aefc48338caf2044112..a064c20cd7b818eae5f9a3929fd74b5aba1243f9 100644 Binary files a/crpptbx_new/gdat_data_request_names.xlsx and b/crpptbx_new/gdat_data_request_names.xlsx differ diff --git a/crpptbx_new/gdat_plot.m b/crpptbx_new/gdat_plot.m index 67e315b12f2e1d955883debe1b29483489b32abc..02c616e88bd508ecd80afec3aea57fb760650944 100644 --- a/crpptbx_new/gdat_plot.m +++ b/crpptbx_new/gdat_plot.m @@ -1,12 +1,34 @@ -function [fighandle]=gdat_plot(gdat_data); +function [fighandle]=gdat_plot(gdat_data,varargin); % +% choices from doplot in gdat_data.gdat_params.doplot: +% doplot = 0: no plot +% = 1: new figure created +% = -1: add to current figure (with hold all) +% > 1: create new figure with this number, adding clf +% <-1: add to figure number abs(doplot) (with hold all) % +if ~isfield(gdat_data.gdat_params,'doplot') || gdat_data.gdat_params.doplot ==0 + return +end + +fighandle = get(0,'CurrentFigure'); -fighandle = figure; if prod(isfield(gdat_data,{'data','t'})) && ~isempty(gdat_data.data) && ~isempty(gdat_data.t) + if gdat_data.gdat_params.doplot == 1 + fighandle = figure; + elseif gdat_data.gdat_params.doplot > 1 + fighandle = figure(gdat_data.gdat_params.doplot); + clf; + elseif gdat_data.gdat_params.doplot == -1 + hold all + elseif gdat_data.gdat_params.doplot < -1 + fighandle = figure(abs(gdat_data.gdat_params.doplot)); + hold all + end plot(gdat_data.t,gdat_data.data); title([gdat_data.gdat_params.machine ' #' num2str(gdat_data.shot)]); ylabel(gdat_data.label); + zoom on; else disp('cannot plot gdat_data, has empty data or t field') end