Python: Least Square Adjustment using parameter

18 04 2011

20110418

Least square adjustment

Example 4 : Adjustment by parameter

Leveling problem as show in image

example4: Least square adjustment

the different of height show in table below

–from– —– — to — — Δh (m.) —
======|=======|==========
E                     A              42.107
B                     A              12.424
C                     B               42.251
C                     D                 8.464
D                     E                 4.138
D                     A              46.269
D                     B               33.802
======|=======|==========

Elevation of point E is 500.000 m. and weight of observation data is invert distance of each point. find all point elevation

solve:
n = 7, n_0 = 4, r = 7-4=3, u = n_0 = 4

set data to equation
v + BΔ = Wf

from least square let
N = B(T) * W * B
t = B(T) * W * f
and
Δ =inv(N) * t

calculate in Python

## Least Square Adjustment
## Example: 4
## Adjustment by Parameter
## Leveling

## Point E has elevation is 500.00 m. MSL
## n = 7, n0 = 4, r = 3


import numpy as np
## V + B * Delta = d - l * W

##Delta

Delta = np.array([["A"],["B"],["C"],["D"]])

##Matrix B

B = np.matrix([[-1.,0,0,0],[-1,1,0,0],[0,-1,1,0],[0,0,1.,-1],[0,0,0,1],[-1,0,0,1],[0,-1,0,1]])

print B

##Matrix of Weight

W = np.matrix([[1./8,0.,0.,0.,0.,0.,0.],[0,1./6,0.,0.,0.,0.,0.],[0.,0.,1./3,0.,0.,0.,0.],[0,0,0,1./6,0,0,0],[0,0,0,0,1./7,0,0],[0,0,0,0,0,1./3,0],[0,0,0,0,0,0,1./5]])

print W

##Matrix f

f = np.matrix([[-542.107],[-12.424],[-42.251],[-8.464],[495.862],[-46.269],[-33.802]])

print f

## N = B^T * W * B

N = B.T * W * B

## t = B^T * W * f

t = B.T * W * f

## delta = N^(-1) * t
invN = np.linalg.inv(N)
delta = invN * t

print "Leveling"
print delta

and output show this
Leveling
[[ 542.11261789]
 [ 529.66589837]
 [ 487.40762703]
 [ 495.85708435]]

เริ่มจากง่ายๆ ไปก่อนนะครับจะได้เรียนรู้การใช้ array ต่างๆ ของไพธอนและการทำงานของแมทริกซ์ใน numpy
คำตอบที่ได้คือค่าระดับของจุด A,B,C และ D ตามลำดับ

Actions

Information

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s




%d bloggers like this: