load_externaldata_D3D

PURPOSE ^

SYNOPSIS ^

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

DESCRIPTION ^

 This function loads data from DIII-D 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_D3D(external_in,opt_gui)%(workdir,shotnum,shotime,t1,t2,opt_gui,dummy)
0002 %
0003 % This function loads data from DIII-D 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 workdir = external_in.workdir;
0047 shotnum = external_in.shotnum;
0048 shotime = external_in.shotime;
0049 %
0050 % ******************************************************************
0051 %
0052 external = '';
0053 basestr = 'D3D';
0054 %
0055 if ~isempty(workdir) && workdir(end) ~= filesep,
0056     workdir = [workdir,filesep];
0057 end
0058 %
0059 shotnum = num2str(shotnum);
0060 %
0061 external.basestr = basestr;
0062 external.shotnum = shotnum;
0063 external.shotime = shotime;
0064 %
0065 if ~ischar(shotime),
0066     shotime = num2str(round(shotime));
0067 end
0068 %
0069 shotnum = [repmat('0',[1,6-length(shotnum)]),shotnum];
0070 shotime = [repmat('0',[1,5-length(shotime)]),shotime];
0071 %
0072 filename = [workdir,'jbdirections_',shotnum,'.',shotime,'.mat'];
0073 %
0074 if exist(filename,'file'),
0075     external.equil = load([workdir,'jbdirections_',shotnum,'_',shotime,'.mat']);
0076     display([' --> Ip direction is ',external.equil.jbdirections.Ip]);
0077     display([' --> Bt direction is ',external.equil.jbdirections.Bt]);
0078 else
0079     error(['The file jbdirections_',shotnum,'_',shotime,'.mat is missing in the directory ',workdir]);
0080 end
0081 %
0082 filename = [workdir,'g',shotnum,'.',shotime];
0083 %
0084 if exist(filename,'file'),
0085     external.equil.magnetic.eqdsk = fileread(filename);
0086     external.equil.shotnum = shotnum;
0087     external.equil.shotime = shotime;
0088 else
0089     error(['The EQDSK file g',shotnum,'.',shotime,' is missing in the directory ',workdir]);
0090 end
0091 %
0092 filename = [workdir,'profiles_',shotnum,'_',shotime,'.mat'];
0093 %
0094 if exist(filename,'file'),
0095     external.equil.prof = load([workdir,'profiles_',shotnum,'_',shotime,'.mat']);
0096 else
0097     error(['The file profiles_',shotnum,'_',shotime,'.mat is missing in the directory ',workdir]);
0098 end
0099 %
0100 filename = [workdir,'species_',shotnum,'_',shotime,'.mat'];
0101 %
0102 if exist(filename,'file'),
0103     external.equil.prof.species = load([workdir,'species_',shotnum,'_',shotime,'.mat']);
0104 else
0105     error(['The file species_',shotnum,'_',shotime,'.mat is missing in the directory ',workdir]);
0106 end
0107 %
0108 filename = [workdir,'EC_mirror_140Ghz_',shotnum,'_',shotime,'.mat'];
0109 %
0110 if exist(filename,'file'),
0111     external.wave.EC.mirror_140Ghz = load([workdir,'EC_mirror_140Ghz_',shotnum,'_',shotime,'.mat']);
0112 else
0113     disp(['--> WARNING: The file EC_mirror_140Ghz_',shotnum,'_',shotime,'.mat does not exist in the directory ',workdir]);
0114 end
0115 %
0116 filename = [workdir,'vloop_',shotnum,'_',shotime,'.mat'];
0117 %
0118 if exist(filename,'file'),
0119     external.ohm = load([workdir,'vloop_',shotnum,'_',shotime,'.mat']);
0120 else
0121     disp(['--> WARNING: The file vloop_',shotnum,'_',shotime,'.mat does not exist in the directory ',workdir]);
0122 end
0123 %
0124 external.id = [basestr,'_',shotnum,'_',shotime]; 
0125 %
0126 if isnan_jd(external,0),
0127     disp('Warning : NaNs were found in the structure ''external'' : ')
0128     isnan_jd(external,1),
0129 end
0130 %

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