Move gravity calculation into a generic function
Merge pull request #124 from jorams/gravity-generic

Move gravity calculation into a generic function