Skip to content
Snippets Groups Projects
Unverified Commit 29a6a553 authored by Amy Stamile's avatar Amy Stamile Committed by GitHub
Browse files

Merge pull request #119 from amystamile-usgs/bundle-adjust

Bundle fixes
parents 5ff60b09 9940f122
No related branches found
No related tags found
No related merge requests found
...@@ -117,3 +117,4 @@ print.prt ...@@ -117,3 +117,4 @@ print.prt
*.CUB *.CUB
.DS_Store .DS_Store
default.profraw
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
File deleted
data/bundle-adjust/G21_026491_2001_XN_20N286W.lev1.cub
data/bundle-adjust/P15_006844_2009_XN_20N286W.lev1.cub
data/bundle-adjust/P17_007846_2007_XN_20N286W.lev1.cub
\ No newline at end of file
...@@ -184,7 +184,7 @@ def compute_sensor_partials(sensor, parameters, ground_pt): ...@@ -184,7 +184,7 @@ def compute_sensor_partials(sensor, parameters, ground_pt):
derivatives are in the same order as the parameter list passed in. derivatives are in the same order as the parameter list passed in.
""" """
partials = np.zeros((2, len(parameters))) partials = np.zeros((2, len(parameters)))
csm_ground = csmapi.EcefCoord(ground_pt.iloc[0], ground_pt.iloc[1], ground_pt.iloc[2]) csm_ground = csmapi.EcefCoord(ground_pt[0], ground_pt[1], ground_pt[2])
for i in range(len(parameters)): for i in range(len(parameters)):
partials[:, i] = sensor.computeSensorPartials(parameters[i].index, csm_ground) partials[:, i] = sensor.computeSensorPartials(parameters[i].index, csm_ground)
return partials return partials
...@@ -208,7 +208,7 @@ def compute_ground_partials(sensor, ground_pt): ...@@ -208,7 +208,7 @@ def compute_ground_partials(sensor, ground_pt):
partials and the second array is the sample partials. The partial partials and the second array is the sample partials. The partial
derivatives are in (x, y, z) order. derivatives are in (x, y, z) order.
""" """
csm_ground = csmapi.EcefCoord(ground_pt.iloc[0], ground_pt.iloc[1], ground_pt.iloc[2]) csm_ground = csmapi.EcefCoord(ground_pt[0], ground_pt[1], ground_pt[2])
partials = np.array(sensor.computeGroundPartials(csm_ground)) partials = np.array(sensor.computeGroundPartials(csm_ground))
return np.reshape(partials, (2, 3)) return np.reshape(partials, (2, 3))
...@@ -282,8 +282,8 @@ def compute_jacobian(network, sensors, parameters, coefficient_columns): ...@@ -282,8 +282,8 @@ def compute_jacobian(network, sensors, parameters, coefficient_columns):
params = parameters[serial] params = parameters[serial]
image_range = coefficient_columns[serial] image_range = coefficient_columns[serial]
point_range = coefficient_columns[row["id"]] point_range = coefficient_columns[row["id"]]
jacobian[2*i : 2*i+2, image_range[0] : image_range[1]] = compute_sensor_partials(sensor, params, ground_pt) jacobian[2*i : 2*i+2, image_range[0] : image_range[1]] = compute_sensor_partials(sensor, params, ground_pt.tolist())
jacobian[2*i : 2*i+2, point_range[0] : point_range[1]] = compute_ground_partials(sensor, ground_pt) jacobian[2*i : 2*i+2, point_range[0] : point_range[1]] = compute_ground_partials(sensor, ground_pt.tolist())
return jacobian return jacobian
...@@ -399,7 +399,7 @@ def compute_residuals(network, sensors): ...@@ -399,7 +399,7 @@ def compute_residuals(network, sensors):
row = network.iloc[i] row = network.iloc[i]
serial = row["serialnumber"] serial = row["serialnumber"]
ground_pt = row[["adjustedX", "adjustedY", "adjustedZ"]].values ground_pt = row[["adjustedX", "adjustedY", "adjustedZ"]].values
ground_pt = csmapi.EcefCoord(ground_pt.iloc[0], ground_pt.iloc[1], ground_pt.iloc[2]) ground_pt = csmapi.EcefCoord(ground_pt[0], ground_pt[1], ground_pt[2])
sensor = sensors[serial] sensor = sensors[serial]
img_coord = sensor.groundToImage(ground_pt) img_coord = sensor.groundToImage(ground_pt)
V[i,:] = [row['line'] - img_coord.line, row['sample'] - img_coord.samp] V[i,:] = [row['line'] - img_coord.line, row['sample'] - img_coord.samp]
...@@ -472,8 +472,15 @@ def compute_sigma0(V, dX, W_parameters, W_observations): ...@@ -472,8 +472,15 @@ def compute_sigma0(V, dX, W_parameters, W_observations):
num_observations = W_observations.shape[0] num_observations = W_observations.shape[0]
dof = num_observations - num_parameters dof = num_observations - num_parameters
VTPV = V.dot(W_observations).dot(V) + dX.dot(W_parameters).dot(dX) VTPV = V.dot(W_observations).dot(V) + dX.dot(W_parameters).dot(dX)
sigma0 = np.sqrt(VTPV/dof)
return sigma0 if (dof > 0):
sigma0 = VTPV/dof
elif (dof == 0):
sigma0 = VTPV
else:
raise ValueError(f"Computed degrees of freedom [{dof}] is invalid.")
return np.sqrt(sigma0)
def compute_sigma0_sparse(V, dX, W_sensors, W_points, W_observations, column_dict): def compute_sigma0_sparse(V, dX, W_sensors, W_points, W_observations, column_dict):
""" """
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment