interp_test

PURPOSE ^

Testing script for interpolation functions

SYNOPSIS ^

This is a script file.

DESCRIPTION ^

 Testing script for interpolation functions

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 % Testing script for interpolation functions
0002 %
0003 shotnum = 36194;
0004 shotime = 28;
0005 %
0006 [tprof.ap,tprof.t] = tsbase(shotnum,'SPROFAMIN');%Plasma minor radius (m)
0007 [tprof.qpsi,tprof.t] = tsbase(shotnum,'GPROFQ');%safety factor qpsi profile
0008 [tprof.Te,tprof.t,tprof.rho] = tsbase(shotnum,'GPROFTEFIT');%Electron temperature (keV)
0009 %
0010 figure('name','Profils');
0011 subplot(2,1,1);
0012 plot(tprof.t,tprof.ap,'r-')
0013 subplot(2,1,2);
0014 plot(tprof.rho,tprof.Te(shotime,:),'b--')
0015 %
0016 i_refm = max(find(tprof.t <= 28));
0017 i_refp = min(find(tprof.t > 28));
0018 Te = interp_tprof_time_fxdrg(tprof.t,tprof.Te,28,'pchip')
0019 figure('name','Interp');plot(tprof.rho,Te,'r-',tprof.rho,tprof.Te(i_refm,:),'b--',tprof.rho,tprof.Te(i_refp,:),'g-.');
0020 %
0021 ap = interp_tprof_time_fxdrg(tprof.t,tprof.ap,28,'pchip');
0022 %
0023 qpsi = interp_tprof_time_fxdrg(tprof.t,tprof.qpsi,28,'pchip');
0024 [qmin,qmax,eq,qopt,chi2] = fit_qprofile_fxdrg(tprof.rho,qpsi);
0025 qpsi_fit = (qmax - qmin).*tprof.rho.^eq + qmin;
0026 figure('name','Fit-q');plot(tprof.rho,qpsi,'r-',tprof.rho,tprof.qpsi(i_refm,:),'b--',tprof.rho,tprof.qpsi(i_refp,:),'g-.',tprof.rho,qpsi_fit,'k*');
0027 %
0028 figure('name','Fit-Te');plot(tprof.rho,Te,'r-',tprof.rho,tprof.Te(i_refm,:),'b--',tprof.rho,tprof.Te(i_refp,:),'g-.');hold on
0029 [Te0,Tea,eTe1,eTe2,chi2_Te] = fit_profile_fxdrg(tprof.rho,Te,1,[2,1]);
0030 Te_fit = (Te0 - Tea)*(1 - tprof.rho.^eTe1).^eTe2 + Tea;
0031 plot(tprof.rho,Te_fit,'k-');
0032 %
0033 [Te0,Tea,eTe1,eTe2,chi2_Te] = fit_profile_fxdrg(tprof.rho,Te,2,-1);
0034 Te_fit = (Te0 - Tea)*(exp(eTe1) - exp(eTe1*tprof.rho.*tprof.rho))/(exp(eTe1)-1) + Tea;
0035 plot(tprof.rho,Te_fit,'c-');
0036 hold off
0037 
0038 %
0039 
0040

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