From 6f2f197ae1bdc12e2d1c5cc2a4244d17869df8ba Mon Sep 17 00:00:00 2001
From: Olivier Sauter <olivier.sauter@epfl.ch>
Date: Wed, 4 Nov 2015 18:04:47 +0000
Subject: [PATCH] added nete_rho

git-svn-id: https://spcsvn.epfl.ch/repos/TCV/gdat/trunk@5207 d63d8f72-b253-0410-a779-e742ad2e26cf
---
 crpptbx/AUG/gdat_aug.m | 62 +++++++++++++++++++++++++++---------------
 crpptbx/TCV/gdat_tcv.m |  2 +-
 2 files changed, 41 insertions(+), 23 deletions(-)

diff --git a/crpptbx/AUG/gdat_aug.m b/crpptbx/AUG/gdat_aug.m
index 54fe15cf..33cf62c0 100644
--- a/crpptbx/AUG/gdat_aug.m
+++ b/crpptbx/AUG/gdat_aug.m
@@ -199,17 +199,20 @@ end
 data_request_eff = gdat_params.data_request; % in case was defined in pairs
 
 % if it is a request_keyword can obtain description:
-if length(data_request_eff)==1
+if ischar(data_request_eff) || length(data_request_eff)==1
   ij=strmatch(data_request_eff,data_request_names_all,'exact');
 else
   ij=[];
 end
+
 if ~isempty(ij); 
   gdat_data.gdat_request = data_request_names_all{ij};
   if isfield(data_request_names.all.(data_request_names_all{ij}),'description') && ~isempty(data_request_names.all.(data_request_names_all{ij}).description)
     % copy description of keyword
     gdat_data.request_description = data_request_names.all.(data_request_names_all{ij}).description;
   end
+else
+  if ~isempty(data_request_eff); gdat_data.gdat_request = data_request_eff; end
 end
 
 % special treatment if shot and data_request given within pairs
@@ -221,7 +224,7 @@ end
 
 if ~isfield(gdat_params,'data_request') || isempty(gdat_params.data_request)
   % warning('input for ''data_request'' missing from input arguments') % might be correct, asking for list of requests
-  error_status=5
+  error_status=5;
   return
 end
 gdat_data.gdat_params = gdat_params;
@@ -964,6 +967,8 @@ elseif strcmp(mapping_for_aug.method,'switchcase')
     params_eff.data_request=data_request_eff(1:2); % start with ne if nete_rho
     % get raw data
     [gdat_data,params_kin,error_status]=gdat_aug(shot,params_eff);
+    gdat_data.gdat_params.data_request=data_request_eff;
+    gdat_data.gdat_request=data_request_eff;
     if error_status>0
       if gdat_params.nverbose>=3; disp(['problems with ' params_eff.data_request]); end
       return
@@ -1038,40 +1043,53 @@ elseif strcmp(mapping_for_aug.method,'switchcase')
     gdat_data.(lower(node_child_nameeff_e)).rhopolnorm = rhopolnorm_out_edge;
     gdat_data.(lower(node_child_nameeff_e)).rhotornorm = rhotornorm_out_edge;
     gdat_data.(lower(node_child_nameeff_e)).rhovolnorm = rhovolnorm_out_edge;
-    % put values of rhopolnorm for dim{1} by default
+    % put values of rhopolnorm for dim{1} by default, all radial mesh for combined core, edge in grids_1d
     gdat_data.x = gdat_data.(lower(node_child_nameeff)).rhopolnorm;
     iaaa=iroundos(gdat_data.(lower(node_child_nameeff_e)).t,gdat_data.(lower(node_child_nameeff)).t);
     gdat_data.x(inb_chord_core+1:inb_chord_core+inb_chord_edge,:) = gdat_data.(lower(node_child_nameeff_e)).rhopolnorm(:,iaaa);
     gdat_data.dim{1} = gdat_data.x;
     gdat_data.dimunits{1} = 'rhopolnorm';
+    gdat_data.grids_1d.rhopolnorm = gdat_data.x;
+    gdat_data.grids_1d.psi = gdat_data.(lower(node_child_nameeff)).psi;
+    gdat_data.grids_1d.psi(inb_chord_core+1:inb_chord_core+inb_chord_edge,:) = gdat_data.(lower(node_child_nameeff_e)).psi(:,iaaa);
+    gdat_data.grids_1d.rhotornorm = gdat_data.(lower(node_child_nameeff)).rhotornorm;
+    gdat_data.grids_1d.rhotornorm(inb_chord_core+1:inb_chord_core+inb_chord_edge,:) = gdat_data.(lower(node_child_nameeff_e)).rhotornorm(:,iaaa);
+    gdat_data.grids_1d.rhovolnorm = gdat_data.(lower(node_child_nameeff)).rhovolnorm;
+    gdat_data.grids_1d.rhovolnorm(inb_chord_core+1:inb_chord_core+inb_chord_edge,:) = gdat_data.(lower(node_child_nameeff_e)).rhovolnorm(:,iaaa);
+
     gdat_data.data_fullpath = [gdat_data.data_fullpath ' projected on equilibrium ' gdat_data.gdat_params.equil];
 
     % if nete_rho, copy data as .ne, get .te and put pe=e ne Te in data:
