物探论坛

 找回密码
 立即注册

QQ登录

只需一步,快速开始

查看: 2045|回复: 7

[GMT] Converting a xyz file into a grd file and plot it using grdimage

[复制链接]
匿名
匿名  发表于 2013-4-20 16:02:35 |阅读模式
#!/bin/csh
/bin/rm tmp.ps tmp.cpt
## Make a basemap of western United States:
psbasemap -R-126.000/-100.000/30.500/50.000 \
-JM5 -Ba5f1 -P -X2.0 -Y2 -K >tmp.ps
## Convert the xyz file into GRD file using xyz2grd
awk '{print $1, $2, $4}' data.dat | xyz2grd -R -I0.5 -Gtmp.grd
## Make a color table
makecpt -Crainbow -T410/450/20 -Z >tmp.cpt
## Produce the image
grdimage tmp.grd -Ctmp.cpt -R -J -O -K >>tmp.ps
## Plot the scale bar at the bottom of the plot
psscale -D2.5/-0.4/5.0/0.1h -B10 -Ctmp.cpt -O -K >>tmp.ps
## Overlay with coastlines and political boudnaries
pscoast -R -J -W3 -Df -Na/1/0t10:5_0 -A1000 -O -K -B  >>tmp.ps
## Add a title
pstext -R -J -O -N  <<END>>tmp.ps
-113 51 15 0 0 6 Depth of the 410 km discontinuity: Preliminary results
END
## Convert tmp.ps into a JPG file:
ps2jpeg100 tmp.ps
data.rar (10.54 KB, 下载次数: 0)
回复

使用道具 举报

匿名
匿名  发表于 2013-4-20 16:04:07
#!/bin/csh
/bin/rm tmp.ps tmp.cpt
## Make a basemap of western United States:
psbasemap -R-126.000/-100.000/30.500/50.000 \
-JM5 -Ba5f1 -P -X2.0 -Y2 -K >tmp.ps
## Convert the xyz file into GRD file using xyz2grd
awk '{print $1, $2, $4}' data.dat | xyz2grd -R -I0.5 -Gtmp.grd
## Resample tmp.grd from coarse (0.5 deg.) into finer resolution (0.1 degree) using grdsample.
#  The output file is tmph.grd.
grdsample tmp.grd -Gtmph.grd -I0.1 -Ql/0.1 -Lx
## Make a color table
makecpt -Crainbow -T410/450/20 -Z >tmp.cpt
## Produce the image using the resampled grd file
grdimage tmph.grd -Ctmp.cpt -R -J -O -K >>tmp.ps
## Plot the scale bar at the bottom of the plot
psscale -D2.5/-0.4/5.0/0.1h -B10 -Ctmp.cpt -O -K >>tmp.ps
## Overlay with coastlines and political boudnaries
pscoast -R -J -W3 -Df -Na/1/0t10:5_0 -A1000 -O -K -B  >>tmp.ps

## Add a title
pstext -R -J -O -N  <<END>>tmp.ps
-113 51 15 0 0 6 Depth of the 410 km discontinuity: Preliminary results
END
## Convert tmp.ps into a JPG file:
ps2jpeg100 tmp.ps
1.jpg
回复 支持 反对

使用道具 举报

匿名
匿名  发表于 2013-4-20 16:05:27
#!/bin/csh
/bin/rm tmp.ps tmp.cpt
## Make a basemap of western United States:
psbasemap -R-126.000/-100.000/30.500/50.000 \
-JM5 -Ba5f1 -P -X2.0 -Y2 -K >tmp.ps
## Convert the xyz file into GRD file using xyz2grd
awk '{print $1, $2, $4}' data.dat | xyz2grd -R -I0.5 -Gtmp.grd
## Resample tmp.grd from coarse (0.5 deg.) into finer resolution (0.1 degree) using grdsample.
#  The output file is tmph.grd.
grdsample tmp.grd -Gtmph.grd -I0.1 -Ql/0.1 -Lx
## Filter tmph.grd using a Gaussian filter of 4 degree wide
## This is used to get rid of short wavelength features
#  The output file is tmpf.grd.
grdfilter tmph.grd -D0 -Fg4 -Gtmpf.grd
## Make a color table
makecpt -Crainbow -T410/450/20 -Z >tmp.cpt
## Produce the image using the resampled grd file
grdimage tmpf.grd -Ctmp.cpt -R -J -O -K >>tmp.ps
## Plot the scale bar at the bottom of the plot
psscale -D2.5/-0.4/5.0/0.1h -B10 -Ctmp.cpt -O -K >>tmp.ps
## Overlay with coastlines and political boudnaries
pscoast -R -J -W3 -Df -Na/1/0t10:5_0 -A1000 -O -K -B  >>tmp.ps
## Add a title
pstext -R -J -O -N  <<END>>tmp.ps
-113 51 15 0 0 6 Depth of the 410 km discontinuity: Preliminary results
END
## Convert tmp.ps into a JPG file:
ps2jpeg100 tmp.ps
1.jpg
回复 支持 反对

