%--------------------------------------------------------------------------
% 
% function[ET_C] = ETC_fit(f)
%
%
% DESCRIBTION
% This function produces for a given frequency vector the corresponding
% amplitude spectral density of the ET-C sensitivity curve. Please note:
% The fit is only valid for frequencies between 1 Hz and 10kHz and the 
% the accuracy is to within 1 percent. Please also note that the fit is 
% not given by a single function, but splitted into several individual 
% frequency bands.
%
% INPUT
% f = frequency vector [Hz]
%
% OUTPUT
% ET_C = amplitude spectral density of ET_C [1/sqrt(Hz)]
%
% REFERNCE FOR ET-C
% A detailed description of ET-C can be found in:
% S.Hild et al.: 'A xylophone configuration for a third-generation 
% gravitational wave detector', CQG, 2010, 27, 015003.
%
%
%
% Stefan Hild, 4/1/2010 (stefan.hild@ligo.org)
% 
%--------------------------------------------------------------------------


function[ET_C] = ETC_fit(f)

f = [f f(length(f))+1];

ET_C = f;    % initializing vector for ET_C

% ----------------------

% Below here the functions for the individual frequency bands are given.

f1 = 4600;        % This is the frequency range from 4.6 to 10 kHz.
[y1, x1] = min(abs(f-f1));
ET_C(x1:length(f)) = 6.405e-28.*f(x1:length(f)).^0.9969-5.092e-27;

f2 = 1900;        % This is the frequency range from 1.9 to 4.6 kHz.
[y2, x2] = min(abs(f-f2));
ET_C(x2:x1-1) = 7.458e-28.*f(x2:x1-1).^0.9794-1.793e-26;

f3 = 210;
[y3, x3] = min(abs(f-f3));
ET_C(x3:x2-1) = -7.646e-55.*f(x3:x2-1).^9 +  1.54e-50.*f(x3:x2-1).^8 -1.331e-46.*f(x3:x2-1).^7 + 6.458e-43.*f(x3:x2-1).^6 -1.936e-39.*f(x3:x2-1).^5 +  3.719e-36.*f(x3:x2-1).^4 -4.606e-33.*f(x3:x2-1).^3 + 3.614e-30.*f(x3:x2-1).^2 -1.095e-27.*f(x3:x2-1) + 4.397e-25;

f4 = 110;
[y4, x4] = min(abs(f-f4));
ET_C(x4:x3-1)=-3.317e-32.*f(x4:x3-1).^3+2.027e-29.*f(x4:x3-1).^2+-4.354e-27.*f(x4:x3-1)+ 6.601e-25;

f5 = 80;
[y5, x5] = min(abs(f-f5));
ET_C(x5:x4-1) =   -2.935e-46.*f(x5:x4-1).^9 +  6.757e-43.*f(x5:x4-1).^8 -6.794e-40.*f(x5:x4-1).^7 + 3.916e-37.*f(x5:x4-1).^6 -1.426e-34.*f(x5:x4-1).^5 +   3.414e-32.*f(x5:x4-1).^4-5.399e-30.*f(x5:x4-1).^3 + 5.52e-28.*f(x5:x4-1).^2 -3.433e-26.*f(x5:x4-1) + 1.389e-24;

f6 = 51;
[y6, x6] = min(abs(f-f6));
ET_C(x6:x5-1) =  -2.998e-30.*f(x6:x5-1).^3 +7.391e-28.*f(x6:x5-1).^2 -6.303e-26.*f(x6:x5-1) +2.279e-24;

f7 = 38;
[y7, x7] = min(abs(f-f7));
ET_C(x7:x6-1) =  1.27e-29.*f(x7:x6-1).^3 -1.118e-27.*f(x7:x6-1).^2 +2.716e-27.*f(x7:x6-1) +1.674e-24;

