Size: 6549
Comment:
|
Size: 6596
Comment:
|
Deletions are marked like this. | Additions are marked like this. |
Line 17: | Line 17: |
"""filename1: ASAR data file, filename2: freeboard data file, resolution: data resolution creates new coordinate system defined by corners of ASAR image and selects freeboard values within ASAR image box returns an array containing normalized image coordinates and corresponding freeboard values: |
"""filename1: ASAR data file, filename2: freeboard data file, resolution: ASAR image data resolution creates new coordinate system defined by corners of ASAR image and selects freeboard values within ASAR image box and returns an array containing normalized image coordinates and corresponding freeboard values: |
Line 107: | Line 108: |
"""filename1: ASAR data file, filename2: freeboard data file, resolution: data resolution creates new coordinate system defined by corners of ASAR image and selects freeboard values within ASAR image box returns an array containing normalized image coordinates and corresponding freeboard values: |
"""filename1: ASAR data file, filename2: freeboard data file, resolution: ASAR image data resolution creates new coordinate system defined by corners of ASAR image and selects freeboard values within ASAR image box returns an array containing normalized image coordinates and corresponding freeboard values: |
Die Besprechung ueber das Vorgehen ihrer Aufgaben ergab:
- die Transformation in polarstereographische Koordinaten und der nachfolgende Uebergang zu den Bildpunkten von ASAR
Eckpunkte und Aufloseung des ASAR-Bildes variieren frei -> allgemeingueltiges Programm fuer den Uebergang der Output erfolgt als Vektor in der Form x, y, Freiboardhoehe; eventuell die Floatangabe
fbh_bildkoordinaten.py
1 from polar_projection import *
2 from read_asar import *
3 import string
4
5 def fit_freeboard_ASAR(filename1,filename2,resolution):
6 """filename1: ASAR data file, filename2: freeboard data file, resolution: ASAR image data resolution
7 creates new coordinate system defined by corners of ASAR image and selects freeboard values within
8 ASAR image box and returns an array containing normalized image coordinates and corresponding
9 freeboard values:
10 [x_coordinate, y_coordinate, freeboardheight(cm)]"""
11
12 sgn=-1 #Antarctica
13 lat1,lon1,lat2,lon2,lat3,lon3,lat4,lon4=read_asar_corners(filename1)
14
15 ASAR_1=[lat1,lon1]
16 ASAR_2=[lat2,lon2]
17 ASAR_3=[lat3,lon3]
18 ASAR_4=[lat4,lon4]
19
20 ASAR_1p=mapll(ASAR_1[0],ASAR_1[1],sgn) #computing polarstereographic coordinates
21 ASAR_2p=mapll(ASAR_2[0],ASAR_2[1],sgn)
22 ASAR_3p=mapll(ASAR_3[0],ASAR_3[1],sgn)
23 ASAR_4p=mapll(ASAR_4[0],ASAR_4[1],sgn)
24
25 X=int(abs(ASAR_2p[0]-ASAR_1p[0])/resolution) #image size in pixel
26 Y=int(abs(ASAR_4p[1]-ASAR_1p[1])/resolution)
27
28 # polarstereographic coordinate system
29 y00,x00,y01,x01,y02,x02,y03,x03=int(ASAR_1p[1]),int(ASAR_1p[0]),int(ASAR_4p[1]),int(ASAR_4p[0]),int(ASAR_3p[1]),int(ASAR_3p[0]),int(ASAR_2p[1]),int(ASAR_2p[0])
30 # new coordinate system with normalized coordinates
31 y10,x10,y11,x11,y12,x12,y13,x13=0,0,1,0,1,1,0,1
32
33 # calculating transformation matrix:
34 P0=array([[x00, x01, x02, x03],[y00,y01,y02,y03],[1.0,1.0,1.0,1.0]])
35 P1=array([[x10, x11, x12, x13],[y10,y11,y12,y13],[1.0,1.0,1.0,1.0]])
36
37 Faktor1=dot(P1,transpose(P0))
38 Faktor2=inverse(dot(P0,transpose(P0)))
39 A=dot(Faktor1,Faktor2) # Transformation matrix
40
41 # reading freeboard data
42 lon=[]
43 lat=[]
44 fbh=[]
45 datei = open (filename2, 'r')
46 line=datei.readline()
47 k=-1
48 while line!="":
49 k=k+1
50 data=string.split(line)
51 lon.append(float(data[0]))
52 lat.append(abs(float(data[1])))
53 fbh.append(float(data[2]))
54 line=datei.readline()
55
56 polar=mapll(array(lat),array(lon),sgn)
57
58 # calculating new coordinates for freeboard data
59 x_neu=[]
60 y_neu=[]
61 for x,y in zip(polar[0],polar[1]):
62 x_neu.append(dot(array([A[0,0],A[0,1]]),array([x,y]))+A[0,2])
63 y_neu.append(dot(array([A[1,0],A[1,1]]),array([x,y]))+A[1,2])
64
65 # cutting off non-corresponding data values
66 m=-1
67 index_vec=[]
68 for xn,yn in zip(x_neu,y_neu):
69 m=m+1
70 if xn<=1. and xn >=0. and yn<=1. and yn >=0.:
71 index_vec.append(m)
72
73 x_bild=[]
74 y_bild=[]
75 fbh_bild=[]
76 for i in index_vec:
77 x_bild.append(x_neu[i])
78 y_bild.append(y_neu[i])
79 fbh_bild.append(fbh[i])
80
81 x_y_fbh=array([x_bild,y_bild,fbh_bild])
82
83 return x_y_fbh
Die benötigten Module polar_projection.py und read_asar.py sind auf der Seite der Arbeitsgruppe 0 AG0_ASAR_Einlesen zu finden.
fbh_bildkoordinaten_test.py
1 from polar_projection import *
2 from read_asar import *
3 import string
4
5 def fit_freeboard_ASAR(filename1,filename2,resolution):
6 """filename1: ASAR data file, filename2: freeboard data file, resolution: ASAR image data resolution
7 creates new coordinate system defined by corners of ASAR image and selects freeboard values within
8 ASAR image box returns an array containing normalized image coordinates and corresponding
9 freeboard values:
10 [x_coordinate, y_coordinate, freeboardheight(cm)]"""
11
12 sgn=-1 #Antarctica
13 lat1,lon1,lat2,lon2,lat3,lon3,lat4,lon4=read_asar_corners(filename1)
14
15 ASAR_1=[lat1,lon1]
16 ASAR_2=[lat2,lon2]
17 ASAR_3=[lat3,lon3]
18 ASAR_4=[lat4,lon4]
19
20 ASAR_1p=mapll(ASAR_1[0],ASAR_1[1],sgn) #computing polarstereographic coordinates
21 ASAR_2p=mapll(ASAR_2[0],ASAR_2[1],sgn)
22 ASAR_3p=mapll(ASAR_3[0],ASAR_3[1],sgn)
23 ASAR_4p=mapll(ASAR_4[0],ASAR_4[1],sgn)
24
25 X=int(abs(ASAR_2p[0]-ASAR_1p[0])/resolution) #image size in pixel
26 Y=int(abs(ASAR_4p[1]-ASAR_1p[1])/resolution)
27
28 # polarstereographic coordinate system
29 y00,x00,y01,x01,y02,x02,y03,x03=int(ASAR_1p[1]),int(ASAR_1p[0]),int(ASAR_4p[1]),int(ASAR_4p[0]),int(ASAR_3p[1]),int(ASAR_3p[0]),int(ASAR_2p[1]),int(ASAR_2p[0])
30 # new coordinate system with normalized coordinates
31 y10,x10,y11,x11,y12,x12,y13,x13=0,0,1,0,1,1,0,1
32
33 # calculating transformation matrix:
34 P0=array([[x00, x01, x02, x03],[y00,y01,y02,y03],[1.0,1.0,1.0,1.0]])
35 P1=array([[x10, x11, x12, x13],[y10,y11,y12,y13],[1.0,1.0,1.0,1.0]])
36
37 Faktor1=dot(P1,transpose(P0))
38 Faktor2=inverse(dot(P0,transpose(P0)))
39 A=dot(Faktor1,Faktor2) # Transformation matrix
40
41 # reading freeboard data
42 lon=[]
43 lat=[]
44 fbh=[]
45 datei = open (filename2, 'r')
46 line=datei.readline()
47 k=-1
48 while line!="":
49 k=k+1
50 data=string.split(line)
51 lon.append(float(data[0]))
52 lat.append(abs(float(data[1])))
53 fbh.append(float(data[2]))
54 line=datei.readline()
55
56 polar=mapll(array(lat),array(lon),sgn)
57
58 # calculating new coordinates for freeboard data
59 x_neu=[]
60 y_neu=[]
61 for x,y in zip(polar[0],polar[1]):
62 x_neu.append(dot(array([A[0,0],A[0,1]]),array([x,y]))+A[0,2])
63 y_neu.append(dot(array([A[1,0],A[1,1]]),array([x,y]))+A[1,2])
64
65 # cutting off non-corresponding data values
66 m=-1
67 index_vec=[]
68 for xn,yn in zip(x_neu,y_neu):
69 m=m+1
70 if xn<=1. and xn >=0. and yn<=1. and yn >=0.:
71 index_vec.append(m)
72
73 x_bild=[]
74 y_bild=[]
75 fbh_bild=[]
76 for i in index_vec:
77 x_bild.append(x_neu[i])
78 y_bild.append(y_neu[i])
79 fbh_bild.append(fbh[i])
80
81 x_y_fbh=array([x_bild,y_bild,fbh_bild])
82
83 return x_y_fbh
84
85 filename1='ASA_IMP_1PNDPA20060617_043346_000000162048_00362_22460_2136.N1'
86 filename2='LonLatFre_1706_6.xyz'
87 resolution=0.025
88 ergebnis=fit_freeboard_ASAR(filename1,filename2,resolution)