Skip to content
Snippets Groups Projects
Commit 2a3ac81d authored by Olivier Sauter's avatar Olivier Sauter
Browse files

adapt run_torbeam_fullshot.m to work with/without IDA automatically and add plot_torbeam.m

git-svn-id: https://spcsvn.epfl.ch/repos/TCV/gdat/trunk@4426 d63d8f72-b253-0410-a779-e742ad2e26cf
parent e868989f
No related branches found
No related tags found
No related merge requests found
function fig_handles=plot_torbeam(torbeam_out_struct,varargin);
%
% fig_handles=plot_torbeam(torbeam_out_struct,varargin);
%
% Default plots of structure torbeam_out_struct obtained from run_torbeam_fullshot.m
%
% varargin: list of fields to be plotted versus time
% (default: 'pow','rhopol_dep', 'pdens_peak', 'rhopol_pdens_width')
%
% []: if empty then a list with multiple choice is proposed
%
fig_handles = [];
if isempty(torbeam_out_struct); return; end
set_colos;
list_fields = {'pow','rhopol_dep', 'pdens_peak', 'rhopol_pdens_width'};
abc=cat(1,torbeam_out_struct{:});
tb_fields = [];
if ~isempty(abc); tb_fields = fields(abc(1)); end
if nargin >= 2
if isempty(varargin{1})
% asks from list
if ~isempty(tb_fields)
h_for_waitfor=figure;
global field_chosen2
h1=uicontrol('Style','listbox','string',tb_fields,'pos',[20 20 200 300],'Max',20, ...
'callback', ['global field_chosen2;field_chosen2=get(gcbo,''value'') ;']);
h2=uicontrol('Style','text','pos',[20 330 200 30],'string','choose fields to plot (ctrl-enter for multiple choices) then quit');
h3=uicontrol('Style','pushbutton','string','quit','pos',[300 20 30 20],'callback', ['field_chosen=get(' num2str(h1,'%.15e') ',''value''); close gcf;']);
waitfor(h_for_waitfor);
list_fields = tb_fields(field_chosen2);
clear global field_chosen2
else
disp('torbeam_out_struct empty');
return
end
elseif length(varargin) == 1
list_fields = varargin{1};
else
list_fields = varargin;
end
end
for ifield=1:length(list_fields)
titleg = [];
eval(['fig_handles.' list_fields{ifield} '.fig = figure(''name'',''' list_fields{ifield} ''');']);
for igyro=1:length(torbeam_out_struct)
if ~isempty(torbeam_out_struct{igyro})
eval(['array_to_plot = torbeam_out_struct{igyro}.' list_fields{ifield} ';']);
plotos(torbeam_out_struct{igyro}.time,array_to_plot,'-',[],[],colos(igyro,:));
hold on
titleg{end+1} = ['L' num2str(igyro)];
end
end
if ~isempty(titleg) ; legend(titleg); end
eval(['fig_handles.' list_fields{ifield} '.titleg = titleg;']);
xlabel('time [s]')
eval(['ylabel(''' list_fields{ifield} ''');']);
title(['AUG #' num2str(torbeam_out_struct{igyro}.shot(1))]);
end
function [torbeam_out_struct, file_out_prefix]=run_torbeam_fullshot(shot,varargin); function [torbeam_out_struct, file_out_prefix]=run_torbeam_fullshot(shot,varargin);
% %
% [torbeam_out_struct, file_out_prefix]=run_torbeam_fullshot(shot,varargin);
%
% Run tbdemo, using line command execution of TORBEAM, to run torbeam acroos full shot on reduced time axis % Run tbdemo, using line command execution of TORBEAM, to run torbeam acroos full shot on reduced time axis
% %
% shot: shot number for which to run Torbeam. % shot: shot number for which to run Torbeam.
% If empty or not given, ask for it % If empty or not given, ask for it
% if negative, assume output file exists, do not re-run TORBEAM and just reads data into structure torbeam_out_struct % if negative, assume output file exists, do not re-run TORBEAM and just reads data into structure torbeam_out_struct
% %
% varargin{1:2}: 'time',time_array: time points for which to run Torbeam (by default run every 50ms for each ECRH2 gyrotron having power>0) % varargin given in pairs: 'keyword', value
% varargin{3:4}: 'file_prefix', filename_prefix: results are saved on [filename '_gyroXX.dat'] (default: tbdemo_shot_gyroXX.dat with XX being the gyro nb) % 'time',time_array: time points for which to run Torbeam (by default run every 50ms for each ECRH2 gyrotron having power>0)
% 'file_prefix', filename_prefix: results are saved on [filename '_gyroXX.dat'] (default: tbdemo_shot_gyroXX.dat with XX being the gyro nb)
% %
% Examples: % Examples:
% torbeam_out_struct = run_torbeam_fullshot(shot); % standard call to run Torbeam % torbeam_out_struct = run_torbeam_fullshot(shot); % standard call to run Torbeam
...@@ -16,6 +19,8 @@ function [torbeam_out_struct, file_out_prefix]=run_torbeam_fullshot(shot,varargi ...@@ -16,6 +19,8 @@ function [torbeam_out_struct, file_out_prefix]=run_torbeam_fullshot(shot,varargi
% torbeam_out_struct = run_torbeam_fullshot(shot,'time',linspace(tstart,tend,nbpoints)); % to run on given time array % torbeam_out_struct = run_torbeam_fullshot(shot,'time',linspace(tstart,tend,nbpoints)); % to run on given time array
% torbeam_out_struct = run_torbeam_fullshot(shot,'time',[t1 t2 t3...],'file_prefix','tbdemo_shot_fewtimes_gyro'); % to run on specific times % torbeam_out_struct = run_torbeam_fullshot(shot,'time',[t1 t2 t3...],'file_prefix','tbdemo_shot_fewtimes_gyro'); % to run on specific times
torbeam_out_struct = [];
if ~exist('shot') if ~exist('shot')
shot=input('shot: '); shot=input('shot: ');
end end
...@@ -42,7 +47,15 @@ end ...@@ -42,7 +47,15 @@ end
if shot>0 if shot>0
pgyro=gdat(shot,'pgyro',1); pgyro=gdat(shot,'pgyro',1);
for igyro=5:8 run_with_IDA = 0;
% test if IDA present
hhh = sfread('IDA', shot);
if hhh.handle~=0;
run_with_IDA = 1;
disp('use IDA since shotfile exists')
end
for igyro=1:8
filename=[file_out_prefix num2str(igyro) '.dat']; filename=[file_out_prefix num2str(igyro) '.dat'];
unix(['rm ' filename ' >& /dev/null']); % since cannot write over an existing file by default unix(['rm ' filename ' >& /dev/null']); % since cannot write over an existing file by default
unix(['rm ' '.' filename ' >& /dev/null']); % since cannot write over an existing file by default unix(['rm ' '.' filename ' >& /dev/null']); % since cannot write over an existing file by default
...@@ -55,25 +68,43 @@ if shot>0 ...@@ -55,25 +68,43 @@ if shot>0
disp(['running system ' num2str(igyro) '...']); disp(['running system ' num2str(igyro) '...']);
for j=1:length(itt_tok) for j=1:length(itt_tok)
if pgyro_tok(j)>1e5 if pgyro_tok(j)>1e5
[a,b]=unix(['ssh sxaug21.aug.ipp.mpg.de ~rem/public/tbm_demo/tbmdemo -batch -silent -shot ' num2str(shot) ' -time ' num2str(time_array(itt_tok(j))) ' -system ' num2str(igyro) ' -usedcr -eqdiag EQI -betapol -usemirror -cdrive 1 >> ' ['.' filename]]); if run_with_IDA==0
% [a,b]=unix(['ssh sxaug21.aug.ipp.mpg.de ~rem/public/tbm_demo/tbmdemo -batch -silent -shot ' num2str(shot) ' -time ' num2str(time_array(itt_tok(j))) ' -system ' num2str(igyro) ' -usedcr -eqdiag EQI -betapol -usemirror -cdrive 1 >> ' ['.' filename]]);
[a,b]=unix(['ssh sxaug21.aug.ipp.mpg.de ~rem/public/tbm_demo/tbmdemo -batch -silent -shot ' num2str(shot) ' -time ' num2str(time_array(itt_tok(j))) ' -system ' num2str(igyro) ' -ntm -usedcr -eqdiag EQI -betapol -usemirror -cdrive 1 >> ' ['.' filename]]);
else
% -shot 29672 -time 3.0 -system 5 -batch -ntm -silent -usemirror -cdrive 1
[a,b]=unix(['ssh sxaug21.aug.ipp.mpg.de ~rem/public/tbm_demo/tbmdemo -batch -silent -shot ' num2str(shot) ' -time ' num2str(time_array(itt_tok(j))) ' -system ' num2str(igyro) ' -ntm -usemirror -cdrive 1 >> ' ['.' filename]]);
end
end end
end end
[a,b]=unix(['grep -v ''could not''' ' .' filename '| grep -v ''invalid'' > ' filename]); % [a,b]=unix(['grep -v ''could not''' ' .' filename '| grep -v ''invalid'' | grep -v ''Error'' | egrep -e ''^$'' -v > ' filename]);
[a,b]=unix(['egrep -e ''^Shot''' ' .' filename ' > ' filename]);
end end
end end
end end
end end
for igyro=5:8 for igyro=1:8
try try
eval(['[gyro_tbnam,tbout{igyro}.gyro,shot_tbnam,tbout{igyro}.shot,time_tbnam,tbout{igyro}.time,pol_tbnam,tbout{igyro}.pol,tor_tbnam,tbout{igyro}.tor,' ... eval(['[shot_tbnam,tbout{igyro}.shot,time_tbnam,tbout{igyro}.time,gyro_tbnam,tbout{igyro}.gyro,pol_tbnam,tbout{igyro}.pol,tor_tbnam,tbout{igyro}.tor,' ...
'pow_tbnam,tbout{igyro}.pow,r_tbnam,tbout{igyro}.r,z_tbnam,tbout{igyro}.z,pwr_dep_tbnam,tbout{igyro}.rhopol_pwr_dep,rhopol_cd_dep_tbnam,tbout{igyro}.rhopol_cd_dep,jcd_peak_tbnam,' ... 'pow_tbnam,tbout{igyro}.pow,r_tbnam,tbout{igyro}.r,z_tbnam,tbout{igyro}.z,rho_tbnam,tbout{igyro}.rhopol_dep,pwr_dep_tbnam,tbout{igyro}.rhopol_pwr_dep,rhopol_cd_dep_tbnam,tbout{igyro}.rhopol_cd_dep,pdens_peak_tbnam,' ...
'tbout{igyro}.jcd_peak,rhopol_c_wid_tbnam,tbout{igyro}.rhopol_c_wid,pni_tbnam,tbout{igyro}.pni,picr_tbnam,tbout{igyro}.picr,prad_tbnam,tbout{igyro}.prad,' ... 'tbout{igyro}.pdens_peak,rhopol_pdens_wid_tbnam,tbout{igyro}.rhopol_pdens_width,jcd_peak_tbnam,tbout{igyro}.jcd_peak,rhopol_c_wid_tbnam,tbout{igyro}.rhopol_jcd_width,pni_tbnam,tbout{igyro}.pni,picr_tbnam,tbout{igyro}.picr,prad_tbnam,tbout{igyro}.prad,' ...
'betan_tbnam,tbout{igyro}.betan,ipl_tbnam,tbout{igyro}.ipl,bt_tbnam,tbout{igyro}.bt,a1_tbnam,tbout{igyro}.a1,a2_tbnam,tbout{igyro}.a2,rhopolntm_tbnam,tbout{igyro}.rhopolntm]=' ... 'betan_tbnam,tbout{igyro}.betan,ipl_tbnam,tbout{igyro}.ipl,bt_tbnam,tbout{igyro}.bt,a1_tbnam,tbout{igyro}.ampN1,a2_tbnam,tbout{igyro}.ampN2,rhopolntm_tbnam,tbout{igyro}.rhopolntm]=' ...
'textread(''' file_out_prefix num2str(igyro) '.dat'',''%s%d%s%d%s%f%s%f%s%f%s%f%s%f%s%f%s%f%s%f%s%f%s%f%s%f%s%f%s%f%s%f%s%f%s%f%s%f%s%f%s%f'');']); 'textread(''' file_out_prefix num2str(igyro) '.dat'',''%s%d%s%f%s%f%s%f%s%f%s%f%s%f%s%f%s%f%s%f%s%f%s%f%s%f%s%f%s%f%s%f%s%f%s%f%s%f%s%f%s%f%s%f%s%f%s%f'');']);
% eval(['[gyro_tbnam,tbout{igyro}.gyro,shot_tbnam,tbout{igyro}.shot,time_tbnam,tbout{igyro}.time,pol_tbnam,tbout{igyro}.pol,tor_tbnam,tbout{igyro}.tor,' ...
% 'pow_tbnam,tbout{igyro}.pow,r_tbnam,tbout{igyro}.r,z_tbnam,tbout{igyro}.z,pwr_dep_tbnam,tbout{igyro}.rhopol_pwr_dep,rhopol_cd_dep_tbnam,tbout{igyro}.rhopol_cd_dep,jcd_peak_tbnam,' ...
% 'tbout{igyro}.jcd_peak,rhopol_c_wid_tbnam,tbout{igyro}.rhopol_c_wid,pni_tbnam,tbout{igyro}.pni,picr_tbnam,tbout{igyro}.picr,prad_tbnam,tbout{igyro}.prad,' ...
% 'betan_tbnam,tbout{igyro}.betan,ipl_tbnam,tbout{igyro}.ipl,bt_tbnam,tbout{igyro}.bt,a1_tbnam,tbout{igyro}.a1,a2_tbnam,tbout{igyro}.a2,rhopolntm_tbnam,tbout{igyro}.rhopolntm]=' ...
% 'textread(''' file_out_prefix num2str(igyro) '.dat'',''%s%d%s%d%s%f%s%f%s%f%s%f%s%f%s%f%s%f%s%f%s%f%s%f%s%f%s%f%s%f%s%f%s%f%s%f%s%f%s%f%s%f'');']);
catch catch
disp(['problems reading file ' file_out_prefix num2str(igyro) '.dat: may be some errors with tbdemo, check file, skipped']) disp(['problems reading file ' file_out_prefix num2str(igyro) '.dat: may be some errors with tbdemo, check file, skipped'])
end end
end end
torbeam_out_struct = tbout; if exist('tbout');
torbeam_out_struct = tbout;
end
fig_handles=plot_torbeam(torbeam_out_struct);
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment