Sabtu, 04 Desember 2010

Cross of Sumatra




#!/bin/csh
# & rubah menjadi <
gmtset ANNOT_FONT_SIZE_PRIMARY 10p HEADER_FONT_SIZE 18p PLOT_DEGREE_FORMAT ddd:mm:ssF
set region = 90/107/-10/7
set size = M11c
set psfile = 4cross.ps
set grdfile=./sumatra.nc
set cptfile=color.cpt
makecpt -Cglobe -Z > $cptfile
set AZ = 45

#Cross box near subduction
set boxlon = 99.0
set boxlat = -4.0
set boxdep = 0
echo $boxlon $boxlat $boxdep >! box.d

#Draw bathymetry and basemap
grdgradient $grdfile -A30/270 -Gintens.grd -Nt0.30 -V
grdimage $grdfile -R$region -J$size -C$cptfile -Iintens.grd -K -P -Ba4f1NWse -X2 -Y17 >! $psfile

gmtset ANOT_FONT_SIZE 9
pscoast -R$region -J$size -C$cptfile -Dl -W1 -P -Lf92.0/-9/40/60 -Tf92.0/-8.65/10i/3 -O -K  >> $psfile

#Draw cross centre
awk -F, '{ print $1, $2}' box.d | psxy -J$size -R$region -Sx.5/.5 -W2::0 -P -O -K  >> $psfile

# Draw tectonical structures
awk -F, '{ print $1, $2}' ../focalproposal/trench.gmt | psxy -R$region -J$size -Gdarkblue -Sc0.05 -O -K >> $psfile
awk -F, '{ print $1, $2}' ../focalproposal/transform.gmt | psxy -R$region -J$size -Gdarkblue -Sc0.05 -O -K >> $psfile
awk -F, '{ print $1, $2}' ../focalproposal/ridge.gmt | psxy -R$region -J$size -Gdarkblue -Sc0.05 -O -K >> $psfile

#Draw usgs data
awk -F, '{ print $1, $2}' ../focalproposal/gempa_kecil.lst | psxy -J$size -R$region -Sc0.1c -W0.1 -H -P -O -K >> $psfile
awk -F, '{ print $1, $2}' ../focalproposal/gempa_sedang.lst | psxy -J$size -R$region -Sc0.15c -W0.15 -H -P -O -K >> $psfile
awk -F, '{ print $1, $2}' ../focalproposal/gempa_besar.lst | psxy -J$size -R$region -Sc0.2c -W0.2 -H -P -O -K >> $psfile


#Projection with the center
awk -F, '{ print $1, $2, $3}' ../focalproposal/trench.gmt  | project -Q -C$boxlon/$boxlat -A$AZ -Fxyzpqrs -L-10/550 -W-50/50 >! xyzpqrs_trench
awk -F, '{ print $1, $2, $3}' ../focalproposal/transform.gmt | project -Q -C$boxlon/$boxlat -A$AZ -Fxyzpqrs -L-10/550 -W-50/50 >! xyzpqrs_transform
awk -F, '{ print $1, $2, $3}' ../focalproposal/ridge.gmt  | project -Q -C$boxlon/$boxlat -A$AZ -Fxyzpqrs -L-10/550 -W-50/50 >! xyzpqrs_ridge

awk -F, '{ print $1, $2, $3}' ../focalproposal/gempa_kecil.lst  | project -Q -C$boxlon/$boxlat -A$AZ -Fxyzpqrs -L-10/550 -W-50/50 >! xyzpqrs_kecil
awk -F, '{ print $1, $2, $3}' ../focalproposal/gempa_sedang.lst  | project -Q -C$boxlon/$boxlat -A$AZ -Fxyzpqrs -L-10/550 -W-50/50 >! xyzpqrs_sedang
awk -F, '{ print $1, $2, $3}' ../focalproposal/gempa_besar.lst  | project -Q -C$boxlon/$boxlat -A$AZ -Fxyzpqrs -L-10/550 -W-50/50 >! xyzpqrs_besar


#Plot projected earthquakes  (red dots) and mainshock (yellow star) on map
awk '{print $1, $2}' xyzpqrs_kecil | psxy -J$size -R$region -Sc0.1c -W0.1/red -P -O -K >> $psfile
awk '{print $1, $2}' xyzpqrs_sedang | psxy -J$size -R$region -Sc0.15c -W0.15/red  -P -O -K >> $psfile
awk '{print $1, $2}' xyzpqrs_besar | psxy -J$size -R$region -Sc0.2c -W0.2/red  -P -O -K >> $psfile

#Mainshock will appear in front of all earthquakes
#BE CAREFULL !!  MAINSHOCK FILE MUST CONSIST OF LON LAT DEPTH
awk '{print $1, $2}' ../focalproposal/cobi.d | psxy -J$size -R$region -Sa0.4c -Gyellow  -Wthin -P -O -K  >> $psfile
project -Q -C$boxlon/$boxlat -A$AZ ../focalproposal/cobi.d -Fxyzpqrs -L-10/550 -W-50/50 >! xyzpqrs_cobi

#Focalmec lines taken from true epicenter
sed -n '2,3p' ../focalproposal/test.txt | psxy -R$region -J$size -Ggray -W1 -O -K >> $psfile
sed -n '5,6p' ../focalproposal/test.txt | psxy -R$region -J$size -Ggray -W1 -O -K >> $psfile
sed -n '8,9p' ../focalproposal/test.txt | psxy -R$region -J$size -Ggray -W1 -O -K >> $psfile
....................................

#Modified location of Global CMT's focalmec
psmeca ../focalproposal/focaltop_cmt.gmt -R$region -J$size -Sm0.25c/-1 -Gred -W1 -O -K >> $psfile
pstext ../focalproposal/cibi.txt -R$region -J$size -Gblack -O -K >> $psfile

#Drawing box and line of cross section on map
psxy box.txt -J$size -R$region -W0.5 -P -O -K >> $psfile
awk '{print $1, $2}' line.txt | psxy -J$size -R$region -W0.5 -P -O -K >> $psfile
awk '{print $1, $2, 14, 0, 1, "LT", $3 }' line.txt | pstext -J$size -R$region -Gdarkblue -P -O -K >> $psfile

#DRAW CROSSEC DIAGRAM
psbasemap -JX9.5/-5 -R0/550/0/300 -B50/30NWes -P -O -K  -Y-7 >> $psfile
pstext -JX -R  -Gdarkblue -P -O -K <> $psfile
0    0   14 0 1 LT C
520  0   14 0 1 LT C'
EOF

#Plot stars of structures, earthquakes, and mainshocks on crossec diagram
awk '{print $4, $3}' xyzpqrs_trench | psxy -JX -R  -Gdarkblue -Sc0.2 -P -O -K >> $psfile
awk '{print $4, $3}' xyzpqrs_transform | psxy -JX -R  -Gdarkblue -Sc0.2 -P -O -K >> $psfile
awk '{print $4, $3}' xyzpqrs_ridge | psxy -JX -R  -Gdarkblue -Sc0.2 -P -O -K >> $psfile

awk '{print $4, $3}' xyzpqrs_kecil | psxy -JX -R  -Sc0.1c -W0.1/red -P -O -K >> $psfile
awk '{print $4, $3}' xyzpqrs_sedang | psxy -JX -R  -Sc0.15c -W0.15/red -P -O -K >> $psfile
awk '{print $4, $3}' xyzpqrs_besar | psxy -JX -R  -Sc0.2c -W0.2/red -P -O -K >> $psfile

awk '{print $4, $3}' xyzpqrs_cobi | psxy -JX -R  -Sa0.4c -Gyellow -Wthin -P -O -K >> $psfile

psscale -C$cptfile -Iintens.grd -D0.4c/1/10/0.15 -B1000 -P -O -K -X11.5c -Y12c >> $psfile

# Create legend of magnitude size
cat << EOF >! magnitude.legend
N 3
S 0.025i c 0.04i red 0.010p 0.1i   mag 3.5-4.5
S 0.020i c 0.06i red 0.015p 0.1i   mag 4.5-5.5
S 0.015i c 0.08i red 0.020p 0.1i   mag 5.5-9.5

&
EOF

pslegend magnitude.legend -Dx0.1i/-0.2i/6.8i/1.5i/TC -Jx0.4i -R0/8/0/8 -O -X-4c -Y-5 >> $psfile

