From 855e6688f0782e5f6307f72ec52b15eebb4fae90 Mon Sep 17 00:00:00 2001
From: Federico Felici <federico.felici@epfl.ch>
Date: Tue, 11 Jun 2019 20:59:03 +0000
Subject: [PATCH] Added coil resistivity + allow not loading time data

git-svn-id: https://spcsvn.epfl.ch/repos/TCV/gdat/trunk@12042 d63d8f72-b253-0410-a779-e742ad2e26cf
---
 crpptbx/TCV_IMAS/tcv_ids_circuit.m | 12 +++++++++++-
 crpptbx/TCV_IMAS/tcv_ids_coil.m    | 12 +++++++++++-
 crpptbx/TCV_IMAS/tcv_ids_supply.m  |  9 ++++++++-
 3 files changed, 30 insertions(+), 3 deletions(-)

diff --git a/crpptbx/TCV_IMAS/tcv_ids_circuit.m b/crpptbx/TCV_IMAS/tcv_ids_circuit.m
index f797b51f..df6d88dc 100644
--- a/crpptbx/TCV_IMAS/tcv_ids_circuit.m
+++ b/crpptbx/TCV_IMAS/tcv_ids_circuit.m
@@ -22,9 +22,19 @@ end
 ids_struct_out(1:tcv_circuit_info.ntotcircuits) = ids_structures;
 for ii=1:tcv_circuit_info.ntotcircuits
   tmpdata = gdat_tcv(shot,['' tcv_circuit_info.mds_paths{ii} '']); % Get current
+  if ischar(tmpdata.data)
+    % replace by dummy
+    tmpdata.dim{1} = [];
+    tmpdata.data = []; 
+    warning('no time data loaded for shot %d',shot);
+    ids_struct_out_description{ii}.current = 'not loaded';
+  else
+      ids_struct_out_description{ii}.current = ['from ' tmpdata.data_fullpath];
+  end
   ids_struct_out{ii}.current.data = tmpdata.data;
-  ids_struct_out_description{ii}.current = ['from ' tmpdata.data_fullpath];
   ids_struct_out{ii}.current.time = tmpdata.dim{1};
+    
+  
   ids_struct_out{ii}.connections = tcv_circuit_info.connection_matrix{ii};
   ids_struct_out_description{ii}.connections = ...
       ['aa=tcv_ids_pf_active_definition, then from aa.connection_matrix{' num2str(ii) '}'];
diff --git a/crpptbx/TCV_IMAS/tcv_ids_coil.m b/crpptbx/TCV_IMAS/tcv_ids_coil.m
index 95577f33..b1b989a2 100644
--- a/crpptbx/TCV_IMAS/tcv_ids_coil.m
+++ b/crpptbx/TCV_IMAS/tcv_ids_coil.m
@@ -62,7 +62,6 @@ iG=strmatch('G_00',namepfc);
 w_c(iG)=sqrt(xsect_c(iG));
 h_c(iG)=sqrt(xsect_c(iG));
 
-
 %% Put data to ids structure
 ids_struct_out(1:sizepfc) = ids_structures;
 ind_coil_ids = 0;
@@ -73,11 +72,19 @@ for ii=1:ncircuits2ids
       ind_coil_ids = ind_coil_ids +1;
       ids_struct_out{ind_coil_ids}.name = coil_names2ids{ii}{jj};
       ids_struct_out_description{ind_coil_ids}.name = ['through aa=tcv_ids_pf_active_definition from aa.coil_names  '];
+      
+      % time-varying data
       tmpdata = tdi(mds_paths2ids{ii});
+      if ischar(tmpdata.data), % arcane way to detect no data was loaded
+        tmpdata.dim{1} = [];
+        tmpdata.data = [];
+        warning('no time data loaded for shot %d',shot);
+      end
       ids_struct_out{ind_coil_ids}.current.data = tmpdata.data;
       ids_struct_out_description{ind_coil_ids}.current.data = ['from ' mds_paths2ids{ii}];
       ids_struct_out{ind_coil_ids}.current.time = tmpdata.dim{1};
 
+      
       % Find index on static tree
       tmpind = find(strcmp(ids_struct_out{ind_coil_ids}.name, namepfc));
       ids_struct_out{ind_coil_ids}.element{1}.geometry.rectangle.r = r_c(tmpind);
@@ -92,6 +99,9 @@ for ii=1:ncircuits2ids
       ids_struct_out_description{ind_coil_ids}.element{1}.turns_with_sign = ['from static(''nt_c'')'];
       ids_struct_out{ind_coil_ids}.element{1}.geometry.geometry_type = 2; % 1 outline, 2 rectangle, 4 arc of circle
       ids_struct_out_description{ind_coil_ids}.element{1}.geometry.geometry_type = 'rectangle';
+      
+      ids_struct_out{ind_coil_ids}.resistance = res_c(tmpind);
+      ids_struct_out_description{ind_coil_ids}.resistance = ['from static(''res_c'')'];
     end
 end
 
diff --git a/crpptbx/TCV_IMAS/tcv_ids_supply.m b/crpptbx/TCV_IMAS/tcv_ids_supply.m
index e073793f..19078821 100644
--- a/crpptbx/TCV_IMAS/tcv_ids_supply.m
+++ b/crpptbx/TCV_IMAS/tcv_ids_supply.m
@@ -22,7 +22,14 @@ end
 ids_struct_out(1:tcv_circuit_info.ntotpowersupplies) = ids_structures;
 for ii=1:tcv_circuit_info.ntotpowersupplies
   tmpdata = gdat_tcv(shot,['' tcv_circuit_info.mds_paths{ii} '']); % Get current
-  ids_struct_out{ii}.current.data = abs(tmpdata.data);
+  if ischar(tmpdata.data);
+    warning('no time data loaded for shot %d',shot);
+    tmpdata.dim{1} = [];
+    tmpdata.data = [];
+    % empty dummy
+  end
+    
+  ids_struct_out{ii}.current.data = abs(tmpdata.data); %%%%%%% FF:WHY ABS?? %%%%%%%
   ids_struct_out_description{ii}.current = ['abs value from ' tmpdata.data_fullpath];
   ids_struct_out{ii}.current.time = tmpdata.dim{1};
   ids_struct_out{ii}.name = tcv_circuit_info.power_supply_names{ii}{1};
-- 
GitLab