From dec898ddb4922dbfb6070d1c3cc7dbe0887c8d8b Mon Sep 17 00:00:00 2001
From: Olivier Sauter <olivier.sauter@epfl.ch>
Date: Tue, 26 Mar 2019 11:03:41 +0000
Subject: [PATCH] add ids to gdat_aug

git-svn-id: https://spcsvn.epfl.ch/repos/TCV/gdat/trunk@11643 d63d8f72-b253-0410-a779-e742ad2e26cf
---
 crpptbx/AUG/aug_requests_mapping.m |  4 +++
 crpptbx/AUG/gdat_aug.m             | 49 ++++++++++++++++++++++++++++++
 2 files changed, 53 insertions(+)

diff --git a/crpptbx/AUG/aug_requests_mapping.m b/crpptbx/AUG/aug_requests_mapping.m
index 6aa9c7a3..e30bed0c 100644
--- a/crpptbx/AUG/aug_requests_mapping.m
+++ b/crpptbx/AUG/aug_requests_mapping.m
@@ -144,6 +144,10 @@ switch lower(data_request)
   mapping.expression = ['params_eff = gdat_data.gdat_params;params_eff.data_request=[{''TTH''},{''H/L-facs''},{''AUGD''}];params_eff.source=''TTH'';' ...
                     'gdat_tmp=gdat_aug(shot,params_eff);S = rdaAUG_eff(shot,''TTH'',''scal_par'',''AUGD'',[],[],''param:descript'');gdat_tmp.dimunits{1}=cellstr(deblank(S.data''));' ...
                     'gdat_tmp.data = min(gdat_tmp.data,10.);'];
+ case 'ids'
+  mapping.timedim = 1;
+  mapping.label = 'ids ala imas';
+  mapping.method = 'switchcase';
  case 'ioh'
   mapping.timedim = 1;
   mapping.label = 'I ohmic transformer';
diff --git a/crpptbx/AUG/gdat_aug.m b/crpptbx/AUG/gdat_aug.m
index 5efda814..446d8711 100644
--- a/crpptbx/AUG/gdat_aug.m
+++ b/crpptbx/AUG/gdat_aug.m
@@ -1081,6 +1081,55 @@ elseif strcmp(mapping_for_aug.method,'switchcase')
     gdat_data.dimunits{1} = 'rhopolnorm';
     gdat_data.dimunits{2} = 'time [s]';
 
+    %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+   case {'ids'}
+    params_eff = gdat_data.gdat_params;
+    if isfield(params_eff,'source') && ~isempty(params_eff.source)
+      ids_top_name = params_eff.source;
+    else
+      ids_top_name = [];
+      disp('need an ids name in ''source'' parameter');
+      disp('check substructure gdat_params.source_available for an ids list');
+    end
+    ids_gen_ok = exist('ids_gen');
+    equil_empty = struct([]);
+    if ids_gen_ok ~= 2
+      ids_struct_saved = 'ids_structures_20190312.mat';
+      if ~exist(ids_struct_saved,'file')
+        warning(['function ids_gen not available neither file ids_structures_20190312.mat thus cannot create empty ids: ids_gen(''' ids_top_name ''')']);
+        return
+      else
+        eval(['load ' ids_struct_saved ])
+        if isfield(ids_structures,ids_top_name)
+          equil_empty = ids_structures.(ids_top_name);
+        else
+          if ~isempty(ids_top_name);
+            warning(['ids ''' ids_top_name ''' does not exist in ids_structures saved in ' ids_struct_saved]);
+          end
+          gdat_data.gdat_params.source_available = ids_list;
+          return
+        end
+      end
+    else
+      equil_empty = ids_gen(ids_top_name);
+    end
+    try
+      if ~isempty(shot)
+        eval(['[ids_top,ids_top_description]=tcv_get_ids_' ids_top_name '(shot,equil_empty);'])
+        gdat_data.(ids_top_name) = ids_top;
+        gdat_data.([ids_top_name '_description']) = ids_top_description;
+      else
+      gdat_data.(ids_top_name) = equil_empty;
+      gdat_data.([ids_top_name '_description']) = ['shot empty so return default empty structure for ' ids_top_name];
+      end
+    catch ME_aug_get_ids
+      getReport(ME_aug_get_ids)
+      disp(['there is a problem with: aug_get_ids_' ids_top_name ...
+            ' , may be check if it exists in your path or test it by itself'])
+      gdat_data.(ids_top_name) = equil_empty;
+      gdat_data.([ids_top_name '_description']) = getReport(ME_aug_get_ids);
+    end
+
     %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    case {'ne','te'}
     exp_name_eff = gdat_data.gdat_params.exp_name;
-- 
GitLab