\rm -f *.d *.xy xyzpqrs_*
gs -sDEVICE=x11 $psfile

Special order

Jumat, 03 Desember 2010

Myjob : kemajuan1

KATALOG TSUNAMI INDONESIA 1990 - 2010


 



#!/bin/csh
gmtset ANNOT_FONT_SIZE_PRIMARY 10p HEADER_FONT_SIZE 18p PLOT_DEGREE_FORMAT ddd:mm:ssF
set area = 90/140/-15/9
set psfile = top.ps
set grdfile=./indo.nc
set cptfile=color.cpt
makecpt -Cglobe -Z > $cptfile
grdgradient $grdfile -A30/270 -Gintens.grd -Nt0.30 -V
grdimage $grdfile -R$area -JM18c -C$cptfile -Iintens.grd -P -K -X1.5 -Y8 >! $psfile


gmtset ANOT_FONT_SIZE 9
pscoast -R$area -JM18c  -Df -W2,100 -P -Ba4f2/a4f2NWSE -O -K >> $psfile

awk -F, '{ print $1, $2}' ./trench.gmt | psxy -R$area -J -Gdarkblue -Sc0.05 -O -K >> $psfile
awk -F, '{ print $1, $2}' ./transform.gmt | psxy -R$area -J -Gdarkblue -Sc0.05 -O -K >> $psfile
awk -F, '{ print $1, $2}' ./ridge.gmt | psxy -R$area -J -Gdarkblue -Sc0.05 -O -K >> $psfile
awk -F, '{ print $1, $2}' ./cobi.d | psxy -R$area -J -Gyellow -W1 -Sa0.2 -O -K >> $psfile

sed -n '2,3p' test.txt | psxy -R$area -JM -Ggray -W1 -O -K >> $psfile
sed -n '5,6p' test.txt | psxy -R$area -JM -Ggray -W1 -O -K >> $psfile
sed -n '8,9p' test.txt | psxy -R$area -JM -Ggray -W1 -O -K >> $psfile
sed -n '11,12p' test.txt | psxy -R$area -JM -Ggray -W1 -O -K >> $psfile
sed -n '14,15p' test.txt | psxy -R$area -JM -Ggray -W1 -O -K >> $psfile
sed -n '17,18p' test.txt | psxy -R$area -JM -Ggray -W1 -O -K >> $psfile
sed -n '20,21p' test.txt | psxy -R$area -JM -Ggray -W1 -O -K >> $psfile
sed -n '23,24p' test.txt | psxy -R$area -JM -Ggray -W1 -O -K >> $psfile
sed -n '26,27p' test.txt | psxy -R$area -JM -Ggray -W1 -O -K >> $psfile
sed -n '29,30p' test.txt | psxy -R$area -JM -Ggray -W1 -O -K >> $psfile
sed -n '32,33p' test.txt | psxy -R$area -JM -Ggray -W1 -O -K >> $psfile
sed -n '35,36p' test.txt | psxy -R$area -JM -Ggray -W1 -O -K >> $psfile
sed -n '38,39p' test.txt | psxy -R$area -JM -Ggray -W1 -O -K >> $psfile
sed -n '41,42p' test.txt | psxy -R$area -JM -Ggray -W1 -O -K >> $psfile
sed -n '44,45p' test.txt | psxy -R$area -JM -Ggray -W1 -O -K >> $psfile
sed -n '47,48p' test.txt | psxy -R$area -JM -Ggray -W1 -O -K >> $psfile
sed -n '50,51p' test.txt | psxy -R$area -JM -Ggray -W1 -O -K >> $psfile
sed -n '53,54p' test.txt | psxy -R$area -JM -Ggray -W1 -O -K >> $psfile
sed -n '56,57p' test.txt | psxy -R$area -JM -Ggray -W1 -O -K >> $psfile
sed -n '59,60p' test.txt | psxy -R$area -JM -Ggray -W1 -O -K >> $psfile
sed -n '62,63p' test.txt | psxy -R$area -JM -Ggray -W1 -O -K >> $psfile
sed -n '65,66p' test.txt | psxy -R$area -JM -Ggray -W1 -O -K >> $psfile
sed -n '68,69p' test.txt | psxy -R$area -JM -Ggray -W1 -O -K >> $psfile
sed -n '71,72p' test.txt | psxy -R$area -JM -Ggray -W1 -O -K >> $psfile
sed -n '74,75p' test.txt | psxy -R$area -JM -Ggray -W1 -O -K >> $psfile
sed -n '77,78p' test.txt | psxy -R$area -JM -Ggray -W1 -O -K >> $psfile
sed -n '80,81p' test.txt | psxy -R$area -JM -Ggray -W1 -O -K >> $psfile
sed -n '83,84p' test.txt | psxy -R$area -JM -Ggray -W1 -O -K >> $psfile
sed -n '86,87p' test.txt | psxy -R$area -JM -Ggray -W1 -O -K >> $psfile
sed -n '89,90p' test.txt | psxy -R$area -JM -Ggray -W1 -O -K >> $psfile

