From abb5e3b6b13e0d31a83edcef4c0561538cfeb757 Mon Sep 17 00:00:00 2001
From: Antoine Merle <antoine.merle@epfl.ch>
Date: Tue, 5 May 2020 22:28:55 +0200
Subject: [PATCH] Simplify reading fir/thom ratio as value for edge system
 never existed and is irrelevant.

---
 matlab/TCV/gdat_tcv.m | 70 ++++++++++++++-----------------------------
 1 file changed, 22 insertions(+), 48 deletions(-)

diff --git a/matlab/TCV/gdat_tcv.m b/matlab/TCV/gdat_tcv.m
index 43686d66..b9ae1b6f 100644
--- a/matlab/TCV/gdat_tcv.m
+++ b/matlab/TCV/gdat_tcv.m
@@ -3395,62 +3395,38 @@ error_status=0;
 return
 
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-function [firthomratio] = get_fir_thom_rat_data(shot,maintracename,timebase,nverbose);
-%
-% since depends on shot number for using auto fit and thomson or thomson edge, use tracename and function here
-%
-% maintracename = 'thomson' or 'thomson_edge
+function [firthomratio] = get_fir_thom_rat_data(shot,timebase,nverbose)
 %
 % return fir_to_thomson ratio on time=timebase
 %
-% normally should use "main" thomson one built from auto fit if possible
-% take edge one if need be
+% Use of autofit or thomson fir ratio depends on shot number
 %
-% default: maintracename = "thomson"
-%
-maintracename_eff = 'thomson';
-if exist('maintracename') && ~isempty(maintracename)
-  maintracename_eff = maintracename;
-end
+% Update on May 5th 2020 (amerle):
+% Node for edge system thomson.edge:fir_thom_rat was never used so this
+% option is now removed. The edge system existed for shots 24382:49895
+% which lies entirely in the range for the autofit ratio. Note also that a
+% separate fir ratio for edge and main makes very little sense as none of
+% them cover the whole chord height.
 
 firthomratio = NaN;
-if ~exist('timebase') || isempty(timebase)
+if ~exist('timebase','var') || isempty(timebase)
   if (nverbose>=1)
     disp('need a timebase in get_fir_thom_rat_data')
   end
   return
 end
 firthomratio = NaN*ones(size(timebase));
-
-if strcmp(maintracename_eff,'thomson')
-  if shot>=23801
-    tracefirrat=tdi('\results::thomson.profiles.auto:fir_thom_rat'); %time base not same!!
-    if isempty(tracefirrat.data) || ischar(tracefirrat.data)
-      if (nverbose>=1); disp('problem with \results::thomson.profiles.auto:fir_thom_rat: empty, use thomson:fir_thom_rat'); end
-      tracefirrat=tdi('\results::thomson:fir_thom_rat');
-    end
-  else
+if shot>=23801
+  tracefirrat=tdi('\results::thomson.profiles.auto:fir_thom_rat'); %time base not same!!
+  if isempty(tracefirrat.data) || ischar(tracefirrat.data)
+    if (nverbose>=1); disp('problem with \results::thomson.profiles.auto:fir_thom_rat: empty, use thomson:fir_thom_rat'); end
     tracefirrat=tdi('\results::thomson:fir_thom_rat');
-    if isempty(tracefirrat.data) || ischar(tracefirrat.data)
-      if (nverbose>=1); disp('problem with \results::thomson:fir_thom_rat: empty'); end
-    end
-  end
-elseif strcmp(maintracename_eff,'thomson_edge')
-  if shot>=23801
-    tracefirrat=tdi('\results::thomson.profiles.auto:fir_thom_rat'); %time base not same!!
-    if isempty(tracefirrat.data) || ischar(tracefirrat.data)
-      if (nverbose>=1); disp('problem with \results::thomson.profiles.auto:fir_thom_rat: empty, use thomson:fir_thom_rat'); end
-      tracefirrat=tdi('\results::thomson:fir_thom_rat');
-    end
-  else
-    tracefirrat=tdi('\results::thomson_edge:fir_thom_rat');
-    if isempty(tracefirrat.data) || ischar(tracefirrat.data)
-      if (nverbose>=1); disp('problem with \results::thomson_edge:fir_thom_rat: empty'); end
-    end
   end
 else
-  if (nverbose>=1); disp('bad input in get_fir_thom_rat_data'); end
-  return
+  tracefirrat=tdi('\results::thomson:fir_thom_rat');
+  if isempty(tracefirrat.data) || ischar(tracefirrat.data)
+    if (nverbose>=1); disp('problem with \results::thomson:fir_thom_rat: empty'); end
+  end
 end
 
 if ~isempty(tracefirrat.data) && ~ischar(tracefirrat.data) && any(isfinite(tracefirrat.data)) ...
@@ -3486,14 +3462,12 @@ if isempty(time) || ischar(time)
   end
   return
 end
-edge_str_ = '';
-edge_str_dot = '';
+edge_str = '';
 if doedge
-  edge_str_ = '_edge';
-  edge_str_dot = '.edge';
+  edge_str = '.edge';
 end
 
-nodenameeff = ['\results::thomson' edge_str_dot ':' data_request_eff(1:2)];
+nodenameeff = ['\results::thomson' edge_str ':' data_request_eff(1:2)];
 tracetdi=tdi(nodenameeff);
 if isempty(tracetdi.data) || ischar(tracetdi.data) || isempty(tracetdi.dim)
   gdat_data.error_bar = [];
@@ -3504,12 +3478,12 @@ if isempty(tracetdi.data) || ischar(tracetdi.data) || isempty(tracetdi.dim)
 end
 
 gdat_data.data=tracetdi.data'; % Thomson data as (t,z)
-tracestd=tdi(['\results::thomson'  edge_str_dot ':' data_request_eff(1:2) ':error_bar']);
+tracestd=tdi(['\results::thomson'  edge_str ':' data_request_eff(1:2) ':error_bar']);
 gdat_data.error_bar=tracestd.data';
 gdat_data.data_fullpath=[nodenameeff '; error_bar'];
 % add fir if ne requested
 if strcmp(data_request_eff(1:2),'ne')
-  tracefirrat_data = get_fir_thom_rat_data(shot,['thomson' edge_str_],time,nverbose);
+  tracefirrat_data = get_fir_thom_rat_data(shot,time,nverbose);
   gdat_data.firrat=tracefirrat_data;
   gdat_data.data_raw = gdat_data.data;
   gdat_data.data = gdat_data.data_raw * diag(tracefirrat_data);
-- 
GitLab