0001 function angles = imake_angles_TCV_jd(data,shotnum,l_opt,force_mode,angles,opt_gui,style)
0002
0003
0004
0005
0006 if nargin < 5,
0007 angles = '';
0008 end
0009 if nargin < 4,
0010 force_mode = 0;
0011 end
0012 if nargin < 3,
0013 l_opt = NaN;
0014 end
0015 if nargin < 2,
0016 shotnum = '';
0017 end
0018 if nargin < 1,
0019 data = '';
0020 end
0021
0022 l_data = '';
0023
0024 if ~isempty(data),
0025
0026 if isfield(data,'shot'),
0027 ishot = find(data.shot == str2num(shotnum));
0028
0029 if isempty(ishot),
0030 disp(['-----> launching data not found for shot :',shotnum]);
0031 return
0032 end
0033
0034 if length(ishot) > 1,
0035 disp(['-----> WARNING : Several entries are found for shot :',shotnum,', first entry selected']);
0036 ishot = ishot(1);
0037 end
0038 end
0039
0040 if isnan(l_opt),
0041
0042 titletext = 'Select EC launcher :';
0043 nlaun = length(data.laun);
0044 s = {};
0045 launch_list = [];
0046 for ilaun = 1:nlaun,
0047 laun = data.laun(ilaun);
0048 P0 = data.(['angles_',num2str(laun)]).P0;
0049 if ~isnan(P0)
0050 launch_list(end+1) = laun;
0051 s{end+1} = ['Launcher # ',num2str(laun),' ; P = ',num2str(P0/1e3),' kW'];
0052 end
0053 end
0054 if isempty(launch_list),
0055 disp('-----> No valid launcher');
0056 return
0057 end
0058
0059 l_opt = launch_list(iselect_jd(s,titletext,opt_gui,style,1));
0060
0061 end
0062
0063 if isfield(data,'angles'),
0064
0065 angles = data.angles(l_opt == data.laun);
0066
0067 else
0068
0069 eval(['angles = data.angles_',num2str(l_opt),'(ishot);'])
0070
0071 if ~strcmp(shotnum,angles.id),
0072 disp('-----> Shot number mismatch. Verify data file');
0073 return
0074 end
0075
0076 end
0077
0078 angles_mod = struct;
0079 angles_mod.freq = angles.freq/1e9;
0080 angles_mod.P0 = angles.P0/1e3;
0081 if force_mode == 0,
0082 angles_mod = imod_struct_jd(angles_mod,'angles',1,opt_gui,struct,style);
0083 end
0084
0085 freq_new = angles_mod.freq*1e9;
0086 P0_new = angles_mod.P0*1e3;
0087
0088 if freq_new ~= angles.freq,
0089 disp(['-----> WARNING: frequency has been changed from ',num2str(angles.freq/1e9),' GHZ to ',num2str(freq_new/1e9),' GHZ']);
0090 angles.freq = freq_new;
0091 end
0092
0093 if P0_new ~= angles.P0 && (~isnan(P0_new) || ~isnan(angles.P0)),
0094 disp(['-----> WARNING: injected power has been changed from ',num2str(angles.P0/1e3),' kW to ',num2str(P0_new/1e3),' kW']);
0095 angles.P0 = P0_new;
0096 end
0097
0098 else
0099
0100 if isnan(l_opt),
0101 l_opt = iselect_jd({'L1','L2','L3','L4','L5','L6'},'Specify launcher',opt_gui,style,1,'popupmenu');
0102 end
0103
0104 if isempty(l_opt) || ~isnumeric(l_opt) || ~any(l_opt == 1:6),
0105 disp('-----> Invalid launcher selection.');
0106 return
0107 end
0108
0109
0110
0111 if any(l_opt == [1,4]),
0112
0113 P1_R = 1.30723;
0114 P1_Z = -0.05865;
0115 P1_theta = 52.013*pi/180;
0116 P2_R = 1.19056;
0117 P2_Z = 0.0645;
0118 P2_d = 0.01;
0119 P3_Z = -0.0025;
0120
0121 elseif any(l_opt == [2,3,5,6]),
0122
0123 P1_R = 1.30723;
0124 P1_Z = 0.39885;
0125 P1_theta = 52.013*pi/180;
0126 P2_R = 1.1906;
0127 P2_Z = 0.5220;
0128 P2_d = 0.01;
0129 P3_Z = 0.4550;
0130
0131 end
0132
0133 if force_mode == 0,
0134 l_data = input([ 'Please confirm/specify the launcher characteristics ',...
0135 '\n (press ''enter'' if OK of specify data vector)',...
0136 '\n[P1_R,P1_Z,P1_theta,P2_R,P2_Z,P2_d,P3_Z] = [',...
0137 num2str(P1_R),',',num2str(P1_Z),',',num2str(P1_theta),',',...
0138 num2str(P2_R),',',num2str(P2_Z),',',num2str(P2_d),',',num2str(P3_Z),'] : ']);
0139 end
0140
0141 if ~isempty(l_data),
0142 if ~isnumeric(l_data) || length(l_data) ~= 7,
0143 disp('-----> Invalid launcher data.');
0144 return
0145 end
0146
0147 P1_R = l_data(1);
0148 P1_Z = l_data(2);
0149 P1_theta = l_data(3);
0150 P2_R = l_data(4);
0151 P2_Z = l_data(5);
0152 P2_d = l_data(6);
0153 P3_Z = l_data(7);
0154
0155 end
0156
0157 if isempty(angles),
0158
0159 theta = input('Specify mirror angle theta (degrees)? [0]: ')*pi/180;
0160 if isempty(theta)
0161 theta = 0;
0162 end
0163 if ~isnumeric(theta),
0164 disp('-----> Invalid angle specification.');
0165 return
0166 end
0167
0168 phi = input('Specify llauncher angle phi (degrees)? [0]: ')*pi/180;
0169 if isempty(phi)
0170 phi = 0;
0171 end
0172 if ~isnumeric(phi),
0173 disp('-----> Invalid angle specification.');
0174 return
0175 end
0176
0177 freq = input('Specify wave frequency (GHz)? [82.7]: ')*1e9;
0178 if isempty(freq)
0179 freq = 82.7e9;
0180 end
0181 if ~isnumeric(freq),
0182 disp('-----> Invalid frequency specification.');
0183 return
0184 end
0185
0186 P0 = input('Specify wave power (kW)? [500]: ')*1e3;
0187 if isempty(P0)
0188 P0 = 500e3;
0189 end
0190 if ~isnumeric(P0),
0191 disp('-----> Invalid power specification.');
0192 return
0193 end
0194
0195 angles.freq = freq;
0196 angles.P0 = P0;
0197
0198 angles.theta = theta;
0199 angles.phi = phi;
0200
0201 elseif isnan(angles),
0202
0203 angles = struct;
0204 angles.theta = 0;
0205 angles.phi = 0;
0206 angles.freq = 82.7e9;
0207 angles.P0 = 500e3;
0208
0209 end
0210
0211 angles.P1_R = P1_R;
0212 angles.P1_theta = P1_theta;
0213 angles.P2_R = P2_R;
0214 angles.P2_d = P2_d;
0215 angles.P1_Z = P1_Z;
0216 angles.P2_Z = P2_Z;
0217 angles.P3_Z = P3_Z;
0218
0219 end
0220
0221 angles.w0 = 0.0188;
0222 angles.z_L = 0.2756;
0223
0224 id = ['L',num2str(l_opt)];
0225
0226 angles.id = id;
0227