1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115
|
#!/bin/sh
############################################################################
#
# MODULE: g3.createwind for GRASS 5.7
# AUTHOR(S): Markus Neteler (neteler itc it)
# PURPOSE: Create DEFAULTWIND3/WIND3 based on current 2D region
# COPYRIGHT: (C) 2004 by the GRASS Development Team
#
# This program is free software under the GNU General Public
# License (>=v2). Read the file COPYING that comes with GRASS
# for details.
#
#############################################################################
#%Module
#% description: g3.createwind creates DEFAULTWIND3/WIND3 based on current 2D region
#%End
#%option
#% key: b
#% type: integer
#% description: Bottom height
#% required : no
#%end
#%option
#% key: t
#% type: integer
#% description: Top height
#% required : no
#%end
#%option
#% key: dres
#% type: integer
#% description: Depth resolution
#% required : no
#%end
if [ -z $GISBASE ] ; then
echo "You must be in GRASS GIS to run this program."
exit 1
fi
if [ "$1" != "@ARGS_PARSED@" ] ; then
exec g.parser "$0" "$@"
fi
eval `g.gisenv`
: ${GISBASE?} ${GISDBASE?} ${LOCATION_NAME?} ${MAPSET?}
LOCATION=$GISDBASE/$LOCATION_NAME/$MAPSET
BOTTOM=$GIS_OPT_b
TOP=$GIS_OPT_t
DRES=$GIS_OPT_dres
echo "Creating g3-region with following parameters:"
cat $LOCATION/WIND | awk ' /proj:/ { print "Proj: "$2 }' > $LOCATION/WIND3
cat $LOCATION/WIND | awk ' /zone:/ { print "Zone: "$2 }' >> $LOCATION/WIND3
cat $LOCATION/WIND | awk ' /north:/ { print "North: "$2 }' >> $LOCATION/WIND3
cat $LOCATION/WIND | awk ' /south:/ { print "South: "$2 }' >> $LOCATION/WIND3
cat $LOCATION/WIND | awk ' /east:/ { print "East: "$2 }' >> $LOCATION/WIND3
cat $LOCATION/WIND | awk ' /west:/ { print "West: "$2 }' >> $LOCATION/WIND3
layer_number=`echo $BOTTOM $TOP $DRES | awk '{print ($2-$1)/$3}'`
echo "Top: $TOP" >> $LOCATION/WIND3
echo "Bottom: $BOTTOM" >> $LOCATION/WIND3
echo "Top: $TOP"
echo "Bottom: $BOTTOM"
# we need this later
number_rows=`cat $LOCATION/WIND | awk ' /rows:/ { print $2 }'`
echo "nofRows: $number_rows" >> $LOCATION/WIND3
number_cols=`cat $LOCATION/WIND | awk ' /cols:/ { print $2 }'`
echo "nofCols: $number_cols" >> $LOCATION/WIND3
echo "nofDepths: $layer_number" >> $LOCATION/WIND3
echo "nofDepths: $layer_number"
cat $LOCATION/WIND | awk ' /e-w/ { print "e-w resol: "$3 }' >> $LOCATION/WIND3
cat $LOCATION/WIND | awk ' /n-s/ { print "n-s resol: "$3 }' >> $LOCATION/WIND3
echo "t-b resol: $DRES" >> $LOCATION/WIND3
echo "t-b resol: $DRES"
# check bottom_height > top_height:
if [ $BOTTOM -ge $TOP ]
then
echo "----- ERROR: bottom_height must be less than top_height."
rm -f $LOCATION/WIND3
exit
fi
number=`echo $number_rows $number_cols $layer_number | awk '{print ($1 * $2 * $3)}'`
echo "WIND3 file created."
echo "You have defined a volume of $number tiles (cubes)."
# this needs to be improved!!:
cp $LOCATION/WIND3 $LOCATION/../PERMANENT/DEFAULT_WIND3
# checking file diffs:
diff $LOCATION/WIND3 $LOCATION/../PERMANENT/DEFAULT_WIND3 > /dev/null
if [ $? -eq 1 ]
then
echo "An error occured. Please check:"
echo "$LOCATION/WIND3"
echo "$LOCATION/../PERMANENT/DEFAULT_WIND3"
exit
fi
echo ""
echo "Now run g3.region to verify the settings."
|