Skip to content

Commit

Permalink
Merge pull request #55 from mathewcohle/fix/parallel-arc-dist
Browse files Browse the repository at this point in the history
Fix calculation of ParallelArcDist
  • Loading branch information
sebhahn committed May 31, 2018
2 parents f52b897 + d05bc8c commit 06452de
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
5 changes: 2 additions & 3 deletions pygeogrids/geodetic_datum.py
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ def EllN(self, lat):
Parameters
----------
lat : numpy.array, list or float
Geodatic latitudes of the points in the grid
Geodatic latitudes of the points in the grid in degrees
Returns
-------
Expand Down Expand Up @@ -270,10 +270,9 @@ def ParallelArcDist(self, lat, lon1, lon2):
dist : np.array, float
Parallel arc distance
"""
lat = np.deg2rad(lat)
lon1 = np.deg2rad(lon1)
lon2 = np.deg2rad(lon2)
return self.EllN(lat) * np.cos(lat) * (lon2 - lon1)
return self.EllN(lat) * np.cos(np.deg2rad(lat)) * (lon2 - lon1)

def MeridianArcDist(self, lat1, lat2):
"""
Expand Down
7 changes: 7 additions & 0 deletions tests/test_geodatic_datum.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,13 @@ def test_ParallelArcDist(self):
dist = self.datum.ParallelArcDist(0., 0., 360.)
nptest.assert_almost_equal(dist, self.datum.geod.a * 2 * np.pi)

lat, lon1, lon2 = 45., -5., 5.
__, __, great_circle_dist = self.datum.geod.inv(lon1, lat, lon2, lat)
parallel_dist = self.datum.ParallelArcDist(lat, lon1, lon2)

assert great_circle_dist < parallel_dist, \
(great_circle_dist, parallel_dist)


if __name__ == "__main__":
unittest.main()

0 comments on commit 06452de

Please sign in to comment.