From 382df7c97e432a9f2f8d106073d7e4d1b4d4f563 Mon Sep 17 00:00:00 2001
From: Olivier Sauter <olivier.sauter@epfl.ch>
Date: Wed, 30 Sep 2015 13:13:53 +0000
Subject: [PATCH] other bugs with empty data fixed, tested full list with
 non-existent shot number

git-svn-id: https://spcsvn.epfl.ch/repos/TCV/gdat/trunk@5080 d63d8f72-b253-0410-a779-e742ad2e26cf
---
 crpptbx/TCV/gdat_tcv.m          | 42 +++++++++++++++++++++++++++++++++
 crpptbx/test_all_requestnames.m | 13 +++++-----
 2 files changed, 49 insertions(+), 6 deletions(-)

diff --git a/crpptbx/TCV/gdat_tcv.m b/crpptbx/TCV/gdat_tcv.m
index e4ce47b7..d0db6bdd 100644
--- a/crpptbx/TCV/gdat_tcv.m
+++ b/crpptbx/TCV/gdat_tcv.m
@@ -124,6 +124,18 @@ if nargin>=1
     shot = mdsipmex(2,'$SHOT');
     gdat_data.shot = shot;
     do_mdsopen_mdsclose = 0;
+    if ischar(shot) || isempty(shot)
+      if gdat_params.nverbose>=1
+        if isstruct(data_request) && isfield(data_request,'data_request')
+          warning(['shot cannot be opened with ' data_request.data_request]);
+        elseif ischar(data_request)
+          warning(['shot cannot be opened with ' data_request]);
+        else
+          warning(['shot cannot be opened']);
+        end
+      end
+      return
+    end
   elseif isnumeric(shot)
     gdat_data.shot = shot;
   elseif ischar(shot)
@@ -476,6 +488,11 @@ elseif strcmp(mapping_for_tcv.method,'switchcase')
     % compute average minor or major radius (on z=zaxis normally)
     nodenameeff=['\results::z_contour' substr_liuqe];
     zcontour=tdi(nodenameeff);
+    if isempty(zcontour.data) || isempty(zcontour.dim) || ~any(~isnan(zcontour.data)) % || ischar(zcontour.data) (to add?)
+      if (gdat_params.nverbose>=1); warning(['problems loading data for ' nodenameeff ' for data_request= ' data_request_eff]); end
+      if (gdat_params.nverbose>=3); disp(['rerun LIUQE?']); end
+      return
+    end   
     if strcmp(data_request_eff,'zgeom')
       gdat_data.data=0.5.*(max(zcontour.data,[],1) + min(zcontour.data,[],1));
       gdat_data.data_fullpath=['(max+min)/2 of ' nodenameeff];
@@ -666,6 +683,12 @@ elseif strcmp(mapping_for_tcv.method,'switchcase')
       time_eff = time(itime);
       % use read_results updated to effectively obtain an eqdsk with sign correct with COCOS=2
       [fnames_readresults]=read_results_for_chease(shot,time_eff,liuqe_version,3,[],[],[],zshift,0,1);
+      if isempty(fnames_readresults)
+        if gdat_params.nverbose>=1;
+          warning(['could not create eqdsk file from read_results_for_chease with data_request= ' data_request_eff]);
+        end
+        return
+      end
       eqdskval=read_eqdsk(fnames_readresults{4},7,0,[],[],1); % LIUQE is 17 but read_results divided psi by 2pi thus 7
       for i=1:length(fnames_readresults)
         unix(['rm ' fnames_readresults{i}]);
@@ -952,6 +975,10 @@ elseif strcmp(mapping_for_tcv.method,'switchcase')
     % At this stage fill just ech, later add nbi
     nodenameeff='\results::toray.input:p_gyro';
     tracetdi=tdi(nodenameeff);
+    if isempty(tracetdi.data) || isempty(tracetdi.dim) || ~any(~isnan(tracetdi.data)) % || ischar(tracetdi.data) (to add?)
+      if (gdat_params.nverbose>=1); warning(['problems loading data for ' nodenameeff ' for data_request= ' data_request_eff]); end
+      return
+    end   
     gdat_data.ec.data = tracetdi.data*1e3; % at this stage p_gyro is in kW'
     gdat_data.ec.units = 'W';
     gdat_data.ec.dim=tracetdi.dim;
@@ -998,6 +1025,11 @@ elseif strcmp(mapping_for_tcv.method,'switchcase')
       nodenameeff=[begstr 'q_psi' substr_liuqe];
     end
     tracetdi=tdi(nodenameeff);
+    if isempty(tracetdi.data) || isempty(tracetdi.dim) || ~any(~isnan(tracetdi.data)) % || ischar(tracetdi.data) (to add?)
+      if (gdat_params.nverbose>=1); warning(['problems loading data for ' nodenameeff ' for data_request= ' data_request_eff]); end
+      if (gdat_params.nverbose>=3); disp(['rerun LIUQE?']); end
+      return
+    end   
     gdat_data.data = tracetdi.data;
     gdat_data.dim = tracetdi.dim;
     gdat_data.t = gdat_data.dim{2};
@@ -1019,6 +1051,11 @@ elseif strcmp(mapping_for_tcv.method,'switchcase')
       nodenameeff=[begstr 'q_psi' substr_liuqe];
     end
     tracetdi=tdi(nodenameeff);
+    if isempty(tracetdi.data) || isempty(tracetdi.dim) || ~any(~isnan(tracetdi.data)) % || ischar(tracetdi.data) (to add?)
+      if (gdat_params.nverbose>=1); warning(['problems loading data for ' nodenameeff ' for data_request= ' data_request_eff]); end
+      if (gdat_params.nverbose>=3); disp(['rerun LIUQE?']); end
+      return
+    end   
     gdat_data.data = tracetdi.data.*0;
     gdat_data.dim = tracetdi.dim;
     gdat_data.t = gdat_data.dim{1};
@@ -1036,6 +1073,11 @@ elseif strcmp(mapping_for_tcv.method,'switchcase')
     params_eff = gdat_data.gdat_params;
     params_eff.data_request='q_rho'; 
     q_rho=gdat_tcv([],params_eff);
+    if isempty(q_rho.data) || isempty(q_rho.dim) || ~any(~isnan(q_rho.data)) % || ischar(q_rho.data) (to add?)
+      if (gdat_params.nverbose>=1); warning(['problems loading data for q_rho for data_request= ' data_request_eff]); end
+      if (gdat_params.nverbose>=3); disp(['rerun LIUQE?']); end
+      return
+    end
     params_eff.data_request='psi_axis'; % psi_edge=0 with LIUQE
     psi_axis=gdat_tcv([],params_eff);
     params_eff.data_request='b0'; % psi_edge=0 with LIUQE
diff --git a/crpptbx/test_all_requestnames.m b/crpptbx/test_all_requestnames.m
index ac1415ac..0faaa283 100644
--- a/crpptbx/test_all_requestnames.m
+++ b/crpptbx/test_all_requestnames.m
@@ -1,15 +1,16 @@
 
-machine='AUG';
-shot=30594;
-machine='TCV';
-shot=48836;
-aa=gdat('machine',machine);
+% $$$ machine='AUG';
+% $$$ shot=30594;
+% $$$ machine='TCV';
+% $$$ shot=48836;
+% aa=gdat('machine',machine);
 aa=gdat;
+machine = aa.gdat_params.machine;
 all_request_names = aa.gdat_request
 %break
 istart=1;
 for irequest=istart:length(all_request_names)
   request=all_request_names{irequest}
-  ab{irequest} = gdat(shot,request,'machine',machine,'doplot',1);
+  ab_test_all{irequest} = gdat(shot,request,'machine',machine,'doplot',1);
   pause
 end
-- 
GitLab