Debian Codegraph @

bin/lonlatCoh2ascii

raw
1 #!/bin/csh -f
2 ### lonlatCoh2ascii -- Generate 3 column ASCII file x y z
3 ### Example script to generate grd file from lambda phi Coh
4 ###
5 ### output of Doris InSAR software.
6 ### $Id: lonlatCoh2ascii,v 1.4 2006/06/22 NdO Exp $
7 ### $Maintainer: Anneleen Oyen
8 ################################################################
9 set PRG = `basename "$0"`
10 set VER = "v1.0 Doris software"
11 set AUT = "TUDelft, (c)1999-2011"
12 echo "$PRG $VER, $AUT"
13 echo " "
14
15
16
17 ### Handle wrong input
18 set WRONG = "0"
19 ### Input files.
20 set LON = "$1"
21 set LAT = "$2"
22 set COH = "$3"
23 set XYCOHFILE = "$4"
24 if ( ! -f "$LAT" ) set WRONG = "1"
25 if ( ! -f "$LON" ) set WRONG = "1"
26 if ( ! -f "$COH" ) set WRONG = "1"
27 if ( $#argv < 4 ) set WRONG = "1"
28 if ( $WRONG == "1" ) then
29 cat << __EOFHD
30
31 SYNOPSIS:
32
33 $PRG longitude_file latitude_file Coh_file output_Coh_file
34
35 This csh-script creates a 3 column ASCII file with "lon lat coh"
36 from the binary doris output (matrices) after step geocode.
37 It filters out invalid data, indicated with "-999" by Doris.
38
39 The output file can be used further with GMT to create a grd file.
40 The format of the 3 input files are matrices in real4 float format.
41 all of the same size. They describe the irregular geocoded position
42 of the pixels in the interferogram, and the corresponding heights.
43
44 The steps taken are within this script:
45 1) Create 3 temporary ASCII files with all data in a single
46 large column using cpxfiddle program;
47 2) Create two 3 column ASCII file (lon lat ***)
48 using "paste";
49 3) remove -999 invalid data using "grep"
50 4) Tidy up, remove temp files.
51
52 These steps may take a while. Obviously staying in binary format
53 would be better. This script is intented to work on all platforms,
54 and to be straightforward and understandable, rather than ingenious.
55
56 DEPENDENCIES:
57
58 cpxfiddle program, part of Doris distribution.
59 grep utility, standard UNIX
60 paste utility, standard UNIX
61 Note that lambda=longitude; phi=latitude
62
63 EXAMPLE:
64
65 $PRG Outdata/lambda.raw Outdata/phi.raw Outdata/Coherence.raw lonlatcoh.dat
66
67 SEE ALSO:
68
69 cpxfiddle, paste, grep, http://gmt.soest.hawaii.edu/
70
71
72 __EOFHD
73 exit 1
74 endif
75
76
77
78 ### Probably smarter is gmtconvert, but OK. ###################################
79 ### Convert binary files to ASCII row; trick cpxfiddle with -w1.
80 echo " Convert LONGITUDES in binary real4 file" \"${LON}\" "to ASCII table"
81 #cpxfiddle -w1 -qnormal -fcr4 $LON | awk '{printf "%3.4f\n%3.4f\n",$1,$2}' > qlon
82 # using new r4 option to cpxfiddle
83 # cpxfiddle -w1 -qnormal -fr4 $LON > qlon1
84 echo " Convert LATITUDES in binary real4 file" \"${LAT}\" "to ASCII table"
85 # cpxfiddle -w1 -qnormal -fr4 $LAT > qlat1
86 echo " Convert COHERENCE in binary real4 file" \"${COH}\" "to ASCII table"
87 cpxfiddle -w1 -qnormal -fr4 $COH > qcoh
88
89
90 ### Create xyz file, delete temp files. ########################################
91 echo "Paste LON/LAT/COH to xyzfile" \"${XYCOHFILE}\"
92 paste qlon1 qlat1 qcoh > $XYCOHFILE.tmp
93 echo "removing -999 from input (if there was an unwrapping problem, or other problem)"
94 grep -v '\-999' $XYCOHFILE.tmp > $XYCOHFILE
95 # rm -f qlon1 qlat1 qcoh $XYCOHFILE.tmp
96 rm -f $XYCOHFILE.tmp
97
98
99 ### EOF.
100 echo "finished..."
101