Debian Codegraph @

bin/lonlathei2ascii

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