f8 = 29.8;
[y8, x8] = min(abs(f-f8));
ET_C(x8:x7-1) =  3.151e-28.*f(x8:x7-1).^3  -3.676e-26.*f(x8:x7-1).^2 + 1.4e-24.*f(x8:x7-1) -1.655e-23;

f9 = 22;
[y9, x9] = min(abs(f-f9));
ET_C(x9:x8-1) =  -3.173e-28.*f(x9:x8-1).^3  +   3.028e-26.*f(x9:x8-1).^2 -9.138e-25.*f(x9:x8-1) + 9.6e-24;

f10 = 18.5;
[y10, x10] = min(abs(f-f10));
ET_C(x10:x9-1) =  -5.873e-29.*f(x10:x9-1).^4+ 5.781e-27.*f(x10:x9-1).^3   -2.06e-25.*f(x10:x9-1).^2 +  3.134e-24.*f(x10:x9-1)  -1.627e-23;

f11 = 9;
[y11, x11] = min(abs(f-f11));
ET_C(x11:x10-1) =  5.104e-28.*f(x11:x10-1).^3   -2.817e-26.*f(x11:x10-1).^2 +  4.761e-25.*f(x11:x10-1)  -1.466e-24;

f12 = 7.5;
[y12, x12] = min(abs(f-f12));
ET_C(x12:x11-1) =  -1.368e-26.*f(x12:x11-1).^3  + 3.581e-25.*f(x12:x11-1).^2  -3.031e-24.*f(x12:x11-1) +  9.151e-24;

f13 = 5.7;
[y13, x13] = min(abs(f-f13));
ET_C(x13:x12-1) =   -6.333e-26.*f(x13:x12-1).^3  + 1.509e-24.*f(x13:x12-1).^2 -1.193e-23.*f(x13:x12-1) +  3.210e-23;

f14 = 4.0;
[y14, x14] = min(abs(f-f14));
ET_C(x14:x13-1) =   1.362e-21.*f(x14:x13-1).^(-3.952)  -3.004e-27;

f15 = 3.0;
[y15, x15] = min(abs(f-f15));
ET_C(x15:x14-1) =  1.135e-21.*f(x15:x14-1).^( -3.806)   -1.16e-25;

f16 = 2.4;
[y16, x16] = min(abs(f-f16));
ET_C(x16:x15-1) =  8.52e-22.*f(x16:x15-1).^(-3.53)   -4.264e-25;

f17 = 2;
[y17, x17] = min(abs(f-f17));
ET_C(x17:x16-1) =   6.899e-22.*f(x17:x16-1).^(-3.276)   -9.181e-25;

f18 = 1.65;
[y18, x18] = min(abs(f-f18));
ET_C(x18:x17-1) =   7.056e-22.*f(x18:x17-1).^(-3.521)  + 9.042e-24;

f19 = 1.4;
[y19, x19] = min(abs(f-f19));
ET_C(x19:x18-1) = 2.717e-21.*f(x19:x18-1).^4 -1.842e-20.*f(x19:x18-1).^3  +  4.709e-20.*f(x19:x18-1).^2 -5.402e-20.*f(x19:x18-1) +2.3667e-20;

f20 = 1.26;
[y20, x20] = min(abs(f-f20));
ET_C(x20:x19-1) =  -1.98e-20.*f(x20:x19-1).^3  +  8.486e-20.*f(x20:x19-1).^2  -1.219e-19.*f(x20:x19-1) + 5.8894e-20;
  
f21 = 1.12;
[y21, x21] = min(abs(f-f21));
ET_C(x21:x20-1) =  -1.042e-19.*f(x21:x20-1).^3  +  4.045e-19.*f(x21:x20-1).^2  -5.257e-19.*f(x21:x20-1) +  2.29051e-19;

f22 = 1;
[y22, x22] = min(abs(f-f22));
ET_C(x22:x21-1) =  4.741e-21.*f(x22:x21-1).^(-11.72)  + 1.906e-23;

ET_C = ET_C(1:length(ET_C)-1);


  
  