Skip to content

Commit

Permalink
[bugfix] make localization_iterative return dtype be consistent with …
Browse files Browse the repository at this point in the history
…input dtype

If inputs are arrays, one expects outputs to be arrays. If inputs are
scalars, one expects outputs to be scalars. Many thanks to Pascal Leroux
(IGN) for pointing that out.
  • Loading branch information
carlodef committed Sep 13, 2020
1 parent f2428d5 commit 117f0ff
Showing 1 changed file with 5 additions and 8 deletions.
13 changes: 5 additions & 8 deletions rpcm/rpc_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -222,8 +222,8 @@ def localization_iterative(self, col, row, alt, return_normalized=False):
# use 3 corners of the lon, lat domain and project them into the image
# to get the first estimation of (lon, lat)
# EPS is 2 for the first iteration, then 0.1.
lon = -np.ones(len(Xf))
lat = -np.ones(len(Xf))
lon = -ncol ** 0 # vector of ones
lat = -ncol ** 0
EPS = 2
x0 = apply_rfm(self.col_num, self.col_den, lat, lon, nalt)
y0 = apply_rfm(self.row_num, self.row_den, lat, lon, nalt)
Expand All @@ -250,11 +250,11 @@ def localization_iterative(self, col, row, alt, return_normalized=False):
# <u, e1> / <e1, e1>
num = np.sum(np.multiply(u, e1), axis=1)
den = np.sum(np.multiply(e1, e1), axis=1)
a1 = np.divide(num, den)
a1 = np.divide(num, den).squeeze()

num = np.sum(np.multiply(u, e2), axis=1)
den = np.sum(np.multiply(e2, e2), axis=1)
a2 = np.divide(num, den)
a2 = np.divide(num, den).squeeze()

# use the coefficients a1, a2 to compute an approximation of the
# point on the gound which in turn will give us the new X0
Expand All @@ -279,10 +279,7 @@ def localization_iterative(self, col, row, alt, return_normalized=False):
lon = lon * self.lon_scale + self.lon_offset
lat = lat * self.lat_scale + self.lat_offset

if np.size(lon) == 1 and np.size(lat) == 1:
return lon[0], lat[0]
else:
return lon, lat
return lon, lat


def incidence_angles(self, lon, lat, z):
Expand Down

0 comments on commit 117f0ff

Please sign in to comment.