+    gdat_data.(data_request_eff(1:2)).data = gdat_data.data;
+    gdat_data.(data_request_eff(1:2)).error_bar = gdat_data.error_bar;
+    gdat_data.(data_request_eff(1:2)).units = gdat_data.units;
+    gdat_data.(data_request_eff(1:2)).core = gdat_data.([data_request_eff(1:2) '_core']);
+    gdat_data.(data_request_eff(1:2)).edge = gdat_data.([data_request_eff(1:2) '_edge']);
+    gdat_data = rmfield(gdat_data,{[data_request_eff(1:2) '_core'],[data_request_eff(1:2) '_edge']});
     if strcmp(data_request_eff(1:4),'nete')
-      % note, now has ne.data_raw for density without fir_to_thomson_ratio
-      gdat_data.ne.data = gdat_data.data;
-      gdat_data.ne.error_bar = gdat_data.error_bar;
-      gdat_data.ne.units = 'm^{-3}';
-      gdat_data.ne.ne_core = gdat_data.ne_core;
-      gdat_data.ne.ne_edge = gdat_data.ne_edge;
-      gdat_data = rmfield(gdat_data,{'ne_core','ne_edge'});
-      %
       params_eff.data_request=data_request_eff(3:4);
       [gdat_data_te,params_kin,error_status]=gdat_aug(shot,params_eff);
       gdat_data.te.data = gdat_data_te.data;
       gdat_data.te.error_bar = gdat_data_te.error_bar;
       gdat_data.te.units = gdat_data_te.units;
-      gdat_data.te.te_core = gdat_data_te.te_core;
-      gdat_data.te.te_edge = gdat_data_te.te_edge;
-      gdat_data.te.error_bar = gdat_data_te.te.error_bar;
-      gdat_data.te.te_core.psi = gdat_data.ne.ne_core.psi;
-      gdat_data.te.te_core.rhopolnorm = gdat_data.ne.ne_core.rhopolnorm;
-      gdat_data.te.te_core.rhotornorm = gdat_data.ne.ne_core.rhotornorm;
-      gdat_data.te.te_core.rhovolnorm = gdat_data.ne.ne_core.rhovolnorm;
-      gdat_data.te.te_edge.psi = gdat_data.ne.ne_edge.psi;
-      gdat_data.te.te_edge.rhopolnorm = gdat_data.ne.ne_edge.rhopolnorm;
-      gdat_data.te.te_edge.rhotornorm = gdat_data.ne.ne_edge.rhotornorm;
-      gdat_data.te.te_edge.rhovolnorm = gdat_data.ne.ne_edge.rhovolnorm;
+      gdat_data.te.core = gdat_data_te.te_core;
+      gdat_data.te.edge = gdat_data_te.te_edge;
+      gdat_data.te.error_bar = gdat_data_te.error_bar;
+      gdat_data.te.core.psi = gdat_data.ne.core.psi;
+      gdat_data.te.core.rhopolnorm = gdat_data.ne.core.rhopolnorm;
+      gdat_data.te.core.rhotornorm = gdat_data.ne.core.rhotornorm;
+      gdat_data.te.core.rhovolnorm = gdat_data.ne.core.rhovolnorm;
+      gdat_data.te.edge.psi = gdat_data.ne.edge.psi;
+      gdat_data.te.edge.rhopolnorm = gdat_data.ne.edge.rhopolnorm;
+      gdat_data.te.edge.rhotornorm = gdat_data.ne.edge.rhotornorm;
+      gdat_data.te.edge.rhovolnorm = gdat_data.ne.edge.rhovolnorm;
+      % put pe in main gdat_data
+      gdat_data.data = 1.6022e-19.*gdat_data.ne.data.*gdat_data.te.data;
+      gdat_data.error_bar = 1.6022e-19 .* (gdat_data.ne.data .* gdat_data.te.error_bar ...
+          + gdat_data.te.data .* gdat_data.ne.error_bar);
+      gdat_data.units='N/m^2; 1.6022e-19 ne Te';
+      gdat_data.data_fullpath=['pe=1.6e-19*ne*Te in data, .ne, .te ' gdat_data.data_fullpath(3:end)];
+      gdat_data.label = 'pe';
     end
     
     %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
diff --git a/crpptbx/TCV/gdat_tcv.m b/crpptbx/TCV/gdat_tcv.m
index 879b38a4..b0992745 100644
--- a/crpptbx/TCV/gdat_tcv.m
+++ b/crpptbx/TCV/gdat_tcv.m
@@ -212,7 +212,7 @@ end
 data_request_eff = gdat_params.data_request; % in case was defined in pairs
 
 % if it is a request_keyword copy it:
-if length(data_request_eff)==1
+if ischar(data_request_eff) || length(data_request_eff)==1
   ij=strmatch(data_request_eff,data_request_names_all,'exact');
 else
   ij=[];
-- 
GitLab