load_externaldata_TCV

PURPOSE ^

SYNOPSIS ^

function external = load_externaldata_TCV(external_in,opt_gui)

DESCRIPTION ^

 This function loads data from TCV database

 INPUTS : 
   - if nargin == 0, return default external_in to be modified interactively in iload_externaldata_jd

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function external = load_externaldata_TCV(external_in,opt_gui)
0002 %
0003 % This function loads data from TCV database
0004 %
0005 % INPUTS :
0006 %   - if nargin == 0, return default external_in to be modified interactively in iload_externaldata_jd
0007 
0008 %   - external_in : input structure.
0009 %   - opt_gui     : option for GUI within function (interactive mode only)
0010 %
0011 %
0012 if nargin == 0,
0013     %
0014     % default values
0015     %
0016     external.workdir = '';
0017     external.shotnum = 0;
0018     external.shotime = 0;
0019     external.t1 = 0;
0020     external.t2 = 0;
0021     %
0022     external.opt_file = false;
0023     external.liuqe = 1;
0024     external.launchers = 1:6;
0025     external.Xte = false;
0026     external.script = false;
0027     %
0028     % description & user halp
0029     %
0030     external.info.workdir = 'tmp directory for files saved by ''liuque'' and  ''collect_parameters_for_luke''';
0031     external.info.shotnum = 'Shot number';
0032     external.info.shotime = 'Shot time (s)';
0033     external.info.t1 = 'Minimum time for data averaging (s)';
0034     external.info.t2 = 'Maximum time for data averaging (s)';
0035     %
0036     external.info.opt_file = 'data source : (false) load data from database; (true) load data from existing files';
0037     external.info.liuqe = 'Option for liuqe version (1,2,3)';
0038     external.info.launchers = 'List of gyrotrons for ECRH data (1->9)';
0039     external.info.Xte = 'Te profile : (false) thomson scattering only; (true) renormalize TS profiles with Xte';
0040     external.info.script = 'generate an equivalent make_external_TCV script : (false) no (true) yes';
0041     %
0042     % expert mode
0043     %
0044     external.expert.workdir = 0;
0045     external.expert.shotnum = 0;
0046     external.expert.shotime = 0;
0047     external.expert.t1 = 0;
0048     external.expert.t2 = 0;
0049     %
0050     external.expert.opt_file = 1;
0051     external.expert.liuqe = 1;
0052     external.expert.launchers = 1;
0053     external.expert.Xte = 1;
0054     external.expert.script = 1;
0055     %
0056     % range of values
0057     %
0058     external.values.workdir = '';
0059     external.values.shotnum = [0;Inf];
0060     external.values.shotime = [0;Inf];
0061     external.values.t1 = [0;Inf];
0062     external.values.t2 = [0;Inf];
0063     %
0064     external.values.opt_file = {true,false};
0065     external.values.liuqe = 1:3;
0066     external.values.launchers = [0;9];
0067     external.values.Xte = {true,false};
0068     external.values.script = {true,false};
0069     %
0070     return
0071     %
0072 end
0073 %
0074 if nargin < 2,
0075     opt_gui = false;
0076 end
0077 %
0078 workdir = external_in.workdir;
0079 shotnum = external_in.shotnum;
0080 shotime = external_in.shotime;
0081 t1 = external_in.t1;
0082 t2 = external_in.t2;
0083 %
0084 opt_file = external_in.opt_file;
0085 liuqe = external_in.liuqe;
0086 launchers = external_in.launchers;
0087 Xte = external_in.Xte;
0088 script = external_in.script;
0089 %
0090 % ******************************************************************
0091 %
0092 external = '';
0093 basestr = 'TCV';
0094 %
0095 if isempty(workdir),
0096     workdir = pwd;
0097 end
0098 if workdir(end) ~= filesep,
0099     workdir = [workdir,filesep];
0100 end
0101 %
0102 eqdsk_path = workdir;
0103 %
0104 eqdsk_str = ['eqdsk.',num2str(shotnum),'t',num2str(shotime,'%6.4f')];
0105 %
0106 data_path = workdir;
0107 %
0108 data_str = ['data_',basestr,'_',num2str(shotnum),'_',num2str(t1),'_',num2str(t2)];
0109 %
0110 launstr = '';
0111 for il = 1:length(launchers),
0112     launstr = [launstr,'_',num2str(launchers(il))];
0113 end
0114 %
0115 if ~opt_file,
0116     %
0117     if ~exist('make_eqdsk.m','file'),
0118         disp('-----> Access to the TCV database is not granted.');
0119         disp('-----> You need the file make_eqdsk.m in the matlab path.');
0120         return;
0121     end
0122     %
0123     if ~exist('collect_parameters_for_luke.m','file'),
0124         disp('-----> Access to the TCV database is not granted.');
0125         disp('-----> You need the file collect_parameters_for_luke.m in the matlab path.');
0126         return;
0127     end
0128     %
0129     make_eqdsk(shotnum,shotime,workdir,'TCV',liuqe);%call LIUQUE
0130     %
0131     eqdsk_file = eqdsk_str;
0132     %
0133     data_file = [data_str,launstr,'.mat'];
0134     %
0135     collect_parameters_for_luke(shotnum,t1,t2,launchers,[workdir,data_file],Xte);%load shot parameters
0136     %
0137 else
0138     %
0139     eqdsk_file = 'eqdsk.*';
0140     %
0141     [eqdsk_file,eqdsk_path] = igetfile_jd(opt_gui,eqdsk_file,'Please select the EQDSK file',[eqdsk_path,eqdsk_str]);
0142     if eqdsk_file == 0,
0143         return
0144     else
0145         newshotnum = str2double(eqdsk_file(find(eqdsk_file == '.',1,'first')+1:find(eqdsk_file == 't',1,'first')-1));
0146         if ~isnan(newshotnum) && newshotnum ~= shotnum,
0147             disp(['Warning : shot number enforced to ',num2str(newshotnum),' by selecting EQDSK file'])
0148             shotnum = newshotnum;
0149         end
0150         %
0151         newshotime = str2double(eqdsk_file(find(eqdsk_file == 't',1,'first')+1:end));
0152         if ~isnan(newshotime) && newshotime ~= shotime,
0153             disp(['Warning : shot time enforced to ',num2str(newshotime),' by selecting EQDSK file'])
0154             shotime = newshotime;
0155         end
0156     end
0157     %
0158     data_file = ['data_',basestr,'_',num2str(shotnum),'*.mat'];
0159     %
0160     [data_file,data_path] = igetfile_jd(opt_gui,data_file,'Please select the data file',[data_path,data_file]);
0161     if data_file == 0,
0162         return
0163     else
0164         isep = [find(data_file == '_' ),strfind(data_file,'.mat')];
0165         %
0166         if length(isep) >= 5,
0167             newt1 = str2double(data_file(isep(3)+1:isep(4)-1));
0168             if ~isnan(newt1) && newt1 ~= t1,
0169                 disp(['Warning : time t1 enforced to ',num2str(newt1),' by selecting data file'])
0170                 t1 = newt1;
0171             end
0172             %
0173             newt2 = str2double(data_file(isep(4)+1:isep(5)-1));
0174             if ~isnan(newt2) && newt2 ~= t2,
0175                 disp(['Warning : time t2 enforced to ',num2str(newt2),' by selecting data file'])
0176                 t2 = newt2;
0177             end
0178             %
0179             newlaunstr = data_file(isep(5):isep(end)-1);
0180             if ~strcmp(newlaunstr,launstr),
0181                 disp(['Warning : launchers list enforced to ',newlaunstr,' by selecting data file'])
0182                 launstr = newlaunstr;
0183             end            
0184         end
0185     end
0186     %
0187 end
0188 %
0189 % return structure external
0190 %
0191 external.basestr = basestr;
0192 external.shotnum = num2str(shotnum);
0193 external.shotime = shotime;
0194 %
0195 external.equil.shotnum = external.shotnum;
0196 external.equil.shotime = external.shotime;
0197 %
0198 external.equil.magnetic.eqdsk_path = eqdsk_path;
0199 external.equil.magnetic.eqdsk_file = eqdsk_file;
0200 %
0201 external.equil.prof = load([data_path,data_file],'shot','rho','ne','te','ti','zeff','zaxis','btsign','ipsign','teflag','Ip');
0202 %
0203 external.equil.prof.data_path = data_path;
0204 external.equil.prof.data_file = data_file;
0205 external.wave = load([data_path,data_file],'shot','laun','angles*');
0206 external.ohm = load([data_path,data_file],'shot','vloop');
0207 %
0208 external.id = ['TCV_',external.shotnum,'_',num2str(shotime,'%6.4f'),'_',num2str(t1),'_',num2str(t2),'_L',launstr];
0209 %
0210 if ~opt_file && script,
0211     %
0212     imake_makeexternal_TCV_jd(workdir,external,opt_gui);
0213     %
0214 end    
0215 %
0216 if isnan_jd(external,0),
0217     disp('Warning : NaNs were found in the structure ''external'' : ')
0218 end
0219 %
0220 
0221

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