From d35b7f15c1390047cfa8704a91202e4814cd8f67 Mon Sep 17 00:00:00 2001
From: Olivier Sauter <olivier.sauter@epfl.ch>
Date: Fri, 19 Feb 2016 11:49:53 +0000
Subject: [PATCH] addbetan even if no data and various small changes

git-svn-id: https://spcsvn.epfl.ch/repos/TCV/gdat/trunk@5491 d63d8f72-b253-0410-a779-e742ad2e26cf
---
 crpptbx/AUG/aug_requests_mapping.m | 54 ++++++++++++++++++++++++++++++
 crpptbx/AUG/gdat_aug.m             |  6 ++--
 crpptbx/JET/gdat_jet.m             |  2 +-
 crpptbx/TCV/gdat_tcv.m             |  2 +-
 4 files changed, 60 insertions(+), 4 deletions(-)

diff --git a/crpptbx/AUG/aug_requests_mapping.m b/crpptbx/AUG/aug_requests_mapping.m
index 6a723708..f1a55341 100644
--- a/crpptbx/AUG/aug_requests_mapping.m
+++ b/crpptbx/AUG/aug_requests_mapping.m
@@ -71,6 +71,20 @@ switch lower(data_request)
   mapping.label = '\beta_N';
   mapping.method = 'signal';
   mapping.expression = [{'TOT'},{'beta_N'}];
+  % in many cases, in particular just after an experiment, betaN is not present in TOT, thus compute it from 2/3Wmhd/V /(B0^2/2mu0)
+  mapping.method = 'expression';
+  mapping.expression = ['params_eff = gdat_data.gdat_params;params_eff.data_request=[{''TOT''},{''beta_2N''},{''AUGD''}];' ...
+                    'gdat_tmp=gdat_aug(shot,params_eff); if isempty(gdat_tmp.data);' ...
+		    'params_eff.data_request=''ip'';gdat_ip=gdat_aug(shot,params_eff);' ...
+		    'params_eff.data_request=''b0'';gdat_b0=gdat_aug(shot,params_eff);' ...
+		    'params_eff.data_request=''a_minor'';gdat_aminor=gdat_aug(shot,params_eff);' ...
+		    'params_eff.data_request=''wmhd'';gdat_tmp=gdat_aug(shot,params_eff);' ...
+		    'params_eff.data_request=''volume'';gdat_vol=gdat_aug(shot,params_eff);' ...
+		    'tmp_data_ip=interp1(gdat_ip.t,gdat_ip.data,gdat_tmp.t,[],NaN);' ...
+		    'tmp_data_b0=interp1(gdat_b0.t,gdat_b0.data,gdat_tmp.t,[],NaN);' ...
+		    'tmp_data_a=interp1(gdat_aminor.t,gdat_aminor.data,gdat_tmp.t,[],NaN);' ...
+		    'tmp_data_vol=interp1(gdat_vol.t,gdat_vol.data,gdat_tmp.t,[],NaN);' ...
+		    'gdat_tmp.data = 100.*abs(2./3.*gdat_tmp.data./tmp_data_vol.*8e-7.*pi./tmp_data_b0.^2./tmp_data_ip.*1e6.*tmp_data_a.*tmp_data_b0);end;'];
  case 'betap'
   mapping.timedim = 1;
   mapping.label = '\beta_p';
@@ -115,6 +129,16 @@ switch lower(data_request)
   mapping.label = 'Halpha';
   mapping.method = 'signal';
   mapping.expression = [{'POT'},{'ELMa-Han'}];
+ case 'h_scalings'
+  mapping.label = 'H_{scal}';
+  mapping.timedim = 1;
+  mapping.method = 'signal';
+  mapping.expression = [{'TTH'},{'H/L-facs'},{'AUGD'}];
+  mapping.method = 'expression';
+  mapping.expression = ['params_eff = gdat_data.gdat_params;params_eff.data_request=[{''TTH''},{''Wmhd''},{''AUGD''}];' ...
+		   'gdat_tmp=gdat_aug(shot,params_eff);ij=find(~isnan(gdat_tmp.data)); gdat_tmp.data_raw=gdat_tmp.data;' ...
+		    'tmp_data=interpos(gdat_tmp.t(ij),gdat_tmp.data(ij),gdat_tmp.t,-1e5);' ...
+		    'gdat_tmp.data = max(tmp_data,0.);'];
  case 'ioh'
   mapping.timedim = 1;
   mapping.label = 'I ohmic transformer';
@@ -130,6 +154,21 @@ switch lower(data_request)
   mapping.label = '\kappa';
   mapping.method = 'signal';
   mapping.expression = [{'FPG'},{'k'}];
