From 74771037e46509990e6d340d25822ed41f9e70eb Mon Sep 17 00:00:00 2001
From: Matteo Vallar <matteo.vallar@epfl.ch>
Date: Thu, 21 Oct 2021 15:06:53 +0200
Subject: [PATCH] Now warning user if nverbose>=3 when no NB1/Nb2 are present

---
 matlab/TCV/gdat_tcv.m | 41 +++++++++++++++++++++++++++++++++++------
 1 file changed, 35 insertions(+), 6 deletions(-)

diff --git a/matlab/TCV/gdat_tcv.m b/matlab/TCV/gdat_tcv.m
index c82eb8d0..8b5bb3b1 100644
--- a/matlab/TCV/gdat_tcv.m
+++ b/matlab/TCV/gdat_tcv.m
@@ -2464,6 +2464,9 @@ elseif strcmp(mapping_for_tcv.method,'switchcase')
     %
     if any(strmatch('nbi1',gdat_data.gdat_params.source))
       nodenameeff = '\results::NBH:POWR_TCV';
+      if shot<70811
+        nodenameeff = '\results::NBH:POWR_TCV';
+      end
       nbh_data_tdi = tdi(nodenameeff);
       if ~isempty(nbh_data_tdi.data) && ~ischar(nbh_data_tdi.data) && ~isempty(nbh_data_tdi.dim)
         nbi_neutral_power_tot = nbh_data_tdi.data.*1e6; % in W
@@ -2487,6 +2490,20 @@ elseif strcmp(mapping_for_tcv.method,'switchcase')
         gdat_data.data(:,end+1) = interpos(-21,gdat_data.nbi1.t(ij),gdat_data.nbi1.data(ij),gdat_data.t);
         gdat_data.x(end+1) = size(gdat_data.data,2);
         gdat_data.label{end+1}=gdat_data.nbi1.label;
+      else
+        if gdat_params.nverbose>=3
+          fprintf('No NB1 data in MDS+ nodes for shot %i\n', shot);
+          model_signame = '\ATLAS::NB1.DATA.MODEL:POWR_NEUTRAL';
+          if shot<70811
+            nodenameeff = '\ATLAS::NB1.DATA.MODEL:POWR_NEUTRAL';
+          end
+          model_data=tdi(model_signame);
+          if isempty(model_data.dim)
+            fprintf('And it was NOT requested \n');
+          else
+            fprintf('And it was requested. Check if plasma was a blip or if NB1 did not work \n');   
+          end
+        end
       end
     end
     %
@@ -2515,10 +2532,10 @@ elseif strcmp(mapping_for_tcv.method,'switchcase')
     end
     %
     if any(strmatch('nbi2',gdat_data.gdat_params.source))
-    % NB2  
-    nodenameeff = '\results::NB2:POWR_TCV';
+      % NB2  
+      nodenameeff = '\results::NB2:POWR_TCV';
       nb2_data_tdi = tdi(nodenameeff);
-      if ~isempty(nb2_data_tdi.data) && ~ischar(nb2_data_tdi.data) && ~isempty(nb2_data_tdi.dim)
+      if ~isempty(nb2_data_tdi.dim) && ~ischar(nb2_data_tdi.data) && ~isempty(nb2_data_tdi.dim)
         nbi_neutral_power_tot = nb2_data_tdi.data.*1e6; % in W
         ij = nbi_neutral_power_tot<100;
         nbi_neutral_power_tot(ij) = 0.;
@@ -2540,8 +2557,20 @@ elseif strcmp(mapping_for_tcv.method,'switchcase')
         gdat_data.data(:,end+1) = interpos(-21,gdat_data.nbi2.t(ij),gdat_data.nbi2.data(ij),gdat_data.t);
         gdat_data.x(end+1) = size(gdat_data.data,2);
         gdat_data.label{end+1}=gdat_data.nbi2.label;
-      end
+      else
+        if gdat_params.nverbose>=3
+          fprintf('No NB2 data in MDS+ nodes for shot %i\n', shot);
+          model_signame = '\ATLAS::NB2.DATA.MODEL:POWR_NEUTRAL';
+          model_data=tdi(model_signame);
+          if isempty(model_data.dim)
+            fprintf('And it was NOT requested \n');
+          else
+            fprintf('And it was requested. Check if plasma was a blip or if NB1 did not work \n');   
+          end
+        end
+      end        
     end
+    
     if any(strmatch('dnbi',gdat_data.gdat_params.source))
     % NB2  
     nodenameeff = '\RESULTS::DNBI:POWR_TCV';
@@ -2675,7 +2704,7 @@ elseif strcmp(mapping_for_tcv.method,'switchcase')
     end
    case {'phi_tor', 'phitor', 'toroidal_flux'}
     % Phi(LCFS) = int(Bphi dSphi), can use Eq.(11) of "Tokamak coordinate conventions: COCOS" paper:
-    % O. Sauter, S.Yu. Medvedev, Comput. Phys. Commun. 184 (2013) 293–302
+    % O. Sauter, S.Yu. Medvedev, Comput. Phys. Commun. 184 (2013) 293???302
     % since cocos=17 for LIUQE we get:
     % q = -dPhi/dpsi => Phi = - int(q*dpsi) which should always have the sign of B0
     % need to get q_rho but to avoid loop for rhotor in grids_1d, get q_rho explicitely here
@@ -2897,7 +2926,7 @@ elseif strcmp(mapping_for_tcv.method,'switchcase')
     %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    case {'rhotor_edge', 'rhotor', 'rhotor_norm'}
     % Phi(LCFS) = int(Bphi dSphi), can use Eq.(11) of "Tokamak coordinate conventions: COCOS" paper:
-    % O. Sauter, S.Yu. Medvedev, Comput. Phys. Commun. 184 (2013) 293–302
+    % O. Sauter, S.Yu. Medvedev, Comput. Phys. Commun. 184 (2013) 293???302
     % since cocos=17 for LIUQE we get:
     % q = -dPhi/dpsi => Phi = - int(q*dpsi) which should always have the sign of B0
     % need to get q_rho but to avoid loop for rhotor in grids_1d, get q_rho explicitely here
-- 
GitLab