East China Sea

East China Sea.

#! /bin/bash

# @purpose : This script make bathymetry map with ship track
# @author : UGeun Jang
# @date : 2011-05-03
# @mailto : worker@kordi.re.kr
# This shellscript created by following command line:
# mbm_grdplot -G1 -PA2 -O tmp -I tmp-9870.g98

# http://127.0.0.1/~worker/gmt/man/psbasemap.html
map_projection=”m”
map_scale=”0.94517″
x_offset=”2.1264i”
y_offset=”5.3935i”
map_region=”118/131/28/40″
scale_position=”6.1436/-0.6632/12.2873/0.1600h”
grid_interval=”120m/120m”
title=”East China Sea”

target=”ecs”
ps_file=${target}”.ps”
cpt_file=${target}”.cpt”
echo “target: ${target}”
echo “target ps: ${ps_file}”
echo “target cpt: ${cpt_file}”
echo ” ”
echo ” ”
echo ” ”

bathy=”tmp”
grid_home=”.”
grd_file=${grid_home}”/”${bathy}”.grd”
grd_info=${grid_home}”/”${bathy}”.txt”
int_file=${grid_home}$”/”${bathy}”.int”
echo “bathy file: ${grd_file}”
echo “bathy info: ${grd_info}”
echo “bathy int: ${int_file}”
echo ” ”
echo ” ”
echo ” ”
if [ ! -f ${grd_info} ]; then
echo “grdinfo -C ${grd_file} > ${grd_info}”
grdinfo -C ${grd_file} > ${grd_info}
more ${grd_info}
echo ” ”
echo ” ”
echo ” ”
fi

if [ -f ${cpt_file} ]; then
echo “more ${cpt_file}”
more ${cpt_file}
echo ” ”
echo ” ”
echo ” ”
fi

grdhisteq ${grd_file} -D -C16 | \
awk ‘BEGIN {n=256}{print $1,n,n,n,$2,n-16,n-16,n-16}{n-=16}’ | \
sed s/’256 256 256’/’255 255 255’/g > ${cpt_file}

# Set new GMT defaults
echo “Setting new GMT defaults…”
rm .gmtcommands4
rm .gmtdefaults4
echo ” ”
echo ” ”
echo ” ”

gmtset MEASURE_UNIT inch
gmtset PAPER_MEDIA A2+

gmtset ANOT_FONT Helvetica
gmtset ANOT_FONT_SIZE 14

gmtset LABEL_FONT Helvetica
gmtset LABEL_FONT_SIZE 14

gmtset HEADER_FONT Helvetica-Bold
gmtset HEADER_FONT_SIZE 18

gmtset FRAME_WIDTH 0.075
gmtset TICK_LENGTH 0.075

gmtset PAGE_ORIENTATION PORTRAIT
gmtset COLOR_BACKGROUND 0/0/0
gmtset COLOR_FOREGROUND 255/255/255
gmtset COLOR_NAN 255/255/255

gmtset PLOT_DEGREE_FORMAT ddd:mm:ssF

# plot positioning and layout: The -X -Y options
# @see : http://localhost/~worker/gmt/gmt_docs/node49.html
gmtset X_ORIGIN 0
gmtset Y_ORIGIN 0

# make color image
# @see : http://127.0.0.1/~worker/gmt/man/grdimage.html
# grdimage : create grayshaded or colored image from a 2-D netCDF grid file.
# -C : Name of the color palette table.
# -I : Gives the name of a grid file with intensities in the (-1,+1) range.
# Default is no illumination.
# -O : Selects Overlay plot mode.
# -K : More PostScript code will be appended later.
# Default terminates the plot system.
# -Q : Make grid nodes with z = NaN transparent.
# -V : Selects verbose mode.
#
# Shading
grdimage ${grd_file} -C${cpt_file} -I${int_file}\
-J${map_projection}${map_scale} -R${map_region} \
-E300 -K -Q -V -X${x_offset} -Y${y_offset} > ${ps_file}

grdcontour ${grd_file} \
-J${map_projection}${map_scale} -R${map_region} \
-C100 -A500+f0+s9 -S5 -Wcthinnest,black -Wathin,black \
-K -O -V >> ${ps_file}

pscoast -R${map_region} -J${map_projection}${map_scale} -Df -I1 -I2 -I3 -V -O -K >> ${ps_file}

# gmtset ANOT_FONT_SIZE 10
# gmtset LABEL_FONT Helvetica-Bold
# psscale -C${cpt_file}\
# -D${scale_position} \
# -B”:depth (m):” \
# -K -O -V >> ${ps_file}
# gmtset ANOT_FONT_SIZE 10
# gmtset LABEL_FONT Helvetica

# Make basemap
#
# @see : http://127.0.0.1/~worker/gmt/man/psbasemap.html
# psbasemap –
echo “Running psbasemap…”
echo ” ”
# gmtset GRID_CROSS_SIZE_PRIMARY 0.05
psbasemap -J${map_projection}${map_scale} -R${map_region} \
-B${grid_interval} \
-O >> ${ps_file}

# Run ghostview
#
# http://127.0.0.1/~worker/gmt/man/ps2raster.html
# -A : Adjust the BoundingBox and HiResBoundingBox to the minimum required by the image content.
# -P : Force Portrait mode.
# -Tf : Sets the output format pdf.
# -Tj : Sets the output format jpeg.
# -W+k : create a minimalist KML file
# -W+g : create a geotiff image .tiff
echo “ps2raster – converts postscript files to pdf formats …”
echo “ps2raster ${ps_file} -P -Tf”
ps2raster ${ps_file} -Tf -A
ps2raster ${ps_file} -Tj -A
open ${ps_file}”.pdf”
echo ” ”
echo ” ”
echo ” ”

chmod 600 *.ps
chmod 600 *.pdf
chmod 600 *.jpg
chmod 600 *.cpt
chmod 600 *.txt
chmod 700 *.sh

# All done!
echo “All done!”
echo ” ”
echo ” ”
echo ” ”
exit 0;

3 comments

  1. Minkyug Son · · Reply

    오빠 이거 그리드 파일은 어디서 가져오신건가요?!?

    1. Minkyug Son · · Reply

      동해랑 동해 남쪽 부분의 그리드 화일이 필요해서요ㅜ.. 어디서 구하시는거에요!?
      지금 있는거로는 울릉분지? 그쪽이 잘 안보여서요.. 음영으로 표시되는데..
      하지만.. 제가 아직 잘 몰라서 지금 갖고 있는 그리드 파일 정보를 다 활용 못하는 걸수도 있음..-_;;;;;;;;;;

      1. 메일 보냈음. 음영으로 표시되면 scale 문제일수 있음. min, max 값 확인해보삼.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: