From e36e5bcb3f2397e9d34bf932aad55dbd99382a82 Mon Sep 17 00:00:00 2001
From: Olivier Sauter <Olivier.Sauter@epfl.ch>
Date: Tue, 26 Nov 2019 16:55:45 +0100
Subject: [PATCH] add psi_axis psi_bnd in core_profiles, correct psi and
 ec_launchers launching_positions

---
 matlab/TCV_IMAS/tcv_get_ids_core_profiles.m | 10 ++++++++++
 matlab/TCV_IMAS/tcv_get_ids_ec_launchers.m  | 10 ++++------
 matlab/get_grids_1d.m                       | 10 +++++++++-
 3 files changed, 23 insertions(+), 7 deletions(-)

diff --git a/matlab/TCV_IMAS/tcv_get_ids_core_profiles.m b/matlab/TCV_IMAS/tcv_get_ids_core_profiles.m
index 5d497abe..c6db74e2 100644
--- a/matlab/TCV_IMAS/tcv_get_ids_core_profiles.m
+++ b/matlab/TCV_IMAS/tcv_get_ids_core_profiles.m
@@ -47,6 +47,13 @@ temp_1d.fit.te_rho.gdat_params = temp_1d.te_rho.gdat_params;
 temp_1d.fit.te_rho.shot = temp_1d.te_rho.shot;
 temp_1d.fit.te_rho = get_grids_1d(temp_1d.fit.te_rho,1,1);
 
+params_eff.data_request = 'psi_axis';
+temp_1d.psi_axis = gdat(params_cores_profiles.shot,params_eff);
+temp_1d_desc.psi_axis = params_eff.data_request;
+params_eff.data_request = 'psi_edge';
+temp_1d.psi_edge = gdat(params_cores_profiles.shot,params_eff);
+temp_1d_desc.psi_edge = params_eff.data_request;
+
 temp_1d.fit.ne_rho = temp_1d.ne_rho.fit;
 if isempty(temp_1d.te_rho.fit.t)
   disp('te_rho.fit')
@@ -156,7 +163,10 @@ for it=1:length(ids_core_profiles.time)
   ids_core_profiles.profiles_1d{it}.grid.rho_tor_norm = temp_1d.fit.te_rho.grids_1d.rhotornorm(:,it);
   ids_core_profiles.profiles_1d{it}.grid.rho_tor = temp_1d.fit.te_rho.grids_1d.rhotornorm(:,it) ...
       .* temp_1d.fit.te_rho.grids_1d.rhotor_edge(it);
+  ids_core_profiles.profiles_1d{it}.grid.rho_pol_norm = temp_1d.fit.te_rho.grids_1d.rhopolnorm;
   ids_core_profiles.profiles_1d{it}.grid.psi = temp_1d.fit.te_rho.grids_1d.psi(:,it);
+  ids_core_profiles.profiles_1d{it}.grid.psi_magnetic_axis = 0. * temp_1d.fit.te_rho.grids_1d.psi(1,it);
+  ids_core_profiles.profiles_1d{it}.grid.psi_boundary = temp_1d.fit.te_rho.grids_1d.psi(end,it);
   ids_core_profiles.profiles_1d{it}.grid.volume = temp_1d.fit.te_rho.grids_1d.rhovolnorm(:,it).^2 ...
       .* temp_1d.fit.te_rho.grids_1d.volume_edge(it);
   ids_core_profiles.profiles_1d{it}.grid.area = interpos(temp_1d.area.x,area_cpt(:,it),temp_1d.fit.te_rho.grids_1d.rhopolnorm, ...
diff --git a/matlab/TCV_IMAS/tcv_get_ids_ec_launchers.m b/matlab/TCV_IMAS/tcv_get_ids_ec_launchers.m
index 680350bb..a132f2a3 100644
--- a/matlab/TCV_IMAS/tcv_get_ids_ec_launchers.m
+++ b/matlab/TCV_IMAS/tcv_get_ids_ec_launchers.m
@@ -81,12 +81,10 @@ for iant=1:nb_launchers
     for i=1:length(it_ok{iant})
       r0 = sqrt(launch_params{iant}{it_ok{iant}(i)}.x0.^2 + launch_params{iant}{it_ok{iant}(i)}.y0.^2) / 100.; % in [m]
       time_launch = launch_params{iant}{it_ok{iant}(i)}.time;
-      ids_ec_launchers.launcher{iant}.launching_position.r.data(i) = r0;
-      ids_ec_launchers.launcher{iant}.launching_position.z.data(i) = launch_params{iant}{it_ok{iant}(i)}.z0/100.;
-      ids_ec_launchers.launcher{iant}.launching_position.phi.data(i) = atan2(launch_params{iant}{it_ok{iant}(i)}.y0/100,r0);
-      ids_ec_launchers.launcher{iant}.launching_position.r.time(i) = time_launch;
-      ids_ec_launchers.launcher{iant}.launching_position.z.time(i) = time_launch;
-      ids_ec_launchers.launcher{iant}.launching_position.phi.time(i) = time_launch;
+      ids_ec_launchers.launcher{iant}.launching_position.r(i) = r0;
+      ids_ec_launchers.launcher{iant}.launching_position.z(i) = launch_params{iant}{it_ok{iant}(i)}.z0/100.;
+      ids_ec_launchers.launcher{iant}.launching_position.phi(i) = atan2(launch_params{iant}{it_ok{iant}(i)}.y0/100,r0);
+      ids_ec_launchers.launcher{iant}.launching_position.time(i) = time_launch;
       kz = cos(launch_params{iant}{it_ok{iant}(i)}.theta_toray*pi/180.);
       kmr = -sin(launch_params{iant}{it_ok{iant}(i)}.theta_toray*pi/180.).*cos(launch_params{iant}{it_ok{iant}(i)}.phi_toray*pi/180.);
       kphi = sin(launch_params{iant}{it_ok{iant}(i)}.theta_toray*pi/180.).*sin(launch_params{iant}{it_ok{iant}(i)}.phi_toray*pi/180.); %*sigma_Rphiz (=+1 for TCV cocos=17)
diff --git a/matlab/get_grids_1d.m b/matlab/get_grids_1d.m
index 97931339..f8e00e4b 100644
--- a/matlab/get_grids_1d.m
+++ b/matlab/get_grids_1d.m
@@ -50,8 +50,16 @@ params_eff.data_request='psi_axis';
 psi_axis = gdat(gdat_data.shot,params_eff);
 params_eff.data_request='psi_edge';
 psi_edge = gdat(gdat_data.shot,params_eff);
+% $$$ gdat_data.grids_1d.psi_axis = psi_axis;
+% $$$ gdat_data.grids_1d.psi_edge = psi_edge;
+
 ij=~isnan(psi_axis.t);
-psi0_edge = interpos(63,psi_axis.t(ij),psi_axis.data(ij)-psi_edge.data(ij),gdat_data.t,-0.01);
+if ~strcmp(lower(params_eff.machine),'tcv')
+  psi0_edge = interpos(63,psi_axis.t(ij),psi_edge.data(ij) - psi_axis.data(ij),gdat_data.t,-0.01);
+else
+  psi0_edge = interpos(63,psi_axis.t(ij),0. - psi_axis.data(ij),gdat_data.t,-0.01);
+end
+gdat_data.grids_1d.psi_axis_edge = psi0_edge';
 if (nbdim_x == 1)
   gdat_data.grids_1d.psi = gdat_data.grids_1d.rhopolnorm.^2*reshape(psi0_edge,1,length(psi0_edge));
 elseif (nbdim_x == 2)
-- 
GitLab