Differences between revisions 12 and 14 (spanning 2 versions)
Revision 12 as of 2008-07-10 10:06:32
Size: 3409
Editor: NinaMaass
Comment:
Revision 14 as of 2008-07-11 09:08:12
Size: 3681
Editor: NinaMaass
Comment:
Deletions are marked like this. Additions are marked like this.
Line 4: Line 4:
  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
  Eckpunkten und Aufloseung des ASAR-Bildes variieren frei -> allgemeingueltiges Programm fuer den Uebergang
  des Outputs erfolgt als Vektor in der Form x, y, Freiboardhoehe(fbh)
Line 15: Line 15:
from LinearAlgebra import *
from Numeric import *
from coord_transform import *
from scipy import *
Line 29: Line 29:
        # polarstereographic coordinate system
    y00,x00,y01,x01,y02,x02,y03,x03=int(ASAR_p[1]),int(ASAR_p[0]),int(ASAR_p[7]),int(ASAR_p[6]),int(ASAR_p[5]),int(ASAR_p[4]),int(ASAR_p[3]),int(ASAR_p[2])
    # new coordinate system with normalized coordinates
    y10,x10,y11,x11,y12,x12,y13,x13=0,0,1,0,1,1,0,1
Line 35: Line 30:
    # calculating transformation matrix:
    P0=array([[x00, x01, x02, x03],[y00,y01,y02,y03],[1.0,1.0,1.0,1.0]])
    P1=array([[x10, x11, x12, x13],[y10,y11,y12,y13],[1.0,1.0,1.0,1.0]])

    Faktor1=dot(P1,transpose(P0))
    Faktor2=inverse(dot(P0,transpose(P0)))
    A=dot(Faktor1,Faktor2) # Transformation matrix
    A=coord_transformation(ASAR_p)
Line 44: Line 33:
    ICESAT_p,fbh=read_icesat(filename2,sgn)     ICESAT_p,fbh=read_icesat(filename2,sgn)    #fbh are measured freeboard heights in cm
Line 52: Line 41:
   
Line 71: Line 60:
    return x_y_fbh      return x_y_fbh
Line 73: Line 62:

'''coord_transform.py'''
{{{#!python
from Numeric import *
import LinearAlgebra as la

def coord_transformation(ASAR_p):
    # polarstereographic coordinate system
    y00,x00,y01,x01,y02,x02,y03,x03=int(ASAR_p[1]),int(ASAR_p[0]),int(ASAR_p[7]),int(ASAR_p[6]),int(ASAR_p[5]),int(ASAR_p[4]),int(ASAR_p[3]),int(ASAR_p[2])
    # new coordinate system with normalized coordinates
    y10,x10,y11,x11,y12,x12,y13,x13=0,0,1,0,1,1,0,1

    # calculating transformation matrix:
    P0=array([[x00, x01, x02, x03],[y00,y01,y02,y03],[1.0,1.0,1.0,1.0]])
    P1=array([[x10, x11, x12, x13],[y10,y11,y12,y13],[1.0,1.0,1.0,1.0]])

    Faktor1=dot(P1,transpose(P0))
    Faktor2=la.inverse(dot(P0,transpose(P0)))
    A=dot(Faktor1,Faktor2) # Transformation matrix
    return A
}}}


'''read_icesat.py'''
Line 98: Line 112:

{{attachment.schemabild2.jpg}}

Die Besprechung ueber das Vorgehen ihrer Aufgaben ergab:

  • die Transformation in polarstereographische Koordinaten und der nachfolgende Uebergang zu den Bildpunkten von ASAR

    Eckpunkten und Aufloseung des ASAR-Bildes variieren frei -> allgemeingueltiges Programm fuer den Uebergang des Outputs erfolgt als Vektor in der Form x, y, Freiboardhoehe(fbh)

