From 9691787e71bd15a144666a08ccddee2659d87c3e Mon Sep 17 00:00:00 2001
From: Luke Simons <luke.simons@epfl.ch>
Date: Thu, 13 Mar 2025 11:25:46 +0100
Subject: [PATCH] Added code to make data zero if return of mds is char.

---
 matlab/TCV_IMAS/tcv_get_ids_nbi.m | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/matlab/TCV_IMAS/tcv_get_ids_nbi.m b/matlab/TCV_IMAS/tcv_get_ids_nbi.m
index eb6777a5..9d5cf6a5 100644
--- a/matlab/TCV_IMAS/tcv_get_ids_nbi.m
+++ b/matlab/TCV_IMAS/tcv_get_ids_nbi.m
@@ -88,7 +88,7 @@ for iunit=1:nb_units
   params_eff.data_request = ['\results::' results_subname{iunit} ':powr_tcv'];
   pow=gdat_tcv(shot,params_eff);
   if ischar(pow.data)
-    pow.data=0;
+    pow.data=[];
   end
   ids_nbi.unit{iunit}.power_launched.data = pow.data*1e6;
   ids_nbi.unit{iunit}.power_launched.time = pow.t;
@@ -96,12 +96,18 @@ for iunit=1:nb_units
   %% energy
   params_eff.data_request = ['\results::' results_subname{iunit} ':energy'];
   en=gdat_tcv(shot,params_eff);
+  if ischar(en.data)
+    en.data=[];
+  end
   ids_nbi.unit{iunit}.energy.data = en.data*1e3;
   ids_nbi.unit{iunit}.energy.time = en.t;
   ids_nbi_description.unit{iunit}.energy = params_eff.data_request;
   %% power & current fractions
   params_eff.data_request = ['\results::' results_subname{iunit} ':fraction'];
   p_frac=gdat(shot,params_eff);
+  if ischar(p_frac.data)
+    p_frac.data=[];
+  end
   ids_nbi.unit{iunit}.beam_power_fraction.time = p_frac.t;
   ids_nbi_description.unit{iunit}.beam_power_fraction = params_eff.data_request;
   if ~isempty(p_frac.data) && size(p_frac.data,2)>=3
-- 
GitLab