{"id":2746,"date":"2019-11-29T12:34:17","date_gmt":"2019-11-29T03:34:17","guid":{"rendered":"http:\/\/home.hiroshima-u.ac.jp\/~leehs\/?p=2746"},"modified":"2019-11-29T17:13:56","modified_gmt":"2019-11-29T08:13:56","slug":"tips-for-gfs-tide-modelling","status":"publish","type":"post","link":"https:\/\/home.hiroshima-u.ac.jp\/~leehs\/?p=2746","title":{"rendered":"Tips for Gfs tide modelling"},"content":{"rendered":"\n<h4 class=\"wp-block-heading\">plot_bathy.sh for checking the bathymetry input<\/h4>\n\n\n\n<div class=\"wp-block-group\"><div class=\"wp-block-group__inner-container is-layout-flow wp-block-group-is-layout-flow\">\n<div class=\"wp-block-group\"><div class=\"wp-block-group__inner-container is-layout-flow wp-block-group-is-layout-flow\">\n<pre class=\"wp-block-preformatted\">#!\/bin\/sh<\/pre>\n\n\n\n<pre class=\"wp-block-preformatted\">infn=bathymetry   # xyz file\npsfn=bathy\nregion=156.75\/210\/-65\/-23.75\/-9500\/5<\/pre>\n\n\n\n<pre class=\"wp-block-preformatted\">gmt psxyz $infn -JQ180\/15 -JZ5c -Bx5+llong -By5+llat -Bz2500+lbathymetry -B+t\"3D bathymetry\" -R$region -Sc0.025 -Ggray -p135\/70 -W -P -V &gt; $psfn.eps<\/pre>\n<\/div><\/div>\n\n\n\n<pre class=\"wp-block-preformatted\">gs $psfn.eps<\/pre>\n<\/div><\/div>\n\n\n\n<h4 class=\"wp-block-heading\">plot_tide.sh for checking the M2 tide amplitude and phase<\/h4>\n\n\n\n<div class=\"wp-block-group\"><div class=\"wp-block-group__inner-container is-layout-flow wp-block-group-is-layout-flow\">\n<pre class=\"wp-block-preformatted\">#!\/bin\/sh<\/pre>\n\n\n\n<pre class=\"wp-block-preformatted\">infn=coefficients\npsfn=amplitude\nregion=168.3\/179.6\/-45.1\/-36.5<\/pre>\n\n\n\n<pre class=\"wp-block-preformatted\">rm -f $psfn.eps<\/pre>\n\n\n\n<pre class=\"wp-block-preformatted\"># Amplitude<\/pre>\n\n\n\n<pre class=\"wp-block-preformatted\"> awk '{print $1,$2,$3}' &lt; $infn | gmt psxy -JQ174\/12 -Bx2+llong -By2+llat -BWSne+t\"M2 amplitude\" -R$region -Sc0.15 -Camp.cpt -P -V -K &gt; $psfn.eps\n gmt psscale -Camp.cpt -DjMR+w7.5c+o-2.5c\/0 -R -J -I -Bx0.25+lAmplitude -By+lm -V -O -K &gt;&gt; $psfn.eps<\/pre>\n\n\n\n<pre class=\"wp-block-preformatted\"># Phase<\/pre>\n\n\n\n<pre class=\"wp-block-preformatted\">awk '{print $1,$2,$4}' &lt; $infn | gmt psxy -JQ174\/12 -Bx2+llong -By2+llat -BWSne+t\"M2 phase\" -R$region -Sc0.15 -Cpha.cpt -V -K -Y13c -O &gt;&gt; $psfn.eps\n gmt psscale -Cpha.cpt -DjMR+w7.5c+o-2.5c\/0 -R -J -I -Bx30+lphase -By+ldeg -V -O &gt;&gt; $psfn.eps\n #\n gs $psfn.eps<\/pre>\n<\/div><\/div>\n\n\n\n<h4 class=\"wp-block-heading\">Tide GTS input files using the Nao Tide dataset<\/h4>\n\n\n\n<p>Download the Nao tide dataset and src from <\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">https:\/\/www.miz.nao.ac.jp\/staffs\/nao99\/index_En.html<\/pre>\n\n\n\n<p>Then, run the following to check the tidal amplitude and phase<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">$ gfortran -o nao2xyap nao2xyap.f<\/pre>\n\n\n\n<pre class=\"wp-block-preformatted\">$.\/nao2xyap &lt; m2.nao &gt; m2.nao.xyap<\/pre>\n\n\n\n<pre class=\"wp-block-preformatted\">$ gmt info m2.nao.xyap    # to check the xyap file and get the attribute for domain<\/pre>\n\n\n\n<p><strong>Then, run the following script, <\/strong><code>plot_tide.sh<\/code><strong>, to plot the tidal charts<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">#!\/bin\/sh<\/pre>\n\n\n\n<pre class=\"wp-block-preformatted\">infn=o1.nao.xyap\npsfn=o1tide.nao\nregion=0\/360\/-90\/90<\/pre>\n\n\n\n<pre class=\"wp-block-preformatted\">rm -f $psfn.ps\n # Amplitude (centi-metre:cm)<\/pre>\n\n\n\n<pre class=\"wp-block-preformatted\"> gmt makecpt -Ccool -T0\/100\/20 -V &gt; amp.cpt\n awk '{print $1,$2,$3}' &lt; $infn | gmt psxy -JQ180\/14 -Bx60+llong -By30+llat -BWSne+t\"NaoTide O1 amplitude\" -R$region -Sc0.015 -Camp.cpt -P -V -K &gt; $psfn.ps\n gmt psscale -Camp.cpt -DjMR+w7.0c+o-2.5c\/0+e -R -J -I -Bx20+lAmplitude -By+lcm -V -O -K &gt;&gt; $psfn.ps<\/pre>\n\n\n\n<pre class=\"wp-block-preformatted\"># Phase (degree)<\/pre>\n\n\n\n<pre class=\"wp-block-preformatted\"> gmt makecpt -Ccool -T0\/360\/30 -V > pha.cpt\n awk '{print $1,$2,$4}' &lt; $infn | gmt psxy -JQ180\/14 -Bx60+llong -By30+llat -BWSne+t\"NaoTide O1 phase\" -R$region -Sc0.015 -Cpha.cpt -V -K -Y12c -O >> $psfn.ps\n gmt psscale -Cpha.cpt -DjMR+w7.0c+o-2.5c\/0 -R -J -I -Bx30+lphase -By+ldeg -V -O >> $psfn.ps\n #\n gs $psfn.ps\n ps2epsi $psfn.ps\n convert $psfn.epsi $psfn.png<\/pre>\n\n\n\n<p>The resulting <code>$psfn.png<\/code> (m2tide.nao.png) is like below<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"507\" height=\"582\" src=\"https:\/\/home.hiroshima-u.ac.jp\/~leehs\/wp-content\/uploads\/2019\/11\/m2tide.nao_.png\" alt=\"\" class=\"wp-image-2764\" srcset=\"https:\/\/home.hiroshima-u.ac.jp\/~leehs\/wp-content\/uploads\/2019\/11\/m2tide.nao_.png 507w, https:\/\/home.hiroshima-u.ac.jp\/~leehs\/wp-content\/uploads\/2019\/11\/m2tide.nao_-261x300.png 261w\" sizes=\"auto, (max-width: 507px) 100vw, 507px\" \/><\/figure>\n\n\n\n<p><strong>Repeat the same process for S2, K1, O1, and so on.<\/strong><\/p>\n\n\n\n<h4 class=\"wp-block-heading\"><strong>Finally, make the gts files <\/strong>of each tidal constituents for GFS modelling by running <code>nao2gts.sh<\/code><\/h4>\n\n\n\n<pre class=\"wp-block-preformatted\">## tidal coefficients#<br> tide=s2<br> Agtsfn=AS2.gts<br> Bgtsfn=BS2.gts<br> infn=$tide.nao.xyap<br> gmt info $infn<\/pre>\n\n\n\n<pre class=\"wp-block-preformatted\"># input file should contain the amplitude and phase of tidal constituents as a function of space i.e. four columns:<\/pre>\n\n\n\n<pre class=\"wp-block-preformatted\"># lon (deg) lat (deg) amplitude (m) phase (degree:-180\/180)<\/pre>\n\n\n\n<pre class=\"wp-block-preformatted\"># therefore, check the units<\/pre>\n\n\n\n<pre class=\"wp-block-preformatted\">tmpfn=$infn.new<br>\nawk '{if ($4 &gt; 180.0) print $1,$2,$3\/100,$4-360; else print $1,$2,$3\/100,$4}' $infn &gt; $tmpfn<br>\ngmt info $tmpfn<\/pre>\n\n\n\n<pre class=\"wp-block-preformatted\"># just counts the number of lines in the input file<\/pre>\n\n\n\n<pre class=\"wp-block-preformatted\">lines=<code>wc -l $tmpfn | awk '{print $1}'<\/code><br>\necho \"lines = \" $lines<\/pre>\n\n\n\n<pre class=\"wp-block-preformatted\"># Gerris defines the tidal M2,S2,K1,O1 mode as:<\/pre>\n\n\n\n<pre class=\"wp-block-preformatted\"># AM2*cos(omega*t) + BM2*sin(omega*t)<\/pre>\n\n\n\n<pre class=\"wp-block-preformatted\">## We first compute AM2 from the amplitude and phase.<\/pre>\n\n\n\n<pre class=\"wp-block-preformatted\">awk -v lines=$lines '\nBEGIN {\n  print lines \" 0 0\"\n} {\n  print $1 \" \" $2 \" \" $3*cos($43.14159265357\/180.)\n}' &lt; $tmpfn | delaunay > $Agtsfn\n#<\/pre>\n\n\n\n<pre class=\"wp-block-preformatted\"># Now compute BM2<\/pre>\n\n\n\n<pre class=\"wp-block-preformatted\">awk -v lines=$lines '\nBEGIN {\n  print lines \" 0 0\"\n} {\n  print $1 \" \" $2 \" \" $3*sin($43.14159265357\/180.)\n}' &lt; $tmpfn | delaunay > $Bgtsfn<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>plot_bathy.sh for checking the bathymetry input #!\/bin\/sh infn=bathymetry # xyz file psfn=bathy region=156.75\/210\/-65\/-23.75\/-9500\/5 gmt psxyz $infn -JQ180\/15 -JZ5c -Bx5+llong -By5+llat -Bz2500+lbathymetry -B+t&#8221;3D bathymetry&#8221; -R$region -Sc0.025 -Ggray -p135\/70 -W -P -V &gt; $psfn.eps gs $psfn.eps plot_tide.sh for checking the M2 tide&#8230;<br \/><a class=\"read-more-button\" href=\"https:\/\/home.hiroshima-u.ac.jp\/~leehs\/?p=2746\">Read more<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[12],"tags":[],"class_list":["post-2746","post","type-post","status-publish","format-standard","hentry","category-tool"],"rttpg_featured_image_url":null,"rttpg_author":{"display_name":"hslee","author_link":"https:\/\/home.hiroshima-u.ac.jp\/~leehs\/?author=1"},"rttpg_comment":0,"rttpg_category":"<a href=\"https:\/\/home.hiroshima-u.ac.jp\/~leehs\/?cat=12\" rel=\"category\">Tool<\/a>","rttpg_excerpt":"plot_bathy.sh for checking the bathymetry input #!\/bin\/sh infn=bathymetry # xyz file psfn=bathy region=156.75\/210\/-65\/-23.75\/-9500\/5 gmt psxyz $infn -JQ180\/15 -JZ5c -Bx5+llong -By5+llat -Bz2500+lbathymetry -B+t\"3D bathymetry\" -R$region -Sc0.025 -Ggray -p135\/70 -W -P -V &gt; $psfn.eps gs $psfn.eps plot_tide.sh for checking the M2 tide...Read more","_links":{"self":[{"href":"https:\/\/home.hiroshima-u.ac.jp\/~leehs\/index.php?rest_route=\/wp\/v2\/posts\/2746","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/home.hiroshima-u.ac.jp\/~leehs\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/home.hiroshima-u.ac.jp\/~leehs\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/home.hiroshima-u.ac.jp\/~leehs\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/home.hiroshima-u.ac.jp\/~leehs\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=2746"}],"version-history":[{"count":16,"href":"https:\/\/home.hiroshima-u.ac.jp\/~leehs\/index.php?rest_route=\/wp\/v2\/posts\/2746\/revisions"}],"predecessor-version":[{"id":2769,"href":"https:\/\/home.hiroshima-u.ac.jp\/~leehs\/index.php?rest_route=\/wp\/v2\/posts\/2746\/revisions\/2769"}],"wp:attachment":[{"href":"https:\/\/home.hiroshima-u.ac.jp\/~leehs\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=2746"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/home.hiroshima-u.ac.jp\/~leehs\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=2746"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/home.hiroshima-u.ac.jp\/~leehs\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=2746"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}