From 2c189c3cd708704f961f51cf3d1b1fd13c986aa1 Mon Sep 17 00:00:00 2001
From: Olivier Sauter <olivier.sauter@epfl.ch>
Date: Mon, 17 Jul 2017 16:29:06 +0000
Subject: [PATCH] add temporary fix for bad w_mhd

git-svn-id: https://spcsvn.epfl.ch/repos/TCV/gdat/trunk@7926 d63d8f72-b253-0410-a779-e742ad2e26cf
---
 crpptbx/TCV/gdat_tcv.m             |  2 ++
 crpptbx/TCV/tcv_requests_mapping.m | 24 ++++++++++++++++++------
 crpptbx/gdat_plot.m                |  9 ++++++++-
 3 files changed, 28 insertions(+), 7 deletions(-)

diff --git a/crpptbx/TCV/gdat_tcv.m b/crpptbx/TCV/gdat_tcv.m
index 7fcbcd7b..0f0c4eb5 100644
--- a/crpptbx/TCV/gdat_tcv.m
+++ b/crpptbx/TCV/gdat_tcv.m
@@ -469,6 +469,7 @@ if strcmp(mapping_for_tcv.method(1:3),'tdi')
     mapping_for_tcv.gdat_timedim = mapping_for_tcv.timedim;
   end
   gdat_data.data_fullpath=[mapping_for_tcv.expression];
+  gdat_data.help = aatmp.help;
 
   % end of method "tdi"
 
@@ -517,6 +518,7 @@ elseif strcmp(mapping_for_tcv.method,'expression')
       end
     end
     gdat_data.data_fullpath=mapping_for_tcv.expression;
+    gdat_data.help = gdat_tmp.help;
   end
   % end of method "expression"
 
diff --git a/crpptbx/TCV/tcv_requests_mapping.m b/crpptbx/TCV/tcv_requests_mapping.m
index b16c9dc7..e5472345 100644
--- a/crpptbx/TCV/tcv_requests_mapping.m
+++ b/crpptbx/TCV/tcv_requests_mapping.m
@@ -100,7 +100,7 @@ switch lower(data_request)
   mapping.method = 'tdiliuqe';
   mapping.expression = '\results::delta_ed_bot';
   mapping.expression = '\tcv_shot::top.results.equil_1.results:delta_bot';
-  mapping.expression = 'tcv_eq(''''delta_bot'''',''''LIUQE.M'''')';
+  mapping.expression = 'tcv_eq(''''delta_ed_bot'''',''''LIUQE.M'''')';
  case 'delta_rho'
   mapping.timedim = 1;
   mapping.method = 'tdiliuqe';
@@ -112,7 +112,7 @@ switch lower(data_request)
   mapping.method = 'tdiliuqe';
   mapping.expression = '\results::delta_ed_top';
   mapping.expression = '\tcv_shot::top.results.equil_1.results:delta_top';
-  mapping.expression = 'tcv_eq(''''delta_top'''',''''LIUQE.M'''')';
+  mapping.expression = 'tcv_eq(''''delta_ed_top'''',''''LIUQE.M'''')';
  case 'ece'
   mapping.timedim = 2;
   mapping.method = 'switchcase';
@@ -362,10 +362,22 @@ switch lower(data_request)
   % mapping.expression = '\results::psitbx:vol'; (if exists for liuqe2 and 3 as well)
  case {'wmhd', 'w_mhd'}
   mapping.timedim = 1;
-  mapping.method = 'tdiliuqe';
-  mapping.expression = '\results::total_energy';
-  mapping.expression = '\tcv_shot::top.results.equil_1.results:w_mhd';
-  mapping.expression = 'tcv_eq(''''w_mhd'''',''''LIUQE.M'''')';
+  if shot==57716 || shot==57732
+    time_for_corr = [0.5,1.03];
+    corr = [4e3,4.5e3];
+    if shot==57732; corr=[4650,4650]; end
+    mapping.method = 'expression';
+    mapping.expression = ['params_eff = gdat_data.gdat_params;params_eff.data_request=''tcv_eq(''''''''w_mhd'''''''',''''''''LIUQE.M'''''''')'';' ...
+                    'gdat_tmp=gdat_tcv(shot,params_eff);ij=find(gdat_tmp.t>0.5&gdat_tmp.t<1.03);' ...
+                    'aa=interp1([' num2str(time_for_corr(1)) ' ' num2str(time_for_corr(2)) ...
+                    '],[' num2str(corr(1)) ' ' num2str(corr(2)) '],gdat_tmp.t(ij));' ...
+		    'gdat_tmp.data(ij)=max(gdat_tmp.data(ij),aa);'];
+  else
+    mapping.method = 'tdiliuqe';
+    mapping.expression = '\results::total_energy';
+    mapping.expression = '\tcv_shot::top.results.equil_1.results:w_mhd';
+    mapping.expression = 'tcv_eq(''''w_mhd'''',''''LIUQE.M'''')';
+  end
  case 'z_contour'
   mapping.timedim = 2;
   mapping.method = 'tdiliuqe';
diff --git a/crpptbx/gdat_plot.m b/crpptbx/gdat_plot.m
index 4251c694..0e138882 100644
--- a/crpptbx/gdat_plot.m
+++ b/crpptbx/gdat_plot.m
@@ -62,7 +62,14 @@ if all(isfield(gdat_data,{'data','t'})) && ~isempty(gdat_data.data) && ~isempty(
     title(eval(['gdat_data.eqdsk' endstr '.stitle']));
   elseif any(find(size(gdat_data.data)==length(gdat_data.t)))
     try
-      plot(gdat_data.t,gdat_data.data);
+      if length(size(gdat_data.data))<=2
+        plot(gdat_data.t,gdat_data.data);
+      else
+        disp('WARNING')
+        disp(['size(gdat_data.data) = ' num2str(size(gdat_data.data)) ', >2D thus do not try to plot'])
+        disp(' ')
+        return
+      end
     catch ME
       if exist('ME','var')
         disp('Problem in gdat_plot')
-- 
GitLab