Skip to content

Commit

Permalink
tests, cleanup: Updated tests with more ranges. Cleaned up misc comme…
Browse files Browse the repository at this point in the history
…nted out print statements
  • Loading branch information
JuLieAlgebra committed Mar 17, 2024
1 parent b8f44ea commit f78c34a
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 10 deletions.
4 changes: 1 addition & 3 deletions icedyno/preprocess/geolocation.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,7 @@ def polar_xy_to_lonlat(
lat = lat * 180 / np.pi
lon = np.arctan2(x, -y)
lon = lon * 180 / np.pi
print("this is lon: ", lon)
# lon = lon + np.less(lon, 0) * 360
# print("again lon: ", lon)

return lon, lat


Expand Down
Empty file removed tests/__init__.py
Empty file.
17 changes: 10 additions & 7 deletions tests/test_geolocation.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,15 @@

def test_xy_to_latlon_inversion():
"""Test that xy to latlon and latlon to xy invert each other"""
lat = 77.508333
lon = -164.754167
lats = [77.508333, 80, 67, 55]
lons = [-164.754167, -80, 90, 155]

xy_converted_coordinates = geolocation.polar_lonlat_to_xy(
longitude=lon, latitude=lat
)
for i in range(len(lats)):
lat = lats[i]
lon = lons[i]
xy_converted_coordinates = geolocation.polar_lonlat_to_xy(
longitude=lon, latitude=lat
)

reverted_lat_lon = geolocation.polar_xy_to_lonlat(*xy_converted_coordinates)
assert np.allclose((lon, lat), reverted_lat_lon)
reverted_lat_lon = geolocation.polar_xy_to_lonlat(*xy_converted_coordinates)
assert np.allclose((lon, lat), reverted_lat_lon)

0 comments on commit f78c34a

Please sign in to comment.