From 967ec20bfa7c5953b9e87b819bfad34240473f58 Mon Sep 17 00:00:00 2001
From: Olivier Sauter <olivier.sauter@epfl.ch>
Date: Wed, 12 Jun 2024 07:49:17 +0200
Subject: [PATCH] add pattern in source option for rtc

---
 matlab/TCV/gdat_tcv.m            | 9 ++++++++-
 matlab/TCV/tcv_help_parameters.m | 3 ++-
 2 files changed, 10 insertions(+), 2 deletions(-)

diff --git a/matlab/TCV/gdat_tcv.m b/matlab/TCV/gdat_tcv.m
index deae6b52..5f2b74c2 100644
--- a/matlab/TCV/gdat_tcv.m
+++ b/matlab/TCV/gdat_tcv.m
@@ -3284,6 +3284,13 @@ elseif strcmp(mapping_for_tcv.method,'switchcase')
     %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    case {'rtc'}
     % load all real-time memory signals for various nodes
+    if ~isfield(gdat_data.gdat_params,'source')
+      gdat_data.gdat_params.source = {'Actuator_state','plasma_state','samone_out'};
+    else
+      if ischar(gdat_data.gdat_params.source) || isstring(gdat_data.gdat_params.source)
+        gdat_data.gdat_params.source = {char(gdat_data.gdat_params.source)};
+      end
+    end
 
     %Get the data from mds and fill the data structure defined by
     %define_simulink_signals
@@ -3296,7 +3303,7 @@ elseif strcmp(mapping_for_tcv.method,'switchcase')
       error('no path for get_scd_mems')
     end
 
-    aa = get_scd_mems(shot);
+    aa = get_scd_mems(shot,gdat_data.gdat_params.source);
     if isstruct(aa)
       scd_names = fieldnames(aa);
       for i=1:length(scd_names)
diff --git a/matlab/TCV/tcv_help_parameters.m b/matlab/TCV/tcv_help_parameters.m
index 2c6c74c0..bc9ec8b9 100644
--- a/matlab/TCV/tcv_help_parameters.m
+++ b/matlab/TCV/tcv_help_parameters.m
@@ -45,7 +45,7 @@ help_struct_all.source = sprintf('%s\n','cxrs: [1 2 3] (default systems);', ...
           'sxr: main source: ''MPX'' (default) or ''XTOMO'', case insensitive', ...
           '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', ...
+          'rtc: defines which pattern(s) to search for (default: {''Actuator_state'',''plasma_state'',''samone_out''}, empty to have all', ...
           'transp: source provides the netcdf file', ...
           'icds: ''ec'', ''nbi'' ', ...
           'ids_names: for request ''ids'' like magnetics, equilibrium, etc', ...
@@ -63,6 +63,7 @@ help_struct_all.max_adcs = 'rtc: source=''adcs'' maximum nb of adc channels load
 help_struct_all.nfft = '512 (default) changes time resolution in spectrogram in gdat_plot for ''mhd'' request';
 help_struct_all.map_eqdsk_psirz = 'eqdsk: if time array provided, maps all psi(R,Z,t) on same R,Zmesh in .data (1) or not (0, default)';
 help_struct_all.write = 'eqdsk: write eqdsk while loading data (1, default) or not (0)';
+help_struct_all.rtc = 'load data from mems saved by SCD system (if on for that shot), source defines what to search for';
 %help_struct_all. = '';
 
 
-- 
GitLab