Skip to content

Commit

Permalink
Fix numpy warning and rounding error
Browse files Browse the repository at this point in the history
  • Loading branch information
seignovert committed Jan 13, 2023
1 parent 5ada317 commit fecabb1
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
13 changes: 7 additions & 6 deletions pyvims/projections/img.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,19 +23,20 @@ def index(img, lon_w, lat):
"""
h, w = np.shape(img)[:2]

i = np.round(np.multiply(-1, lon_w) % 360 * w / 360).astype(int)
j = np.round(np.subtract(90, lat) * h / 180).astype(int)
i = np.round(np.multiply(-1, lon_w) % 360 * w / 360)
j = np.round(np.subtract(90, lat) * h / 180)

if np.ndim(lon_w) == 0:
if i >= w or np.isnan(lon_w):
i = w - 1
if np.isnan(lat):
j = h - 1
else:
i[(i >= w) | np.isnan(lon_w)] = w - 1
j[(j >= h) | np.isnan(lat)] = h - 1
return int(j), int(i)

i[(i >= w) | np.isnan(lon_w)] = w - 1
j[(j >= h) | np.isnan(lat)] = h - 1

return j, i
return j.astype(int), i.astype(int)


def bg_pole(img, proj, lat_1=60, n=1024):
Expand Down
3 changes: 2 additions & 1 deletion pyvims/projections/sky.py
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,8 @@ def radec(self, x, y):
u = np.divide(u, norm)

v = np.dot(self.m.T, u)
ra = np.degrees(np.arctan2(v[1], v[0])) % 360
d, i = np.modf(np.degrees(np.arctan2(v[1], v[0])))
ra = np.mod(i, 360) + d
dec = np.degrees(np.arcsin(v[2]))

if shape is not None:
Expand Down

0 comments on commit fecabb1

Please sign in to comment.