psmeca focaltop_cmt.gmt -R$area -JM -Sm0.25c/-1 -Gred -W1 -O -K >> $psfile
pstext cibi.txt -R$area -JM -Gblack -O -K >> $psfile

psscale -C$cptfile -Iintens.grd -D0.4c/1/2/0.15 -B2000 -P -O -X20c -Y5c >> $psfile

Cut command linux

cut

cut options [files]
Cut out selected columns or fields from one or more files.





In the following options, list is a sequence of integers. Use a comma between separate values, and a hyphen to specify a range (e.g., 1-10,15,20 or 50-). See also paste and join.

Options

-b list, --bytes list
Specify list of positions; only bytes in these positions will be printed.
-c list, --characters list
Cut the column positions identified in list. Column numbers start with 1.
-d c, --delimiter c
Use with -f to specify field delimiter as character c (default is tab); special characters (e.g., a space) must be quoted.
-f list, --fields list
Cut the fields identified in list.
-n
Don't split multibyte characters.
-s, --only-delimited
Use with -f to suppress lines without delimiters.
--output-delimiter=string
Use string as the output delimiter. By default, the output delimiter is the same as the input delimiter.
--help
Print help message and exit.
--version
Print version information and exit.

Examples

Extract usernames and real names from /etc/passwd:
cut -d: -f1,5 /etc/passwd
Find out who is logged on, but list only login names:
who | cut -d" " -f1
Cut characters in the fourth column of file, and paste them back as the first column in the same file:
cut -c4 file | paste - file

  1. cut -c1-3 text.txt
    Output:
    Thi
    Cut the first three letters from the above line.
  2. cut -d, -f1,2 text.txt
    Output:
    This is, an example program
    The above command is used to split the fields using delimiter and cut the first two fields.

Sed command linux

sed
(=stream editor) I use sed to filter text files. The pattern to match is typically included between a pair of slashes // and quoted.
For example, to print lines containing the string "1024", I may use:
cat filename | sed -n '/1024/p'
Here, sed filters the output from the cat command. The option "-n" tells sed to block all the incoming lines but those explicitly matching my expression.  The sed action on a match is "p"= print.
Another example, this time for deleting selected lines:

cat filename | sed '/.*o$/d' > new_file

In this example, lines ending the an "o" will be deleted. I used a regular expression for matching any string followed by an "o" and the end of the line. The output (i.e., all lines but those ending with "d") is directed to new_file.
Another example. To search and replace, I use the sed 's' action, which comes in front of two expressions:

cat filename | sed 's/string_old/string_new/' > newfile

A shorter form for the last command is:
sed 's/string_old/string_new/' filename > newfile
To insert a text from a text file into an html file, I may use a script containing:
sed '/text_which_is_a_placeholder_in__my_html_file/r text_file_to_insert.txt' index_master_file.html > index.htmll

sed G myfile.txt > newfile.txt
In the above example using the sed command with G would double space the file myfile.txt and output the results to the newfile.txt.
sed = myfile.txt | sed 'N;s/\n/\. /'
The above example will use the sed command to output each of the lines in myfile.txt with the line number followed by a period and a space before each line. As done with the first example the output could be redirected to another file using > and the file name.
sed 's/test/example/g' myfile.txt > newfile.txt
Opens the file myfile.txt and searches for the word "test" and replaces every occurrence with the word "example".
sed -n '$=' myfile.txt
Above this command count the number of lines in the myfile.txt and output the results.


