[SCM] Gerris Flow Solver branch, upstream, updated. b3aa46814a06c9cb2912790b23916ffb44f1f203
Stephane Popinet
popinet at users.sourceforge.net
Fri May 15 02:51:17 UTC 2009
The following commit has been merged in the upstream branch:
commit 3ad48374a5f275e58a919a664ce31eb661391e6e
Author: Stephane Popinet <popinet at users.sourceforge.net>
Date: Wed Oct 27 09:22:55 2004 +1000
Added bat2gts script (gerris--mainline--0.7--patch-6)
gerris--mainline--0.7--patch-6
Keywords:
For generating ocean bathymetry files.
darcs-hash:20041026232255-aabb8-2f73e2fe2131beadad0a7a60481968008915ab3d.gz
diff --git a/tools/bat2gts b/tools/bat2gts
new file mode 100755
index 0000000..5a9b5d7
--- /dev/null
+++ b/tools/bat2gts
@@ -0,0 +1,152 @@
+#!/bin/sh
+
+# reference longitude (degrees)
+rlong=174
+# reference latitude (degrees)
+rlat=-41
+# width of the domain (kilometers)
+width=500
+# coastline reference depth (m)
+coast=0.1
+# verbose output
+verbose=""
+# angle of rotation
+angle=0
+# relative error
+relative=0.05
+# reference depth
+H=5000
+
+usage()
+{
+ cat <<EOF
+Usage: bat2gts [OPTIONS] < BATHY
+
+Takes a bathymetry file (three columns: longitude, latitude (degree),
+depth (meters)) and generates a GTS depth file for the given
+domain.
+
+Options:
+ [--long=V] set reference longitude to V (default 174 deg)
+ [--lat=V] set reference latitude to V (default -41 deg)
+ [--width=V] set domain width (default is 500 km)
+ [--depth=V] set reference depth to V
+ (default is 5000 meters)
+ [--coast=V] set coastline reference depth to V
+ (default is 0.1 meters)
+ [--rel=T] set relative error allowed on bathymetry (default is 0.05)
+ [--angle=V] rotation of V degrees (default is 0)
+ [--verbose] display info about the process
+ [--help] display this message and exits
+EOF
+ exit $1
+}
+
+if test $# -lt 1; then
+ usage 1 1>&2
+fi
+
+command="bat2gts $*"
+
+while test $# -gt 0; do
+ case "$1" in
+ -*=*) optarg=`echo "$1" | sed 's/[-_a-zA-Z0-9]*=//'` ;;
+ *) optarg= ;;
+ esac
+
+ case $1 in
+ --long=*)
+ rlong=$optarg
+ ;;
+ --lat=*)
+ rlat=$optarg
+ ;;
+ --width=*)
+ width=$optarg
+ ;;
+ --depth=*)
+ H=$optarg
+ ;;
+ --coast=*)
+ coast=$optarg
+ ;;
+ --angle=*)
+ angle=$optarg;
+ ;;
+ --rel=*)
+ relative=$optarg
+ ;;
+ --verbose)
+ verbose="-v"
+ ;;
+ --help)
+ usage 0 1>&2
+ ;;
+ *)
+ usage 0 1>&2
+ ;;
+ esac
+ shift
+done
+
+proj=-Ja$rlong/$rlat/1:`echo $width | awk '{print $1*1e5}'`c
+area=-R`echo $rlong $rlat $width | awk '{
+ Pi = 3.14159265359
+ dlon = 0.71*$3/(6378.*cos ($2*Pi/180))*180./Pi
+ dlat = 0.71*$3/6378.*180./Pi
+ print $1 - dlon "/" $1 + dlon "/" $2 - dlat "/" $2 + dlat
+}'`
+
+cat <<EOF
+# Created by bat2gts
+# wdir: $PWD
+# command line: $command
+# reference depth: $H m
+EOF
+mapproject -C $proj $area |\
+ awk -v H=$H -v coast=$coast '{
+ if ($1 < 0.71 && $1 > -0.71 && $2 < 0.71 && $2 > -0.71)
+ print $1 " " $2 " " (coast - $3)/H;
+ }
+' | sort | uniq | happrox -f $verbose -C -r `awk -v H=$H 'BEGIN{print 1./H}'` -c $relative |\
+transform --rz $angle | transform --tz 0.5
+
+cat <<EOF > lolat2xy
+mapproject -C $proj $area | awk '
+BEGIN {
+ angle = $angle * 3.14159265359/180.;
+ cosa = cos (angle);
+ sina = sin (angle);
+}
+{
+ if (NF >= 2) {
+ printf ("%f %f", cosa*\$1 - sina*\$2, sina*\$1 + cosa*\$2);
+ for (i = 3; i <= NF; i++)
+ printf (" %s", \$i);
+ printf ("\n");
+ }
+ else
+ print \$0;
+}'
+EOF
+chmod +x lolat2xy
+
+cat <<EOF > xy2lolat
+awk '
+BEGIN {
+ angle = - $angle * 3.14159265359/180.;
+ cosa = cos (angle);
+ sina = sin (angle);
+}
+{
+ if (NF >= 2) {
+ printf ("%f %f", cosa*\$1 - sina*\$2, sina*\$1 + cosa*\$2);
+ for (i = 3; i <= NF; i++)
+ printf (" %s", \$i);
+ printf ("\n");
+ }
+ else
+ print \$0;
+}' | mapproject -I -C $proj $area
+EOF
+chmod +x xy2lolat
--
Gerris Flow Solver
More information about the debian-science-commits
mailing list