+ case 'kappa_top'
+  mapping.timedim = 1;
+  mapping.label = '\kappa^{top}';
+  mapping.method = 'signal';
+  mapping.expression = [{'FPG'},{'koben'}];
+ case 'kappa_bottom'
+  mapping.timedim = 1;
+  mapping.label = '\kappa_{bottom}';
+  mapping.method = 'signal';
+  mapping.expression = [{'FPG'},{'kuntn'}];
+ case 'li'
+  mapping.timedim = 1;
+  mapping.label = 'l_i';
+  mapping.method = 'signal';
+  mapping.expression = [{'FPG'},{'li'}];
  case 'mhd'
   mapping.timedim = 1;
   mapping.label = 'Odd and Even n';
@@ -260,6 +299,11 @@ switch lower(data_request)
   mapping.timedim = 1;
   mapping.gdat_timedim = 2;
   mapping.method = 'switchcase';
+ case 'tau_tot'
+  mapping.label = '\tau_{tot}';
+  mapping.timedim = 1;
+  mapping.method = 'signal';
+  mapping.expression = [{'TOT'},{'tau_tot'},{'AUGD'}];
  case 'te'
   mapping.timedim = 2;
   mapping.label = 'Te';
@@ -290,6 +334,16 @@ switch lower(data_request)
   mapping.timedim = 2;
   mapping.label = 'volume\_norm';
   mapping.method = 'switchcase';
+ case 'wmhd'
+  mapping.label = 'Wmhd';
+  mapping.timedim = 1;
+  mapping.method = 'signal';
+  mapping.expression = [{'FPG'},{'Wmhd'},{'AUGD'}];
+  mapping.method = 'expression';
+  mapping.expression = ['params_eff = gdat_data.gdat_params;params_eff.data_request=[{''FPG''},{''Wmhd''},{''AUGD''}];' ...
+		   'gdat_tmp=gdat_aug(shot,params_eff);ij=find(~isnan(gdat_tmp.data)); gdat_tmp.data_raw=gdat_tmp.data;' ...
+		    'tmp_data=interpos(gdat_tmp.t(ij),gdat_tmp.data(ij),gdat_tmp.t,-1e5);' ...
+		    'gdat_tmp.data = max(tmp_data,0.);'];
  case 'zeff'
   mapping.label = 'zeff from cxrs';
   mapping.timedim = 1;
diff --git a/crpptbx/AUG/gdat_aug.m b/crpptbx/AUG/gdat_aug.m
index 84c95934..82d7afbd 100644
--- a/crpptbx/AUG/gdat_aug.m
+++ b/crpptbx/AUG/gdat_aug.m
@@ -82,7 +82,7 @@ if ~isempty(data_request_names.aug)
     data_request_names.all.(aug_names{i}) = data_request_names.aug.(aug_names{i});
   end
 end
-data_request_names_all = fieldnames(data_request_names.all);
+data_request_names_all = sort(fieldnames(data_request_names.all));
 
 % construct default output structure
 gdat_data.data = [];
@@ -346,7 +346,9 @@ elseif strcmp(mapping_for_aug.method,'expression')
   fields_to_copy = {'gdat_params', 'gdat_request', 'label', 'data_fullpath', 'request_description', 'mapping_for'};
   eval([mapping_for_aug.expression ';']);
   for i=1:length(fields_to_copy)
-    gdat_tmp.(fields_to_copy{i}) = gdata_data_orig.(fields_to_copy{i});
+    if isfield(gdata_data_orig,fields_to_copy{i})
+      gdat_tmp.(fields_to_copy{i}) = gdata_data_orig.(fields_to_copy{i});
+    end
   end
   if isempty(gdat_tmp) || (~isstruct(gdat_tmp) & ~isobject(gdat_tmp))
     if (gdat_params.nverbose>=1); warning(['expression does not create a gdat_tmp structure: ' mapping_for_aug.expression]); end
diff --git a/crpptbx/JET/gdat_jet.m b/crpptbx/JET/gdat_jet.m
index f289ddce..19f65b7c 100644
--- a/crpptbx/JET/gdat_jet.m
+++ b/crpptbx/JET/gdat_jet.m
@@ -82,7 +82,7 @@ if ~isempty(data_request_names.jet)
     data_request_names.all.(jet_names{i}) = data_request_names.jet.(jet_names{i});
   end
 end
-data_request_names_all = fieldnames(data_request_names.all);
+data_request_names_all = sort(fieldnames(data_request_names.all));
 
 % construct default output structure
 gdat_data.data = [];
diff --git a/crpptbx/TCV/gdat_tcv.m b/crpptbx/TCV/gdat_tcv.m
index 5eb934dd..40fd682a 100644
--- a/crpptbx/TCV/gdat_tcv.m
+++ b/crpptbx/TCV/gdat_tcv.m
@@ -81,7 +81,7 @@ if ~isempty(data_request_names.tcv)
     data_request_names.all.(tcv_names{i}) = data_request_names.tcv.(tcv_names{i});
   end
 end
-data_request_names_all = fieldnames(data_request_names.all);
+data_request_names_all = sort(fieldnames(data_request_names.all));
 
 % construct default output structure
 gdat_data.data = [];
-- 
GitLab