From 562e52fb9a195165eaaec9a43ab0c4a0bded4cd5 Mon Sep 17 00:00:00 2001 From: Olivier Sauter <olivier.sauter@epfl.ch> Date: Wed, 26 Aug 2015 14:12:13 +0000 Subject: [PATCH] eqdsk at various times git-svn-id: https://spcsvn.epfl.ch/repos/TCV/gdat/trunk@4922 d63d8f72-b253-0410-a779-e742ad2e26cf --- crpptbx_new/TCV/gdat_tcv.m | 65 +++++++++++++++++++++++++------------- 1 file changed, 43 insertions(+), 22 deletions(-) diff --git a/crpptbx_new/TCV/gdat_tcv.m b/crpptbx_new/TCV/gdat_tcv.m index 536caf22..b4cfa20a 100644 --- a/crpptbx_new/TCV/gdat_tcv.m +++ b/crpptbx_new/TCV/gdat_tcv.m @@ -495,6 +495,8 @@ elseif strcmp(mapping_for_tcv.method,'switchcase') time=1.; % default time if isfield(gdat_data.gdat_params,'time') && ~isempty(gdat_data.gdat_params.time) time = gdat_data.gdat_params.time; + else + disp(['"time" is expected as an option, choose default time = ' num2str(time)]); end gdat_data.gdat_params.time = time; gdat_data.t = time; @@ -503,29 +505,48 @@ elseif strcmp(mapping_for_tcv.method,'switchcase') zshift = gdat_data.gdat_params.zshift; end gdat_data.gdat_params.zshift = zshift; - % use read_results updated to effectively obtain an eqdsk with sign correct with COCOS=2 - [fnames_readresults]=read_results_for_chease(shot,time,liuqe_version,3,[],[],[],zshift,0); - eqdskval=read_eqdsk(fnames_readresults{4},7); % LIUQE is 17 but read_results divided psi by 2pi thus 7 - for i=1:length(fnames_readresults) - unix(['rm ' fnames_readresults{i}]); - end - % transform to cocos=2 since read_results originally assumed it was cocos=2 - cocos_in = 2; - [eqdsk_cocos_in, eqdsk_cocosout_IpB0pos,cocos_inout]=eqdsk_cocos_transform(eqdskval,[7 cocos_in]); - fnamefull = fullfile(['/tmp/' getenv('USER')],['EQDSK_' num2str(shot) 't' num2str(time,'%.4f')]); - % We still write COCOS=2 case, since closer to standard (in /tmp) - write_eqdsk(fnamefull,eqdsk_cocos_in,cocos_in); - % Now gdat_tcv should return the convention from LIUQE which is COCOS=17, except if specified in option - % create standard filename name from shot, time (cocos will be added by write_eqdsk) - cocos_out = 17; - if isfield(gdat_data.gdat_params,'cocos') && ~isempty(gdat_data.gdat_params.cocos) - cocos_out = gdat_data.gdat_params.cocos; + for itime=1:length(time) + time_eff = time(itime) + % use read_results updated to effectively obtain an eqdsk with sign correct with COCOS=2 + [fnames_readresults]=read_results_for_chease(shot,time_eff,liuqe_version,3,[],[],[],zshift,0); + eqdskval=read_eqdsk(fnames_readresults{4},7); % LIUQE is 17 but read_results divided psi by 2pi thus 7 + for i=1:length(fnames_readresults) + unix(['rm ' fnames_readresults{i}]); + end + % transform to cocos=2 since read_results originally assumed it was cocos=2 + cocos_in = 2; + [eqdsk_cocos_in, eqdsk_cocosout_IpB0pos,cocos_inout]=eqdsk_cocos_transform(eqdskval,[7 cocos_in]); + fnamefull = fullfile(['/tmp/' getenv('USER')],['EQDSK_' num2str(shot) 't' num2str(time_eff,'%.4f')]); + % We still write COCOS=2 case, since closer to standard (in /tmp) + write_eqdsk(fnamefull,eqdsk_cocos_in,cocos_in); + % Now gdat_tcv should return the convention from LIUQE which is COCOS=17, except if specified in option + % create standard filename name from shot, time_eff (cocos will be added by write_eqdsk) + cocos_out = 17; + if isfield(gdat_data.gdat_params,'cocos') && ~isempty(gdat_data.gdat_params.cocos) + cocos_out = gdat_data.gdat_params.cocos; + end + [eqdsk_cocosout, eqdsk_cocosout_IpB0pos,cocos_inout]=eqdsk_cocos_transform(eqdsk_cocos_in,[cocos_in cocos_out]); + % for several times, use array of structure for eqdsks, + % cannot use it for psi(R,Z) in .data and .x since R, Z might be different at different times, + % so project psi(R,Z) on Rmesh, Zmesh of 1st time + if length(time) > 1 + gdat_data.eqdsk{itime} = write_eqdsk(fnamefull,eqdsk_cocosout,cocos_out); + if itime==1 + gdat_data.data(:,:,itime) = gdat_data.eqdsk{itime}.psi; + gdat_data.dim{1} = gdat_data.eqdsk{itime}.rmesh; + gdat_data.dim{2} = gdat_data.eqdsk{itime}.zmesh; + else + aa=interpos2Dcartesian(gdat_data.eqdsk{itime}.rmesh,gdat_data.eqdsk{itime}.zmesh, ... + gdat_data.eqdsk{itime}.psi,repmat(gdat_data.dim{1}',1,129),repmat(gdat_data.dim{2},129,1),-1,-1); + gdat_data.data(:,:,itime) = aa; + end + else + gdat_data.eqdsk = write_eqdsk(fnamefull,eqdsk_cocosout,cocos_out); + gdat_data.data = gdat_data.eqdsk.psi; + gdat_data.dim{1} = gdat_data.eqdsk.rmesh; + gdat_data.dim{2} = gdat_data.eqdsk.zmesh; + end end - [eqdsk_cocosout, eqdsk_cocosout_IpB0pos,cocos_inout]=eqdsk_cocos_transform(eqdsk_cocos_in,[cocos_in cocos_out]); - gdat_data.eqdsk = write_eqdsk(fnamefull,eqdsk_cocosout,cocos_out); - gdat_data.data = gdat_data.eqdsk.psi; - gdat_data.dim{1} = gdat_data.eqdsk.rmesh; - gdat_data.dim{2} = gdat_data.eqdsk.zmesh; gdat_data.dim{3} = gdat_data.t; gdat_data.x = gdat_data.dim(1:2); gdat_data.data_fullpath=['psi(R,Z) and eqdsk from read_eqdsk from LIUQE' num2str(liuqe_version) ';zshift=' num2str(zshift)]; -- GitLab