function [Energy,EnergyErr]=hst_acs_zp_apcorr(Aper,Filter)
% Aperture correction for HST/ACS filter and aperture radius.
% Package: VO.HST
% Description: Given aperture radius for photometry, and Hubble Space
%              Telecsope (HST) ACS-WFC filter name, return the fraction,
%              and error in fraction, of the encircled energy within the
%              aperture.
% Input  : - Aperture radius [arcseconds].
%          - HST/ACS/WFC filter name
% Output : - Fraction of energy encircled within aperture.
%          - Error in the fraction of energy encircled within aperture.
% Tested : Matlab 7.0
%     By : Eran O. Ofek                    Feb 2007
%    URL : http://weizmann.ac.il/home/eofek/matlab/
% Reference: Sirianni et al. (2005)
% Example: [Energy,EnergyErr]=VO.HST.hst_acs_zp_apcorr(0.3,'F475W');
% Reliable: 2
%--------------------------------------------------------------------------

%
% Encircled Energy -  HST/ACS/WFC  (Sirianni et al. 2005, PASP, 117, 1049)
% See: hst_acs_zp_apcorr.m utility function
%
% Aper     F435W         F475W           F555W           F606W          F625W           F775W             F814W           F850LP          F892N
% Radius
% ["]
Data=[ 0.05      0.289 0.011   0.318 0.006     0.311 0.005     0.313 0.003    0.312 0.004     0.296 0.001       0.293 0.009     0.246 0.004     0.241 0.002
 0.10      0.626 0.011   0.669 0.006     0.662 0.003     0.656 0.005    0.648 0.004     0.623 0.005       0.603 0.006     0.538 0.001     0.546 0.007
 0.15      0.775 0.004   0.801 0.003     0.795 0.002     0.796 0.003    0.795 0.002     0.780 0.003       0.764 0.004     0.689 0.003     0.711 0.007
 0.20      0.832 0.002   0.850 0.002     0.843 0.001     0.845 0.001    0.844 0.000     0.840 0.001       0.833 0.002     0.779 0.002     0.802 0.004
 0.25      0.859 0.000   0.876 0.002     0.871 0.001     0.871 0.000    0.868 0.001     0.863 0.001       0.858 0.001     0.815 0.000     0.835 0.001
 0.30      0.875 0.000   0.890 0.002     0.891 0.000     0.890 0.001    0.888 0.000     0.882 0.001       0.879 0.000     0.837 0.001     0.858 0.000
 0.35      0.884 0.001   0.900 0.002     0.899 0.001     0.900 0.000    0.899 0.000     0.899 0.001       0.895 0.001     0.858 0.001     0.878 0.000
 0.40      0.892 0.001   0.907 0.002     0.908 0.000     0.908 0.001    0.907 0.000     0.909 0.001       0.907 0.001     0.877 0.001     0.895 0.000
 0.45      0.900 0.000   0.914 0.002     0.915 0.000     0.914 0.000    0.914 0.000     0.914 0.001       0.914 0.001     0.889 0.001     0.906 0.000
 0.50      0.906 0.000   0.920 0.002     0.920 0.000     0.920 0.000    0.920 0.000     0.921 0.001       0.920 0.001     0.897 0.001     0.912 0.000
 0.55      0.912 0.000   0.925 0.002     0.924 0.001     0.925 0.000    0.924 0.000     0.926 0.001       0.926 0.001     0.905 0.001     0.917 0.000
 0.60      0.916 0.001   0.930 0.002     0.929 0.001     0.929 0.000    0.929 0.000     0.931 0.001       0.931 0.001     0.912 0.001     0.923 0.000
 0.65      0.920 0.001   0.934 0.002     0.933 0.001     0.933 0.000    0.933 0.000     0.935 0.001       0.935 0.001     0.918 0.001     0.927 0.000
 0.70      0.923 0.001   0.937 0.002     0.935 0.001     0.938 0.000    0.937 0.000     0.939 0.001       0.939 0.001     0.923 0.001     0.930 0.000
 0.75      0.926 0.001   0.940 0.002     0.938 0.001     0.941 0.000    0.940 0.000     0.942 0.001       0.942 0.001     0.927 0.001     0.934 0.000
 0.80      0.929 0.001   0.943 0.002     0.940 0.001     0.944 0.000    0.943 0.000     0.945 0.001       0.945 0.001     0.932 0.001     0.937 0.000
 0.85      0.931 0.001   0.945 0.002     0.942 0.001     0.946 0.000    0.946 0.000     0.948 0.001       0.948 0.001     0.936 0.001     0.940 0.000
 0.90      0.934 0.001   0.948 0.002     0.944 0.001     0.948 0.000    0.948 0.000     0.950 0.001       0.951 0.001     0.940 0.001     0.943 0.000
 0.95      0.937 0.001   0.950 0.002     0.946 0.001     0.950 0.000    0.950 0.000     0.953 0.001       0.953 0.001     0.943 0.001     0.945 0.000
 1.00      0.940 0.001   0.952 0.002     0.948 0.001     0.952 0.000    0.952 0.000     0.955 0.001       0.955 0.001     0.946 0.001     0.947 0.000
 1.25      0.952 0.001   0.968 0.000     0.957 0.001     0.960 0.000    0.959 0.000     0.962 0.001       0.962 0.000     0.958 0.001     0.957 0.000
 1.50      0.964 0.001   0.974 0.002     0.965 0.001     0.967 0.000    0.965 0.000     0.967 0.001       0.968 0.001     0.965 0.001     0.963 0.001
 1.75      0.973 0.001   0.983 0.002     0.973 0.001     0.974 0.000    0.972 0.000     0.972 0.001       0.973 0.001     0.970 0.001     0.968 0.001
 2.00      0.980 0.001   0.989 0.002     0.980 0.001     0.981 0.000    0.977 0.000     0.977 0.001       0.976 0.000     0.974 0.001     0.972 0.001
 2.25      0.983 0.001   0.994 0.002     0.985 0.001     0.987 0.001    0.982 0.000     0.980 0.001       0.980 0.001     0.978 0.001     0.976 0.001
 2.50      0.986 0.001   0.997 0.002     0.989 0.001     0.991 0.001    0.986 0.000     0.985 0.001       0.982 0.000     0.982 0.001     0.979 0.001
 2.75      0.991 0.001   0.998 0.002     0.991 0.001     0.994 0.001    0.989 0.000     0.988 0.001       0.987 0.001     0.985 0.001     0.982 0.001
 3.00      0.993 0.001   1.000 0.002     0.993 0.001     0.995 0.001    0.991 0.000     0.990 0.001       0.990 0.001     0.988 0.001     0.984 0.001
 3.25      0.995 0.001   1.001 0.001     0.995 0.001     0.996 0.001    0.994 0.000     0.993 0.000       0.991 0.001     0.991 0.001     0.986 0.001
 3.50      0.995 0.001   1.001 0.001     0.996 0.001     0.997 0.001    0.997 0.001     0.995 0.000       0.994 0.000     0.994 0.001     0.989 0.001
 3.75      0.997 0.000   1.003 0.001     0.996 0.001     0.999 0.001    0.997 0.001     0.995 0.000       0.996 0.001     0.996 0.001     0.989 0.000
 4.00      0.997 0.001   1.002 0.001     0.998 0.001     0.998 0.001    0.998 0.001     0.998 0.001       0.997 0.001     0.997 0.001     0.992 0.000
 4.25      0.999 0.000   1.002 0.001     1.000 0.000     0.999 0.001    0.999 0.001     0.999 0.001       0.999 0.001     0.997 0.000     0.993 0.000
 4.50      1.000 0.000   1.002 0.001     0.999 0.001     1.000 0.001    1.000 0.001     1.000 0.001       0.999 0.001     1.000 0.001     0.995 0.000
 4.75      1.000 0.001   1.001 0.001     1.000 0.001     1.000 0.001    1.000 0.001     1.000 0.001       1.000 0.001     1.001 0.000     0.997 0.001
 5.00      0.999 0.000   1.001 0.001     1.001 0.000     1.001 0.001    1.001 0.001     1.001 0.000       1.000 0.001     1.001 0.000     0.997 0.000
 5.50      1.000 0.000   1.000 0.000     1.000 0.000     1.000 0.000    1.000 0.000     1.000 0.000       1.000 0.000     1.000 0.000     1.000 0.000];
 


%Data = load2('HST_ACS_WFC_Encircled_Energy.dat');   % requires the /data/Filters/ directory
%Data = HST_ACS_WFC_Encircled_Energy;
ColAper = 1;
switch lower(Filter)
 case 'f435w'
    Col = [2 3];
 case 'f475w'
    Col = [4 5];
 case 'f555w'
    Col = [6 7];
 case 'f606w'
    Col = [8 9];
 case 'f625w'
    Col = [10 11];
 case 'f775w'
    Col = [12 13];
 case 'f814w'
    Col = [14 15];
 case 'f850lp'
    Col = [16 17];
 case 'f892n'
    Col = [18 19];
 otherwise
    error('Unknown Filter option');
end

Energy    = interp1(Data(:,ColAper),Data(:,Col(1)),Aper,'spline');
EnergyErr = interp1(Data(:,ColAper),Data(:,Col(2)),Aper,'nearest');
