From b144ae1ccd1a86f42d4f3dbdc602e708db2b215d Mon Sep 17 00:00:00 2001
From: Olivier Sauter <Olivier.Sauter@epfl.ch>
Date: Wed, 29 Jun 2022 12:01:06 +0200
Subject: [PATCH] make z=0 probes default for mhd spectrogram except if
 zaxis>12cm

---
 matlab/TCV/gdat_tcv.m | 14 ++++++++++++--
 1 file changed, 12 insertions(+), 2 deletions(-)

diff --git a/matlab/TCV/gdat_tcv.m b/matlab/TCV/gdat_tcv.m
index e763fd77..4efc8ab9 100644
--- a/matlab/TCV/gdat_tcv.m
+++ b/matlab/TCV/gdat_tcv.m
@@ -1297,7 +1297,7 @@ elseif strcmp(mapping_for_tcv.method,'switchcase')
     params_eff.data_request = '\hybrid::mat_m_signals:output_019';
     gasrequest = gdat_tcv(gdat_data.shot,params_eff);
     gdat_data.gas_request_volt = gasrequest;
-    %volt_to_mlpers = max(0.,(in_volt-0.6879)*(72.41/(4.2673-0.6879))
+    % volt_to_mlpers = max(0.,(in_volt-0.6879)*(72.41/(4.2673-0.6879)))
     gdat_data.gas_request_flux = gasrequest;
     gdat_data.gas_request_flux.data = max(0.,72.41.*(gasrequest.data-0.6879)./(4.2673-0.6879));
     gdat_data.gas_request_flux.units = gasflux.units;
@@ -1944,7 +1944,17 @@ elseif strcmp(mapping_for_tcv.method,'switchcase')
       if isfield(gdat_data.gdat_params,'source') && ~isempty(gdat_data.gdat_params.source)
         % gdat_data.gdat_params.source;
       else
-        gdat_data.gdat_params.source = '23';
+        z_axis=gdat_tcv([],'z_axis');
+        z_axis_av = 0.;
+        if numel(z_axis.data > 10) && isnumeric(z_axis.data)
+          z_axis_av = nanmean(z_axis.data([round(numel(z_axis.data)/3):round(numel(z_axis.data)*0.85)]));
+        end
+        if z_axis_av > 0.12
+          gdat_data.gdat_params.source = '23';
+        else
+          gdat_data.gdat_params.source = '0';
+        end
+        disp(sprintf('source set to ''%s'', can be ''0'', ''23'', ''23full'' or ''ltcc''',gdat_data.gdat_params.source))
       end
       if length(gdat_data.gdat_params.source)>=2 && strcmp(gdat_data.gdat_params.source(1:2),'23')
         aaLFSz23_sect3=tdi('\atlas::DT196_MHD_001:channel_067');
-- 
GitLab