使用道具 举报

匿名
匿名  发表于 2013-4-20 16:07:12
#!/bin/csh
/bin/rm tmp.ps tmp.cpt
## Make a basemap of western United States:
psbasemap -R-126.000/-100.000/30.500/50.000 \
-JM5 -Ba5f1 -P -X2.0 -Y2 -K >tmp.ps
## Convert the xyz file into GRD file using xyz2grd
awk '{print $1, $2, $4}' data.dat | xyz2grd -R -I0.5 -Gtmp.grd
## Resample tmp.grd from coarse (0.5 deg.) into finer resolution (0.1 degree) using grdsample.
#  The output file is tmph.grd.
grdsample tmp.grd -Gtmph.grd -I0.1 -Ql/0.1 -Lx
## Make a color table
makecpt -Crainbow -T410/450/20 -Z >tmp.cpt
## Make a gradient file to be used as "shade" of the image
# The output intensity file is tmph.int. The "light" comes from 45 degree (Northeast)
# "N" is for normalization (otherwise the gradients will be too large)
grdgradient tmph.grd -Gtmph.int -A45 -N
## Produce the image using the resampled grd file and tmp.int
grdimage tmph.grd -Itmph.int -Ctmp.cpt -R -J -O -K >>tmp.ps

## Plot the scale bar at the bottom of the plot
psscale -D2.5/-0.4/5.0/0.1h -B10 -Ctmp.cpt -O -K >>tmp.ps

## Overlay with coastlines and political boudnaries
pscoast -R -J -W3 -Df -Na/1/0t10:5_0 -A1000 -O -K -B  >>tmp.ps

## Add a title
pstext -R -J -O -N  <<END>>tmp.ps
-113 51 15 0 0 6 Depth of the 410 km discontinuity: Preliminary results
END
## Convert tmp.ps into a JPG file:
ps2jpeg100 tmp.ps
1.jpg
回复 支持 反对

使用道具 举报

匿名
匿名  发表于 2013-4-20 16:09:22
#!/bin/csh
/bin/rm tmp.ps tmp.cpt
## Make a basemap of western United States:
psbasemap -R-126.000/-100.000/30.500/50.000 \
-JM5 -Ba5f1 -P -X2.0 -Y2 -K >tmp.ps
## Convert the xyz file into GRD file using xyz2grd
awk '{print $1, $2, $4}' data.dat | xyz2grd -R -I0.5 -Gtmp.grd
## Resample tmp.grd from coarse (0.5 deg.) into finer resolution (0.1 degree) using grdsample.
#  The output file is tmph.grd.
grdsample tmp.grd -Gtmph.grd -I0.1 -Ql/0.1 -Lx
## Make a color table
makecpt -Crainbow -T410/450/20 -Z >tmp.cpt
## Make a gradient file out of elevation data to be used as "shade" of the image
# The output intensity file is tmph.int. The "light" comes from 45 degree (Northeast)
# "N" is for normalization (otherwise the gradients will be too large)
# Cut out the portion of elevation data from a global database
# The output is topo0.grd
grdcut /home/sgao/Dbase/topo1min/data.grd -Gtopo0.grd -R
## Resample it into the same interval as tmph.grd
grdsample topo0.grd -Gtopoh.grd -I0.1 -Ql/0.1 -Lx
## Produce the gradient file. This time I usd -Nt to make a more dramatic shade
grdgradient topoh.grd -Gtopoh.int -A45 -Nt
## Produce the image using the resampled grd file and tmp.int
grdimage tmph.grd -Itopoh.int -Ctmp.cpt -R -J -O -K >>tmp.ps
## Plot the scale bar at the bottom of the plot
psscale -D2.5/-0.4/5.0/0.1h -B10 -Ctmp.cpt -O -K >>tmp.ps
## Overlay with coastlines and political boudnaries
pscoast -R -J -W3 -Df -Na/1/0t10:5_0 -A1000 -O -K -B  >>tmp.ps
## Add a title
pstext -R -J -O -N  <<END>>tmp.ps
-113 51 15 0 0 6 Depth of the 410 km discontinuity: Preliminary results
END
## Convert tmp.ps into a JPG file:
ps2jpeg100 tmp.ps
1.jpg
回复 支持 反对

使用道具 举报

匿名
匿名  发表于 2013-4-20 16:13:27
#!/bin/csh
/bin/rm tmp.ps tmp.cpt
## Convert the xyz file into GRD file using xyz2grd
awk '{print $1, $2, $4}' data.dat | xyz2grd -R -I0.5 -Gtmp.grd
## Resample tmp.grd from coarse (0.5 deg.) into finer resolution (0.1 degree) using grdsample.
#  The output file is tmph.grd.
grdsample tmp.grd -Gtmph.grd -I0.1 -Ql/0.1 -Lx
## Get the coordinates of points of 0.1 degree apart along the great circle arc from two points:
sample1d -I0.1 <<END>! profile.xy
-120.0 35.0
-105.0 45.0
END
## Get the data value at the points using grdtrack
grdtrack profile.xy -Gtmph.grd >! profile.xyz
## Plot the data against logitude (first column)
awk '{print $1, $3}' profile.xyz | \
psxy -R-125/-100/410/440 -JX5/2 -K -X2.0 -Y7.5 -P \
-Ba5f1/a10f1 -W4/255/0/0 >tmp.ps
## For the bottom plot, make a basemap of western United States:
# It shifts by 5.8 inches downward
psbasemap -R-126.000/-100.000/30.500/50.000 \
-JM5 -Ba5f1 -P -O -Y-5.8 -K >>tmp.ps
## Make a color table
makecpt -Crainbow -T410/450/20 -Z >tmp.cpt
## Produce the image using the resampled grd file
grdimage tmph.grd -Ctmp.cpt -R -J -O -K >>tmp.ps

## Plot the scale bar at the bottom of the plot
psscale -D2.5/-0.4/5.0/0.1h -B10 -Ctmp.cpt -O -K >>tmp.ps

## Overlay with coastlines and political boudnaries
pscoast -R -J -W3 -Df -Na/1/0t10:5_0 -A1000 -O -K -B  >>tmp.ps

## Plot the profile on the map as dashed line
awk '{print $1, $2}' profile.xyz | \
psxy -R -J -W20/255/0/0t150:100_0 -O -K >>tmp.ps

## Add a title
pstext -R -J -O -N  <<END>>tmp.ps
-113 51 15 0 0 6 Depth of the 410 km discontinuity: Preliminary results
END
## Convert tmp.ps into a JPG file:
ps2jpeg100 tmp.ps
1.jpg
回复 支持 反对

使用道具 举报

匿名
匿名  发表于 2013-4-20 16:14:48
#!/bin/csh
/bin/rm tmp.ps tmp.cpt
## Make a basemap of western United States:
psbasemap -E180/45 -R-126.000/-100.000/30.500/50.000 \
-JM5 -Ba5f1 -P -X2.0 -Y2 -K >tmp.ps
## Convert the xyz file into GRD file using xyz2grd
awk '{print $1, $2, $4}' data.dat | xyz2grd -R -I0.5 -Gtmp.grd
## Resample tmp.grd from coarse (0.5 deg.) into finer resolution (0.2 degree) using grdsample.
#  The output file is tmph.grd.
grdsample tmp.grd -Gtmph.grd -I0.2 -Ql/0.1 -Lx
## Filter tmph.grd using a Gaussian filter of 4 degree wide
## This is used to get rid of short wavelength features
#  The output file is tmpf.grd.
grdfilter tmph.grd -D0 -Fg4 -Gtmpf.grd
## Make a color table
makecpt -Crainbow -T410/450/20 -Z >tmp.cpt
## Produce the image using the resampled grd file
grdview tmpf.grd -E180/45 -Ctmp.cpt -R -JM -Jz0.05 -O -K >>tmp.ps
## Plot the scale bar at the bottom of the plot
#psscale -D2.5/-0.4/5.0/0.1h -B10 -Ctmp.cpt -O -K >>tmp.ps
## Overlay with coastlines and political boudnaries
pscoast -R -J -W3 -E180/45 -Df -Na/1/0t10:5_0 -A1000 -O -K -B  >>tmp.ps
## Add a title
pstext -R -J -O -N  <<END>>tmp.ps
-113 51 15 0 0 6 Depth of the 410 km discontinuity: Preliminary results
END
## Convert tmp.ps into a JPG file:
ps2jpeg100 tmp.ps
1.jpg
回复 支持 反对

使用道具 举报

发表于 2013-4-27 19:52:40 | 显示全部楼层
好,顶一下
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

QQ|Archiver|手机版|小黑屋|物探论坛 ( 鄂ICP备12002012号 微信号:iwutan )

GMT+8, 2024-4-29 20:57 , Processed in 0.080852 second(s), 18 queries .

Powered by Discuz! X3.4

© 2001-2017 Comsenz Inc.

快速回复 返回顶部 返回列表