0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

【GMT】NetCDF形式の気温データを描画

Last updated at Posted at 2021-11-18

概要

GMTを使ってNetCDFファイルに格納されたデータを描画。
grdimageコマンドを使用して、グラデーション図にします。
こんなグラフが出来上がります。

image

ソースコード

bashで作成します。bashなのでターミナル直書きでも作成可能。
データはこちらの記事で作成した擬似気温データを使用しました。
今回の話から逸れますが、pscoastで海岸線、psscaleで凡例をつけてます。
ちなみにtxtやcsvファイルからNetCDFファイルを作りたい場合は、xyz2grdコマンドで作成可能です(今回説明はしませんが)。

grdimage.sh
#!/bin/bash
 
ncFile=./netcdf4.nc
psFile=./grdimage.ps
cptFile=./color.cpt
 
gmt makecpt -Crainbow -Z -D -T-5/40/1 > $cptFile
gmt grdimage $ncFile -JM15c -Ba30f10g20/a20f10g10:."Global Temperature":WSne -R0/360/-60/60 -C$cptFile -P -K  > $psFile
gmt pscoast -J -B -R -W -P -K -O >> $psFile
gmt psscale -C$cptFile -Dx16/3/6/0.5 -Ba10f5::/:"deg C": -O >> $psFile

grdimageはデータであるNetCDFファイルと描画色を示すカラーパレットファイルを事前に用意しておく必要があります。
grdimageではオプションなしでNetCDFファイル、Cオプションでカラーパレットファイルを指定します。
カラーパレットファイルはmakecptコマンドで作成可能です。
R, B, J, P, K, Oオプションあたりはいつも通りです。

その他

今回使用したソースコード及び結果をGitHubに載せています。

0
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?