Rabu, 01 Desember 2010

Cross section Sumbagsel

#!/bin/csh
gmtset ANNOT_FONT_SIZE_PRIMARY 10p HEADER_FONT_SIZE 18p PLOT_DEGREE_FORMAT ddd:mm:ssF
set cptfile = color.cpt
set psfile = south_sumatra.ps
set size = M11c
set region = 97/103/-4/3
makecpt -Cglobe -Z > $cptfile
set AZ = 45

#Padang_30/9/2010
set Alon = 98.0
set Alat = -2.5
set Adep = 0
echo $Alon $Alat $Adep >! A.d

set lon_X      = 99.67
set lat_X      = -0.79
set dep_X      = 77.8
set lon_Xplus4    = 101.67
set lat_Xplus0    = -0.79
set lat_Xmin1    = -1.29
echo $lon_X $lat_X $dep_X >! mainshock_X.d

#Draw bathymetry and basemap
grdgradient indo.nc -A30/270 -Gintens.grd -Nt0.30 -V
grdimage indo.nc -R$region -J$size  -C$cptfile -Iintens.grd -K -P -Ba1g0.5NWse -X2 -Y10 > $psfile
pscoast -R$region -J$size -P -C$cptfile -Dl -W1 -O -K  -Lf108/-6/25/200 >> $psfile

#Draw cross centre
awk -F, '{ print $1, $2}' A.d | psxy -J$size -R$region -Sx.5/.5 -W2::0 -P -O -K  >> $psfile

# Draw tectonical structures
awk -F, '{ print $1, $2}' trench.gmt | psxy -R$region -J$size   -Gdarkblue -St0.2 -O -K >> $psfile
awk -F, '{ print $1, $2}' transform.gmt | psxy -R$region -J$size   -Gdarkblue -St0.2 -O -K >> $psfile
awk -F, '{ print $1, $2}' ridge.gmt | psxy -R$region -J$size   -Gdarkblue -St0.2 -O -K >> $psfile

#Draw usgs data
awk -F, '{ print $1, $2}' gempa_kecil.lst | psxy -J$size -R$region -Sc0.1c -W0.1 -H -P -O -K >> $psfile
awk -F, '{ print $1, $2}' gempa_sedang.lst | psxy -J$size -R$region -Sc0.15c -W0.15 -H -P -O -K >> $psfile
awk -F, '{ print $1, $2}' gempa_besar.lst | psxy -J$size -R$region -Sc0.2c -W0.2 -H -P -O -K >> $psfile

#Projection with the center
awk -F, '{ print $1, $2, $3}' trench.gmt  | \
project -Q -C$Alon/$Alat -A$AZ -Fxyzpqrs -L-10/550 -W-50/50 >! xyzpqrs_trench
awk -F, '{ print $1, $2, $3}' transform.gmt | \
project -Q -C$Alon/$Alat -A$AZ -Fxyzpqrs -L-10/550 -W-50/50 >! xyzpqrs_transform
awk -F, '{ print $1, $2, $3}' ridge.gmt  | \
project -Q -C$Alon/$Alat -A$AZ -Fxyzpqrs -L-10/550 -W-50/50 >! xyzpqrs_ridge

awk -F, '{ print $1, $2, $3}' gempa_kecil.lst  | \
project -Q -C$Alon/$Alat -A$AZ -Fxyzpqrs -L-10/550 -W-50/50 >! xyzpqrs_kecil
awk -F, '{ print $1, $2, $3}' gempa_sedang.lst  | \
project -Q -C$Alon/$Alat -A$AZ -Fxyzpqrs -L-10/550 -W-50/50 >! xyzpqrs_sedang
awk -F, '{ print $1, $2, $3}' gempa_besar.lst  | \
project -Q -C$Alon/$Alat -A$AZ -Fxyzpqrs -L-10/550 -W-50/50 >! xyzpqrs_besar

project -Q -C$Alon/$Alat -A$AZ mainshock_X.d -Fxyzpqrs -L-10/550 -W-50/50 >! xyzpqrs_X

