An extension of the Filon method for the accurate numerical integration of rapidly varying functions