0001 function equil = fmake_equil_KSTAR_jd(eqdsk_path,eqdsk_file,ece_path,ece_file,equil_prof_data,shotdata)
0002
0003 if nargin < 6,
0004 [shotinfo] = sscanf(eqdsk_file,'g%d.%d');
0005 shotnum = int2str(shotinfo(1));
0006 nshotime = shotinfo(2)/1000;
0007 else
0008 shotnum = shotdata.shotnum;
0009 nshotime = shotdata.shotime;
0010 end
0011
0012 shotime = num2str(nshotime,'%6.4f');
0013
0014 display_mode = 0;
0015 p_opt = -1;
0016 basestr = 'KSTAR';
0017
0018 equil_id = [basestr,'_',shotnum,'_',shotime];
0019
0020 if isfield(shotdata,'locid_equil'),
0021 equil_id = [equil_id,shotdata.locid_equil];
0022 end
0023 dispname = [basestr,' #',shotnum,'; t = ',shotime,' s'];
0024 savename = equil_id;
0025
0026
0027
0028 [equil,prho,pspsin,pspsinT] = equil_magnetic_EFIT_jd([eqdsk_path,eqdsk_file],display_mode,p_opt,dispname,savename);
0029
0030
0031
0032 if isfield(equil_prof_data,'ne0'),
0033 fid = fopen([ece_path,ece_file]);
0034 str = fgetl(fid);
0035
0036 istr = find(str == 't');
0037 istr = [istr,length(str) + 1];
0038 nt = length(istr) - 1;
0039
0040 t = NaN(1,nt);
0041 for it = 1:nt,
0042 t(it) = sscanf(str(istr(it):istr(it+1)-1),'t = %f s');
0043 end
0044
0045 fgetl(fid);
0046
0047 [data] = fscanf(fid,[' ECE%d %f',repmat(' %f',[1,nt])]);
0048
0049 nc = length(data)/(2+nt);
0050
0051 data = reshape(data,[2+nt,nc]);
0052
0053
0054 cR = data(2,:).';
0055 cece = data(3:end,:).'/1e3;
0056
0057 [tTe0,tTea,teTe1,teTe2] = Te_ece_jd(equil,cR,cece);
0058
0059 np = length(prho);
0060
0061 tpTe0 = repmat(tTe0.',[1,np]);
0062 tpTea = repmat(tTea.',[1,np]);
0063 tpeTe1 = repmat(teTe1.',[1,np]);
0064 tpeTe2 = repmat(teTe2.',[1,np]);
0065
0066 tprho = repmat(prho,[nt,1]);
0067
0068 tpTe = (tpTe0 - tpTea).*(1 - tprho.^tpeTe1).^tpeTe2 + tpTea;
0069
0070 pTe = interp1(t,tpTe,nshotime,'linear');
0071
0072 nz = length(equil_prof_data.Zi);
0073 pzTi = repmat(pTe/equil_prof_data.Tfac,[nz,1]);
0074
0075 ne0 = equil_prof_data.ne0;
0076 nea = equil_prof_data.nea;
0077 nei = equil_prof_data.nei;
0078 ene1 = equil_prof_data.ene1;
0079 ene2 = equil_prof_data.ene2;
0080
0081 if isnan(ne0) && ~isnan(nei),
0082
0083 ne0 = nea + (nei - nea)*ene1/beta(1/ene1,1+ene2);
0084
0085 end
0086
0087 [dummy,dummy,pne,dummy,pzni,zZi,zmi,fi] = idealprof_yp(equil_prof_data.Zi,equil_prof_data.mi,equil_prof_data.fi,NaN,NaN,NaN,NaN,...
0088 ne0,nea,ene1,ene2,NaN,NaN,NaN,NaN,...
0089 equil_prof_data.Zeff0,equil_prof_data.Zeffa,equil_prof_data.eZeff,NaN,prho);
0090
0091 else
0092
0093
0094
0095
0096
0097
0098
0099
0100 method = 'spline';
0101
0102 data = dlmread([ece_path,ece_file]);
0103
0104 if size(data,2) == 5,
0105 prho_prof = data(:,2).';
0106 pTe_prof = data(:,3).';
0107 pTi_prof = data(:,4).';
0108 pne_prof = 1e19*data(:,5).';
0109 elseif size(data,2) == 3,
0110 prho_prof = data(:,1).';
0111 pTe_prof = data(:,2).';
0112 pne_prof = 1e19*data(:,3).';
0113 pTi_prof = pTe_prof*equil_prof_data.Tifac;
0114 end
0115
0116 pTe = interp1(prho_prof,pTe_prof,pspsinT,method);
0117 pTi = interp1(prho_prof,pTi_prof,pspsinT,method);
0118 pne = interp1(prho_prof,pne_prof,pspsinT,method);
0119
0120 zZi = equil_prof_data.Zi;
0121 zmi = equil_prof_data.mi;
0122 fi = equil_prof_data.fi;
0123
0124 pzTi = repmat(pTi,[length(zZi),1]);
0125 pzni = species_dke_yp(pne,equil_prof_data.Zeff,zZi,fi);
0126
0127 end
0128
0129 equil.pTe = pTe;
0130 equil.pne = pne;
0131 equil.pzTi = pzTi;
0132 equil.pzni = pzni;
0133 equil.zZi = zZi;
0134 equil.zmi = zmi;
0135 equil.fi = fi;
0136
0137 equil.id = equil_id;
0138
0139 equil.basestr = basestr;
0140 equil.shotnum = shotnum;
0141 equil.shotime = shotime;
0142
0143
0144
0145