function [sa, sigma] = AS_1997_vert(M, r_rup, T, is_soil, fault_type, HW);
% by Jack Baker, 2/1/05
% Stanford University
% bakerjw@stanford.edu
%
% Compute the Abrahamson and Silva attenuation prediction for spectral
% accelerations of the vertical component (1997 Seismological Research
% Letters, Vol 68, No 1, p94).
%
% This script has been modified to correct an error in the function
% f_3 that occured in the printed version of the attenuation.
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% INPUT
%
% M = earthquake magnitude
% R = closest distance to fault rupture
% T = period of vibration
% is_soil = 1 for soil prediction
% = 0 for rock
% fault_type = 1 for Reverse
% = 0.5 for reverse/oblique
% = 0 otherwise
% HW = 1 for Hanging Wall sites
% = 0 otherwise
%
% OUTPUT
%
% sa = median spectral acceleration prediction
% sigma = logarithmic standard deviation of spectral acceleration
% prediction FOR AN ARBITRARY OR AVERAGE COMPONENT
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% for the given period T, get the index for the constants
period = [0.01, 0.02, 0.03, 0.04, 0.05, 0.06, 0.075, 0.09, 0.1, 0.12, 0.15, 0.17, 0.2, 0.24, 0.3, 0.36, 0.4, 0.46, 0.5, 0.6, 0.75, 0.85, 1, 1.5, 2, 3, 4, 5];
% fill in missing input parameters with default values
if (nargin < 4) % no soil type supplied
is_soil = 1;
end
if (nargin < 5) % no fault type supplied
fault_type = 0;
end
if (nargin < 6) % no Hanging wall indicator supplied
HW = 0;
end
% interpolate between periods if neccesary
if (length(find(period == T)) == 0)
index_low = sum(period