load_externaldata_AUG_MultiTimes

PURPOSE ^

SYNOPSIS ^

function external = load_externaldata_AUG_MultiTimes(workdir,opt_gui,style,~)

DESCRIPTION ^

 This function loads AUG data for multiple times from S. Denk
 LUKE_data_shot_<shotnum>.mat files

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SUBFUNCTIONS ^

SOURCE CODE ^

0001 function external = load_externaldata_AUG_MultiTimes(workdir,opt_gui,style,~)
0002     %
0003     % This function loads AUG data for multiple times from S. Denk
0004     % LUKE_data_shot_<shotnum>.mat files
0005     %
0006     external = struct;
0007     %
0008     [filename,pathname] = igetfile_jd(isobject(opt_gui) || opt_gui,{'LUKE_data_shot_*.mat'},'Please select AUG data file',workdir);
0009     %
0010     if ~ischar(filename)
0011         return
0012     end
0013     %
0014     external.basestr = 'AUG';
0015     %
0016     if length(filename) > 19 && strcmp(filename(1:15),'LUKE_data_shot_') && strcmp(filename(end-3:end),'.mat')
0017         shotnum = filename(16:end-4);
0018     else
0019         shotnum = '0';
0020     end
0021     %
0022     external.shotnum = iselect_jd({},'Enter shot number : ',opt_gui,style.editselectstyle,shotnum,'edit');
0023     %
0024     shotdata = make_double(load([pathname,filesep,filename]));
0025     %
0026     tshot = shotdata.t;
0027     ntshot = length(tshot);
0028     %
0029     timestr = ['tmin = ',sprintf('%3.3f',min(tshot)),'s ; tmax = ',sprintf('%3.3f',max(tshot)),'s ; dt = ',sprintf('%3.3f',mean(diff(tshot))),'s ; nt = ',num2str(ntshot)];
0030     %
0031     itshot = iselect_jd({},[timestr,' :\n -> select time indices (enter 0 to select all times)'],opt_gui,style.editselectstyle,0,'edit');
0032     %
0033     if isempty(itshot)
0034         itshot = 1:ntshot;
0035     end
0036     %
0037     external.shotime = tshot(itshot);
0038     %
0039     for it = 1:length(itshot)
0040         %
0041         external.equil(it).shotnum = external.shotnum;
0042         external.equil(it).shotime = external.shotime(it);
0043         %
0044         external.equil(it).prof.ne.rho = shotdata.rhop_prof(itshot(it),:).';
0045         external.equil(it).prof.ne.data = shotdata.ne_prof(itshot(it),:).';
0046         %
0047         external.equil(it).prof.te.rho = shotdata.rhop_prof(itshot(it),:).';
0048         external.equil(it).prof.te.data = shotdata.Te_prof(itshot(it),:).';
0049         %
0050         external.equil(it).prof.ti = 1;%Ti/Te
0051         external.equil(it).prof.zeff = 1.5;%default value
0052         %
0053         external.equil(it).prof.Ip = -shotdata.I_p(itshot(it));
0054         %
0055         external.equil(it).magnetic.R = shotdata.R(itshot(it),:);
0056         external.equil(it).magnetic.Z = shotdata.z(itshot(it),:);
0057         %
0058         nR = size(shotdata.R,2);
0059         nZ = size(shotdata.z,2);
0060         %
0061         external.equil(it).magnetic.BR = reshape(shotdata.Br(itshot(it),:,:),[nR,nZ]);
0062         external.equil(it).magnetic.BZ = reshape(shotdata.Bz(itshot(it),:,:),[nR,nZ]);
0063         external.equil(it).magnetic.Bphi = -reshape(shotdata.Bt(itshot(it),:,:),[nR,nZ]);% different sign convention
0064         external.equil(it).magnetic.psi = reshape(shotdata.Psi(itshot(it),:,:),[nR,nZ])/(2*pi);
0065         external.equil(it).magnetic.rhop = reshape(shotdata.rhop(itshot(it),:,:),[nR,nZ]);
0066         %
0067         external.equil(it).magnetic.Rp = shotdata.R_ax(itshot(it));
0068         external.equil(it).magnetic.Zp = shotdata.z_ax(itshot(it));
0069         external.equil(it).magnetic.psi0 = shotdata.Psi_ax(itshot(it))/(2*pi);
0070         external.equil(it).magnetic.psia = shotdata.Psi_sep(itshot(it))/(2*pi);
0071         %
0072         external.ohm(it).vloop = shotdata.Vloop(itshot(it));
0073         %
0074         external.wave(1,it).mmode = - shotdata.mode_gy1(itshot(it));
0075         external.wave(2,it).mmode = - shotdata.mode_gy2(itshot(it));
0076         %
0077         external.wave(1,it).f_GHz = shotdata.freq_gy1(itshot(it))/1e9;
0078         external.wave(2,it).f_GHz = shotdata.freq_gy2(itshot(it))/1e9;
0079         %
0080         external.wave(1,it).P_MW = shotdata.PW_gy1(itshot(it))/1e6;
0081         external.wave(2,it).P_MW = shotdata.PW_gy2(itshot(it))/1e6;
0082         %
0083         external.wave(1,it).alpha_L = pi + pi/180*shotdata.tor_angle_gy1(itshot(it));
0084         external.wave(2,it).alpha_L = pi + pi/180*shotdata.tor_angle_gy2(itshot(it));
0085         %
0086         external.wave(1,it).beta_L = pi/2 + pi/180*shotdata.pol_angle_gy1(itshot(it));
0087         external.wave(2,it).beta_L = pi/2 + pi/180*shotdata.pol_angle_gy2(itshot(it));
0088         %
0089         x1_L = shotdata.x_gy1(itshot(it));
0090         x2_L = shotdata.x_gy2(itshot(it));
0091         y1_L = shotdata.y_gy1(itshot(it));
0092         y2_L = shotdata.y_gy2(itshot(it));
0093         %
0094         external.wave(1,it).R_L = sqrt(x1_L^2 + y1_L^2);
0095         external.wave(2,it).R_L = sqrt(x2_L^2 + y2_L^2);
0096         %
0097         external.wave(1,it).Z_L = shotdata.z_gy1(itshot(it));
0098         external.wave(2,it).Z_L = shotdata.z_gy2(itshot(it));
0099         %
0100         if shotdata.curv_y_gy1(itshot(it)) ~= shotdata.curv_z_gy1(itshot(it))
0101             disp('Warning : EC beam 1 is astygmatic. Average curvature radius selected.')
0102         end
0103         %
0104         if shotdata.curv_y_gy2(itshot(it)) ~= shotdata.curv_z_gy2(itshot(it))
0105             disp('Warning : EC beam 2 is astygmatic. Average curvature radius selected.')
0106         end
0107         %
0108         external.wave(1,it).z0 = (shotdata.curv_y_gy1(itshot(it)) + shotdata.curv_z_gy1(itshot(it)))/2;
0109         external.wave(2,it).z0 = (shotdata.curv_y_gy2(itshot(it)) + shotdata.curv_z_gy2(itshot(it)))/2;
0110         %
0111         if shotdata.width_y_gy1(itshot(it)) ~= shotdata.width_z_gy1(itshot(it))
0112             disp('Warning : EC beam 1 is elliptical. Average beam radius selected.')
0113         end
0114         %
0115         if shotdata.width_y_gy2(itshot(it)) ~= shotdata.width_z_gy2(itshot(it))
0116             disp('Warning : EC beam 2 is elliptical. Average beam radius selected.')
0117         end
0118         %
0119         external.wave(1,it).w0 = (shotdata.width_y_gy1(itshot(it)) + shotdata.width_z_gy1(itshot(it)))/2;
0120         external.wave(2,it).w0 = (shotdata.width_y_gy2(itshot(it)) + shotdata.width_z_gy2(itshot(it)))/2;
0121     end    
0122 
0123     %
0124     external.id = [external.basestr,'_',external.shotnum]; 
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     %
0131 end
0132 %
0133 function s = make_double(s)
0134     %
0135     fnames = fieldnames(s);
0136     for ifield = 1:length(fnames)
0137         if isnumeric(s.(fnames{ifield}))
0138             s.(fnames{ifield}) = double(s.(fnames{ifield}));
0139         end
0140     end
0141 end

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