#Plot earthquakes projected (red dots) and mainshock (yellow star) on map
awk '{print $1, $2}' xyzpqrs_kecil | psxy -J$size -R$region -Sc0.1c -W0.1/red -P -O -K >> $psfile
awk '{print $1, $2}' xyzpqrs_sedang | psxy -J$size -R$region -Sc0.15c -W0.15/red  -P -O -K >> $psfile
awk '{print $1, $2}' xyzpqrs_besar | psxy -J$size -R$region -Sc0.2c -W0.2/red  -P -O -K >> $psfile

awk '{print $1, $2}' mainshock_X.d | psxy -J$size -R$region -Sa0.4c -Gyellow  -Wthin -P -O -K  >> $psfile

#Focalmec lines for true epicentres
psxy -R$region -J$size -P -O -K -W2 <> $psfile
$lon_X $lat_X
$lon_Xplus4 $lat_Xplus0
EOF

# Modified focalmec sphere from Global CMT
psmeca -R$region -J$size -Sm0.5c/-1 -Gred -Wthin -O -K <> $psfile
$lon_Xplus4 $lat_Xplus0 $dep_X 1.76 -0.76 -0.99 0.66 -0.99 -1.94 27 X Y 200909301016A
EOF
pstext -R$region -J$size -Gblack -Wwhite -O -K <> $psfile
$lon_Xplus4 $lat_Xmin1     9    0    1    LC    2009/09/30
EOF

#Create points of cross section line on map
psxy -J$size -R$region -W0.5 -P -O -K <> $psfile
98.0    -2.5
101.5   1.0
EOF
psxy -J$size -R$region -W0.5 -P -O -K <> $psfile
98.318     -2.818
101.813 0.677
101.177 1.313
97.682     -2.182
98.318     -2.818
EOF
pstext -J$size -R$region -Gdarkblue -P -O -K <> $psfile
98.0    -2.5  14 0 1 LT A
EOF


#DRAW CROSSEC DIAGRAM
psbasemap -JX9.5/-5 -R0/550/0/300 -B50/30NWes -P -O -K  -Y-7 >> $psfile
pstext -JX -R  -Gdarkblue -P -O -K <> $psfile
0    0   14 0 1 LT A
EOF

#Plot stars of structures, earthquakes, and mainshocks on crossec diagram
awk '{print $4, $3}' xyzpqrs_trench | \
psxy -JX -R  -Gdarkblue -Sc0.2 -P -O -K >> $psfile
awk '{print $4, $3}' xyzpqrs_transform | \
psxy -JX -R  -Gdarkblue -Sc0.2 -P -O -K >> $psfile
awk '{print $4, $3}' xyzpqrs_ridge | \
psxy -JX -R  -Gdarkblue -Sc0.2 -P -O -K >> $psfile

awk '{print $4, $3}' xyzpqrs_kecil | \
psxy -JX -R  -Sc0.1c -W0.1/red -P -O -K >> $psfile
awk '{print $4, $3}' xyzpqrs_sedang | \
psxy -JX -R  -Sc0.15c -W0.15/red -P -O -K >> $psfile
awk '{print $4, $3}' xyzpqrs_besar | \
psxy -JX -R  -Sc0.2c -W0.2/red -P -O -K >> $psfile

awk '{print $4, $3}' xyzpqrs_X | \
psxy -JX -R  -Sa0.4c -Gyellow -Wthin -P -O -K >> $psfile


psscale -C$cptfile -Iintens.grd -D0.4c/1/10/0.15 -B1000 -P -O -K -X11.5c -Y12c >> $psfile

# Create legend of magnitude size
cat << EOF >! magnitude.legend
N 3
S 0.025i c 0.025i red 0.01p 0.050i   mag 3-5
S 0.050i c 0.050i red 0.01p 0.075i   mag 5-6
S 0.075i c 0.075i red 0.01p 0.100i   mag 6-9
>
EOF

pslegend magnitude.legend -Dx0.1i/-0.2i/6.8i/1.5i/TC -Jx0.4i -R0/8/0/8 -O -X-4c -Y-5 >> $psfile

\rm -f *.d *.xy xyzpqrs_*
gs -sDEVICE=x11 $psfile

Laman