From d5b869fa21db5ec229e4fb5c56776a42a123c38d Mon Sep 17 00:00:00 2001
From: Olivier Sauter <olivier.sauter@epfl.ch>
Date: Thu, 12 Sep 2024 13:53:49 +0200
Subject: [PATCH] add correct traces, refs to check

---
 matlab/TCV/gdat_tcv.m | 39 ++++++++++++++++++++++++++-------------
 1 file changed, 26 insertions(+), 13 deletions(-)

diff --git a/matlab/TCV/gdat_tcv.m b/matlab/TCV/gdat_tcv.m
index a0e28176..5d9df8d1 100644
--- a/matlab/TCV/gdat_tcv.m
+++ b/matlab/TCV/gdat_tcv.m
@@ -1358,21 +1358,34 @@ elseif strcmp(mapping_for_tcv.method,'switchcase')
         end
       end
      case {'gas_fluxes'}
-       for i=1:20
-         if shot < 78667
-           params_eff.data_request = sprintf('\\draw_feedfor_gas:alim_0%.2d',i);
-         else
-           params_eff.data_request = sprintf('\\draw_refs_gas:ref_0%.2d',i)
-         end
-         gasrequest_ref = gdat_tcv(gdat_data.shot,params_eff); gasrequest_ref.units = 'V';
-         gdat_data_data{i} = gasrequest_ref.data;
-         if ~isempty(gasrequest_ref.t)
-           gdat_data.units = gasrequest_ref.units;
-           gdat_data.t = gasrequest_ref.t;
-           gdat_data.data_fullpath = gasrequest_ref.data_fullpath;
+       try
+         if shot > 82186
+           for i=1:20
+             params_eff.data_request = sprintf('\\draw_refs_gas:ref_0%.2d',i);
+             try
+               gasrequest_ref = gdat_tcv(gdat_data.shot,params_eff);
+               gdat_data_data_refs{i}.data = gasrequest_ref.data;
+               gdat_data_data_refs{i}.t = gasrequest_ref.t;
+               gdat_data_data_refs{i}.data_fullpath = gasrequest_ref.data_fullpath;
+             catch
+               gdat_data_data_refs{i}.data = [];
+               gdat_data_data_refs{i}.t = [];
+               gdat_data_data_refs{i}.data_fullpath = params_eff.data_request;
+             end
+             params_eff.data_request = sprintf('\\atlas::top.system.gas.valve_0%.2d:flow',i);
+             gasrequest = gdat_tcv(gdat_data.shot,params_eff); gasrequest.units = 'V';
+             gdat_data_data{i} = gasrequest.data;
+             if ~isempty(gasrequest.t)
+               gdat_data.units = gasrequest.units;
+               gdat_data.t = gasrequest.t;
+               gdat_data.data_fullpath = gasrequest.data_fullpath;
+             end
+           end
+           gdat_data.data = gdat_data_data;
+           gdat_data.data_refs = gdat_data_data_refs;
          end
+       catch
        end
-       gdat_data.data = gdat_data_data;
      otherwise
       error('gas option not defined')
     end
-- 
GitLab