fbh_bildkoordinaten.py

   1 from polar_projection import *
   2 from read_asar import *
   3 from read_icesat import *
   4 from coord_transform import *
   5 from scipy import *
   6 
   7 def fit_freeboard_ASAR(filename1,filename2):
   8     """filename1: ASAR data file, filename2: freeboard data file
   9        creates new coordinate system defined by corners of ASAR image and selects freeboard values within ASAR image box
  10        returns an array containing normalized image coordinates and corresponding freeboard values:
  11        [x_coordinate, y_coordinate, freeboardheight(cm)]"""
  12     
  13     sgn=-1  #Antarctica
  14     ASAR=array(read_asar_corners(filename1))
  15     ASAR_p=zeros(8)
  16     for k in arange(0,7,2):       #computing polarstereographic coordinates
  17         ASAR_p[k:k+2]=mapll(ASAR[k],ASAR[k+1],sgn)
  18 
  19     A=coord_transformation(ASAR_p)
  20 
  21     # reading freeboard data and computing geographic into polarstereographic coordinates
  22     ICESAT_p,fbh=read_icesat(filename2,sgn)    #fbh are measured freeboard heights in cm
  23 
  24     # calculating new coordinates for freeboard data
  25     x_neu=[]
  26     y_neu=[]
  27     for x,y in zip(ICESAT_p[0],ICESAT_p[1]):
  28         x_neu.append(dot(array([A[0,0],A[0,1]]),array([x,y]))+A[0,2])
  29         y_neu.append(dot(array([A[1,0],A[1,1]]),array([x,y]))+A[1,2])
  30    
  31     # cutting off non-corresponding data values  
  32     m=-1
  33     index_vec=[]
  34     for xn,yn in zip(x_neu,y_neu):
  35         m=m+1
  36         if xn<=1. and xn >=0. and yn<=1. and yn >=0.:
  37             index_vec.append(m)
  38 
  39     x_bild=[]
  40     y_bild=[] 
  41     fbh_bild=[]
  42     for i in index_vec:
  43         x_bild.append(x_neu[i])
  44         y_bild.append(y_neu[i])
  45         fbh_bild.append(fbh[i])
  46 
  47     x_y_fbh=array([x_bild,y_bild,fbh_bild])
  48 
  49     return x_y_fbh

coord_transform.py

   1 from Numeric import *
   2 import LinearAlgebra as la
   3 
   4 def coord_transformation(ASAR_p):
   5     # polarstereographic coordinate system
   6     y00,x00,y01,x01,y02,x02,y03,x03=int(ASAR_p[1]),int(ASAR_p[0]),int(ASAR_p[7]),int(ASAR_p[6]),int(ASAR_p[5]),int(ASAR_p[4]),int(ASAR_p[3]),int(ASAR_p[2])
   7     # new coordinate system with normalized coordinates  
   8     y10,x10,y11,x11,y12,x12,y13,x13=0,0,1,0,1,1,0,1
   9 
  10     # calculating transformation matrix:
  11     P0=array([[x00, x01, x02, x03],[y00,y01,y02,y03],[1.0,1.0,1.0,1.0]])
  12     P1=array([[x10, x11, x12, x13],[y10,y11,y12,y13],[1.0,1.0,1.0,1.0]])
  13 
  14     Faktor1=dot(P1,transpose(P0))
  15     Faktor2=la.inverse(dot(P0,transpose(P0)))
  16     A=dot(Faktor1,Faktor2)  # Transformation matrix
  17     return A

read_icesat.py

   1 import string
   2 from polar_projection import *
   3 from scipy import io
   4 
   5 def read_icesat(filename,sgn):
   6     data=io.read_array(filename)
   7     polar=mapll(data[:,1],data[:,0],sgn)
   8     fbh=data[:,2]
   9     return polar,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

Zum Testen hängt man an das obige Programm folgende Zeilen an:

   1 filename1='ASA_IMP_1PNDPA20060617_043346_000000162048_00362_22460_2136.N1'
   2 filename2='LonLatFre_1706_6.xyz'
   3 ergebnis=fit_freeboard_ASAR(filename1,filename2)

schemabild.jpg

attachment.schemabild2.jpg

LehreWiki: \AG1_Freibord (last edited 2008-07-11 11:19:34 by NinaMaass)