imake_makeexternal_TCV_jd

PURPOSE ^

SYNOPSIS ^

function imake_makeexternal_TCV_jd(workdir,external,opt_gui)

DESCRIPTION ^

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function imake_makeexternal_TCV_jd(workdir,external,opt_gui)
0002 %
0003 if nargin < 3,
0004     opt_gui = 1;
0005 end
0006 %
0007 % This function automatically generates a make_external_TCV script to generate external structures
0008 %
0009 externalstr = external.id;
0010 externalstr(externalstr == '.') = 'p';
0011 %
0012 [data_file,data_path] = iputfile_jd(opt_gui,'make_external_TCV*.m','Please provide a name for the make_external script',[workdir,'make_external_',externalstr,'.m']);
0013 %
0014 if data_file == 0,
0015     disp('-----> No make_external script name specified.');
0016     return
0017 end  
0018 %
0019 filename = [data_path,data_file];
0020 %
0021 basestr = 'TCV';
0022 %
0023 shotnum = external.equil.shotnum;
0024 shotime = external.equil.shotime;
0025 %
0026 it1 = length([basestr,'_',shotnum,'_',shotime,'_']) + 1;
0027 it2 = it1 - 1 + strfind(external.id(it1:end),'_');
0028 %
0029 t1 = external.id(it1:it2(1) - 1);
0030 t2 = external.id(it2(1) + 1:it2(2) - 1);
0031 %
0032 launchstr = external.id(it2(2) + 2:end);
0033 itL = strfind(launchstr,'_');
0034 %
0035 laun = '[';
0036 %
0037 for iL = 1:length(itL)-1,
0038     laun = [laun,launchstr(itL(iL) + 1:itL(iL+1) - 1),','];
0039 end
0040 laun = [laun,launchstr(itL(end) + 1:end),']'];
0041 %
0042 f_opt = external.equil.prof.teflag;
0043 %
0044 % RUN SCRIPT GENERATION
0045 %
0046 s = {};
0047 s = [s,{'% Script for generating external structure from TCV database'}];
0048 s = [s,{'%'}];
0049 s = [s,{'% This script is automatically generated by imake_makeexternal-TCV_jd.'}];
0050 s = [s,{'% by J. Decker (joan.decker@cea.fr) and Y. Peysson (yves.peysson@cea.fr)'}];
0051 s = [s,{'%'}];
0052 s = [s,{'clear all'}];
0053 s = [s,{'clear mex'}];
0054 s = [s,{'clear functions'}];
0055 s = [s,{'close all'}];
0056 s = [s,{'%'}];
0057 s = [s,{['basestr = ''',basestr,''';']}];
0058 s = [s,{'%'}];
0059 s = [s,{['workdir = ''',workdir,''';']}];
0060 s = [s,{'%'}];
0061 s = [s,{['shotnum = ',shotnum,';%shot number']}];
0062 s = [s,{['shotime = ',num2str(str2num(shotime)),';%shot time']}];
0063 s = [s,{'%'}];
0064 s = [s,{['t1 = ',t1,';% initial time for data averaging']}];
0065 s = [s,{['t2 = ',t2,';% final time for data averaging']}];
0066 s = [s,{'%'}];
0067 s = [s,{['laun = ',laun,';%Vector of EC launchers to account for (ex: [1,3])']}];
0068 s = [s,{'%'}];
0069 s = [s,{['f_opt = ',num2str(f_opt),';% (0) load Te from fitted Thomson only, (1) load Te with Xte renormalization']}];
0070 s = [s,{'%'}];
0071 s = [s,{'l_opt = 1;% Option for liuqe version (1,2,3)'}];
0072 s = [s,{'%'}];
0073 s = [s,{'% ------------------------------------------------------------------------------------'}];
0074 s = [s,{'%'}];
0075 s = [s,{'shotnumstr = num2str(shotnum);'}];
0076 s = [s,{'shotimestr = num2str(shotime,''%6.4f'');'}];
0077 s = [s,{'%'}];
0078 s = [s,{'eqdsk_path = [workdir,''/''];'}];
0079 s = [s,{'%'}];
0080 s = [s,{'eqdsk_file = [''eqdsk.'',shotnumstr,''t'',shotimestr];'}];
0081 s = [s,{'%'}];
0082 s = [s,{'data_path = [workdir,''/''];'}];
0083 s = [s,{'%'}];
0084 s = [s,{'data_str = [''data_'',basestr,''_'',shotnumstr,''_'',num2str(t1),''_'',num2str(t2)];'}];
0085 s = [s,{'%'}];
0086 s = [s,{'if ~exist(''make_eqdsk.m'',''file''),'}];
0087 s = [s,{'    disp(''-----> Access to the TCV database is not granted.'');'}];
0088 s = [s,{'    disp(''-----> You need the file make_eqdsk.m in the matlab path.'');'}];
0089 s = [s,{'    return;'}];
0090 s = [s,{'end'}];
0091 s = [s,{'%'}];
0092 s = [s,{'if ~exist(''collect_parameters_for_luke.m'',''file''),'}];
0093 s = [s,{'    disp(''-----> Access to the TCV database is not granted.'');'}];
0094 s = [s,{'    disp(''-----> You need the file collect_parameters_for_luke.m in the matlab path.'');'}];
0095 s = [s,{'    return;'}];
0096 s = [s,{'end'}];
0097 s = [s,{'%'}];
0098 s = [s,{['make_eqdsk(shotnum,shotime,workdir,''',basestr,''',l_opt);%call LIUQUE']}];
0099 s = [s,{'%'}];
0100 s = [s,{'launstr = '''';'}];
0101 s = [s,{'for il = 1:length(laun),'}];
0102 s = [s,{'    launstr = [launstr,''_'',num2str(laun(il))];'}];
0103 s = [s,{'end'}];
0104 s = [s,{'%'}];
0105 s = [s,{'data_path = [workdir,''/''];'}];
0106 s = [s,{'data_file = [data_str,launstr,''.mat''];'}];
0107 s = [s,{'%'}];
0108 s = [s,{'collect_parameters_for_luke(shotnum,t1,t2,laun,[data_path,data_file],f_opt);%load dhot parameters'}];
0109 s = [s,{'%'}];
0110 s = [s,{'% ------------------------------------------------------------------------------------'}];
0111 s = [s,{'%'}];
0112 s = [s,{'% return structure equil'}];
0113 s = [s,{'%'}];
0114 s = [s,{'external.equil.shotnum = shotnumstr;'}];
0115 s = [s,{'external.equil.shotime = shotimestr;'}];
0116 s = [s,{'external.equil.magnetic.eqdsk_path = eqdsk_path;'}];
0117 s = [s,{'external.equil.magnetic.eqdsk_file = eqdsk_file;'}];
0118 s = [s,{'%'}];
0119 s = [s,{'external.equil.prof = load([data_path,data_file],''shot'',''rho'',''ne'',''te'',''ti'',''zeff'',''zaxis'',''btsign'',''ipsign'',''teflag'');'}];
0120 s = [s,{'external.equil.prof.data_path = data_path;'}];
0121 s = [s,{'external.equil.prof.data_file = data_file;'}];
0122 s = [s,{'external.wave = load([data_path,data_file],''shot'',''laun'',''angles*'');'}];
0123 s = [s,{'external.ohm = load([data_path,data_file],''shot'',''vloop'');'}];
0124 s = [s,{'%'}];
0125 s = [s,{'external.id = [''TCV_'',shotnumstr,''_'',shotimestr,''_'',num2str(t1),''_'',num2str(t2),''_L'',launstr];'}];
0126 s = [s,{'%'}];
0127 s = [s,{'save_str = [''EXTERNAL_'',external.id,''.mat''];'}];
0128 s = [s,{'eval([''save '',save_str,'' external'']);'}];
0129 s = [s,{'%'}];
0130 s = [s,{'info_dke_yp(2,''External parameters saved'');'}];
0131 s = [s,{'%'}];
0132 %
0133 fid = fopen(filename,'w');
0134 %
0135 for is = 1:length(s),
0136     fprintf(fid,'%s\n',s{is});
0137 end
0138 %
0139 fclose(fid);
0140 disp(['-----> The make_external script ',filename,' has been created.']);
0141 %
0142

Community support and wiki are available on Redmine. Last update: 18-Apr-2019.