load_externaldata_CMOD

PURPOSE ^

SYNOPSIS ^

function external = load_externaldata_CMOD(external_in,opt_gui)%(workdir,shotnum,shotime,t1,t2,opt_gui,dummy)

DESCRIPTION ^

 This function loads data from CMOD 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_CMOD(external_in,opt_gui)%(workdir,shotnum,shotime,t1,t2,opt_gui,dummy)
0002 %
0003 % This function loads data from CMOD 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     %
0020     % description & user halp
0021     %
0022     external.info.workdir = 'directory for source files';
0023     external.info.shotnum = 'Shot number';
0024     external.info.shotime = 'Shot time (s)';
0025     %
0026     % expert mode
0027     %
0028     external.expert.workdir = 0;
0029     external.expert.shotnum = 0;
0030     external.expert.shotime = 0;
0031     %
0032     % range of values
0033     %
0034     external.values.workdir = '';
0035     external.values.shotnum = [0;Inf];
0036     external.values.shotime = [0;Inf];
0037     %
0038     return
0039     %
0040 end
0041 %
0042 if nargin < 2,
0043     opt_gui = false;
0044 end
0045 %
0046 keyboard
0047 workdir = external_in.workdir;
0048 shotnum = external_in.shotnum;
0049 shotime = external_in.shotime;
0050 %
0051 % ******************************************************************
0052 %
0053 external = '';
0054 basestr = 'CMOD';
0055 %
0056 if ~isempty(workdir) && workdir(end) ~= filesep,
0057     workdir = [workdir,filesep];
0058 end
0059 %
0060 shotnum = num2str(shotnum);
0061 %
0062 external.basestr = basestr;
0063 external.shotnum = shotnum;
0064 external.shotime = shotime;
0065 %
0066 if ~ischar(shotime),
0067     shotime = num2str(round(shotime));
0068 end
0069 %
0070 shotnum = [repmat('0',[1,6-length(shotnum)]),shotnum];
0071 shotime = [repmat('0',[1,5-length(shotime)]),shotime];
0072 %
0073 filename = [workdir,'jbdirections_',shotnum,'_',shotime,'.mat'];
0074 %
0075 if exist(filename,'file'),
0076     external.equil = load([workdir,'jbdirections_',shotnum,'_',shotime,'.mat']);
0077     display([' --> Ip direction is ',external.equil.jbdirections.Ip]);
0078     display([' --> Bt direction is ',external.equil.jbdirections.Bt]);
0079 else
0080 %%    error(['The file jbdirections_',shotnum,'.',shotime,'.mat is missing in the directory ',workdir]);
0081 end
0082 %
0083 filename = [workdir,'g',shotnum,'_',shotime];
0084 %
0085 if exist(filename,'file'),
0086     external.equil.magnetic.eqdsk = fileread(filename);
0087     external.equil.shotnum = shotnum;
0088     external.equil.shotime = shotime;
0089 else
0090     error(['The EQDSK file g',shotnum,'.',shotime,' is missing in the directory ',workdir]);
0091 end
0092 %
0093 filename = [workdir,'profiles_',shotnum,'.',shotime,'.mat'];
0094 %
0095 if exist(filename,'file'),
0096     external.equil.prof = load([workdir,'profiles_',shotnum,'.',shotime,'.mat']);
0097 else
0098     error(['The file profiles_',shotnum,'.',shotime,'.mat is missing in the directory ',workdir]);
0099 end
0100 %
0101 filename = [workdir,'species_',shotnum,'.',shotime,'.mat'];
0102 %
0103 if exist(filename,'file'),
0104     external.equil.prof.species = load([workdir,'species_',shotnum,'.',shotime,'.mat']);
0105 else
0106     error(['The file species_',shotnum,'.',shotime,'.mat is missing in the directory ',workdir]);
0107 end
0108 %
0109 filename = [workdir,'LH_antenna_3p70Ghz_',shotnum,'.',shotime,'.mat'];
0110 %
0111 if exist(filename,'file'),
0112     external.wave.LH.antenna_3p70Ghz = load([workdir,'LH_antenna_3p70Ghz_',shotnum,'.',shotime,'.mat']);
0113 else
0114     disp(['--> WARNING: The file LH_antenna_3p70Ghz_',shotnum,'.',shotime,'.mat does not exist in the directory ',workdir]);
0115 end
0116 %
0117 filename = [workdir,'EC_mirror_68Ghz_',shotnum,'.',shotime,'.mat'];
0118 %
0119 if exist(filename,'file'),
0120     external.wave.EC.mirror_68Ghz = load([workdir,'EC_mirror_68Ghz_',shotnum,'.',shotime,'.mat']);
0121 else
0122     disp(['--> WARNING: The file EC_mirror_68Ghz_',shotnum,'.',shotime,'.mat does not exist in the directory ',workdir]);
0123 end
0124 %
0125 filename = [workdir,'EC_mirror_140Ghz_',shotnum,'.',shotime,'.mat'];
0126 %
0127 if exist(filename,'file'),
0128     external.wave.EC.mirror_140Ghz = load([workdir,'EC_mirror_140Ghz_',shotnum,'.',shotime,'.mat']);
0129 else
0130     disp(['--> WARNING: The file EC_mirror_140Ghz_',shotnum,'.',shotime,'.mat does not exist in the directory ',workdir]);
0131 end
0132 %
0133 filename = [workdir,'vloop_',shotnum,'.',shotime,'.mat'];
0134 %
0135 if exist(filename,'file'),
0136     external.ohm = load([workdir,'vloop_',shotnum,'.',shotime,'.mat']);
0137 else
0138     disp(['--> WARNING: The file vloop_',shotnum,'.',shotime,'.mat does not exist in the directory ',workdir]);
0139 end
0140 %
0141 external.id = [basestr,'_',shotnum,'_',shotime]; 
0142 %
0143 if isnan_jd(external,0),
0144     disp('Warning : NaNs were found in the structure ''external'' : ')
0145     isnan_jd(external,1),
0146 end
0147 %

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