0001 function [flag,ap,Rp,Zp,Bt,Ip,qmin,eq,qopt,Zi,mi,fi,Te0,Tea,eTe1,eTe2,ne0,nea,ene1,ene2,Ti0,Tia,eTi1,eTi2,Zeff0,Zeffa,eZeff,xZeff,Vloop] = load_tprof_tsbase_yp(shotnum,certif,shotime,tmin,tmax,basestr);
0002
0003
0004
0005
0006
0007 method = 'spline';
0008 flag = 1;
0009
0010 if strcmp(basestr,'TS'),
0011
0012 shotnum = str2num(shotnum) + certif/10;
0013
0014 [tprof.ap,tprof.t] = tsbase(shotnum,'SPROFAMIN');
0015 [tprof.Rp,tprof.t] = tsbase(shotnum,'SPROFRMAJ');
0016 [tprof.Zp,tprof.t] = tsbase(shotnum,'SPROFZPOS');
0017
0018 [tprof.Bt,tprof.t] = tsbase(shotnum,'SPROFBTOR');
0019 [tprof.Ip,tprof.t] = tsbase(shotnum,'SPROFIP');
0020 [tprof.qpsi,tprof.t] = tsbase(shotnum,'GPROFQ');
0021
0022 [tprof.vloop,tprof.t] = tsbase(shotnum,'SPROFVS');
0023 [tprof.Zeff,tprof.t] = tsbase(shotnum,'SPROFZEFF');
0024 [tprof.Zmain] = tsbase(shotnum,'SPROFZMAIN');
0025 [tprof.Mmain] = tsbase(shotnum,'SPROFMMAIN');
0026 [tprof.Cmain] = tsbase(shotnum,'SPROFCMAIN');
0027 [tprof.Zimp] = tsbase(shotnum,'SPROFZIMP');
0028 [tprof.Mimp] = tsbase(shotnum,'SPROFMIMP');
0029
0030 [tprof.Te,tprof.t,tprof.rho] = tsbase(shotnum,'GPROFTEFIT');
0031 [tprof.ne,tprof.t,tprof.rho] = tsbase(shotnum,'GPROFNEFIT');
0032 [tprof.Ti,tprof.t,tprof.rho] = tsbase(shotnum,'GPROFTIFIT_');
0033 [tprof.ni,tprof.t,tprof.rho] = tsbase(shotnum,'GPROFNIFIT');
0034
0035 if isempty(tprof.ap) | isempty(tprof.Rp) |isempty(tprof.Zp) |isempty(tprof.Bt) |isempty(tprof.Ip) |isempty(tprof.qpsi) |isempty(tprof.vloop) | isempty(tprof.Zeff) | isempty(tprof.Zmain) | isempty(tprof.Mmain) | isempty(tprof.Cmain) | isempty(tprof.Zimp) | isempty(tprof.Mimp) | isempty(tprof.Te) | isempty(tprof.ne) | isempty(tprof.ni),
0036 ap = [];
0037 Rp = [];
0038 Zp = [];
0039 Bt = [];
0040 Ip = [];
0041 qmin = [];
0042 eq = [];
0043 qopt = [];
0044 Zi = [];
0045 mi = [];
0046 fi = [];
0047 Te0 = [];
0048 Tea = [];
0049 eTe1 = [];
0050 eTe2 = [];
0051 ne0 = [];
0052 nea = [];
0053 ene1 = [];
0054 ene2 = [];
0055 Ti0 = [];
0056 Tia = [];
0057 eTi1 = [];
0058 eTi2 = [];
0059 Zeff0 = [];
0060 Zeffa = [];
0061 eZeff = [];
0062 xZeff = [];
0063 Vloop = [];
0064 LH_out = [];
0065 EC_out = [];
0066 flag = 0;
0067 return
0068 end
0069
0070 if isempty(tprof.Ti),
0071 tprof.Ti = tprof.Te/2;
0072 end
0073
0074
0075
0076
0077
0078 ap = interp_tprof_time_fxdrg(tprof.t,tprof.ap,shotime,method);
0079 Rp = interp_tprof_time_fxdrg(tprof.t,tprof.Rp,shotime,method);
0080 Zp = interp_tprof_time_fxdrg(tprof.t,tprof.Zp,shotime,method);
0081
0082 Bt = interp_tprof_time_fxdrg(tprof.t,tprof.Bt,shotime,method);
0083 Ip = interp_tprof_time_fxdrg(tprof.t,tprof.Ip,shotime,method);
0084 qpsi = interp_tprof_time_fxdrg(tprof.t,tprof.qpsi,shotime,method);
0085
0086
0087
0088 Te_tmin = interp_tprof_time_fxdrg(tprof.t,tprof.Te,tmin,method);
0089 Te_tmax = interp_tprof_time_fxdrg(tprof.t,tprof.Te,tmax,method);
0090 ne_tmin = interp_tprof_time_fxdrg(tprof.t,tprof.ne,tmin,method);
0091 ne_tmax = interp_tprof_time_fxdrg(tprof.t,tprof.ne,tmax,method);
0092 Ti_tmin = interp_tprof_time_fxdrg(tprof.t,tprof.Ti,tmin,method);
0093 Ti_tmax = interp_tprof_time_fxdrg(tprof.t,tprof.Ti,tmax,method);
0094 ni_tmin = interp_tprof_time_fxdrg(tprof.t,tprof.ni,tmin,method);
0095 ni_tmax = interp_tprof_time_fxdrg(tprof.t,tprof.ni,tmax,method);
0096
0097 vloop_tmin = interp_tprof_time_fxdrg(tprof.t,tprof.vloop,tmin,method);
0098 vloop_tmax = interp_tprof_time_fxdrg(tprof.t,tprof.vloop,tmax,method);
0099 Zeff_tmin = interp_tprof_time_fxdrg(tprof.t,tprof.Zeff,tmin,method);
0100 Zeff_tmax = interp_tprof_time_fxdrg(tprof.t,tprof.Zeff,tmax,method);
0101
0102 dt = [tmin;tprof.t(find((tprof.t > tmin).*(tprof.t < tmax)));tmax];
0103
0104 Te = mean([Te_tmin;tprof.Te(find((tprof.t > tmin).*(tprof.t < tmax)),:);Te_tmax]);
0105 ne = mean([ne_tmin;tprof.ne(find((tprof.t > tmin).*(tprof.t < tmax)),:);ne_tmax]);
0106 Ti = mean([Ti_tmin;tprof.Ti(find((tprof.t > tmin).*(tprof.t < tmax)),:);Ti_tmax]);
0107 ni = mean([ni_tmin;tprof.ni(find((tprof.t > tmin).*(tprof.t < tmax)),:);ni_tmax]);
0108
0109 Vloop = mean([vloop_tmin;tprof.vloop(find((tprof.t > tmin).*(tprof.t < tmax)),:);vloop_tmax]);
0110 Zeff = mean([Zeff_tmin;tprof.Zeff(find((tprof.t > tmin).*(tprof.t < tmax)),:);Zeff_tmax]);
0111
0112
0113
0114 [qmin,qmax,eq,qopt,chi2_q] = fit_qprofile_fxdrg(tprof.rho,qpsi);
0115 [Te0,Tea,eTe1,eTe2,chi2_Te] = fit_profile_fxdrg(tprof.rho,Te,1,[2,2]);
0116 [ne0,nea,ene1,ene2,chi2_ne] = fit_profile_fxdrg(tprof.rho,ne,1,[2,2]);
0117 [Ti0,Tia,eTi1,eTi2,chi2_Ti] = fit_profile_fxdrg(tprof.rho,Ti,1,[2,2]);
0118 [ni0,nia,eni1,eni2,chi2_ni] = fit_profile_fxdrg(tprof.rho,ni,1,[2,2]);
0119
0120
0121
0122 [sZmain,iZmain] = sort(tprof.Zmain);
0123 [sZimp,iZimp] = sort(tprof.Zimp);
0124 sMmain = tprof.Mmain(iZmain);
0125 sCmain = tprof.Mmain(iZmain);
0126 sMimp = tprof.Mimp(iZimp);
0127
0128 isZmain1 = find(sZmain == 1);
0129 isZmain2 = find(sZmain > 1);
0130 [ssZmain1,isZmain1] = sort(sZmain(isZmain1));
0131 [ssZmain2,isZmain2] = sort(sZmain(isZmain2));
0132
0133
0134
0135 if isempty(isZmain1),
0136 Zi = [1,1;1;sZmain;sZimp]';
0137 mi = [1;2;3;sMmain;tprof.Mimp(iZimp)]';
0138 fi = [0;0;0]';
0139 else,
0140 if length(isZmain1) == 1,
0141 Zi = [1;1;1;sZmain(isZmain2);sZimp]';
0142 mi = [1;2;3;tprof.Mmain(isZmain2);tprof.Mimp(iZimp)]';
0143
0144 if tprof.Mmain(isZmain1) == 1,
0145 fi = [1;0;0]';
0146 elseif tprof.Mmain(isZmain1) == 2,
0147 fi = [0;1;0]';
0148 end
0149 else,
0150 Zi = [sZmain(isZmain1);1;sZmain(isZmain2);sZimp]';
0151 mi = [tprof.Mmain(isZmain1);3;tprof.Mmain(isZmain2);tprof.Mimp(iZimp)]';
0152 fi = [tprof.Cmain(isZmain1);0]';
0153 fi(2) = 1 - fi(1);
0154 end
0155 end
0156
0157
0158
0159 Zeff0 = Zeff;
0160 Zeffa = Zeff;
0161 eZeff = 0;
0162 xZeff = NaN;
0163 else
0164 disp('Not yet implemented for this machine.')
0165 return
0166 end
0167