~ubuntu-branches/ubuntu/wily/grass/wily

« back to all changes in this revision

Viewing changes to scripts/i.oif/i.oifcalc

Tags: 7.0.0~rc1+ds1-1~exp1
* New upstream release candidate.
* Repack upstream tarball, remove precompiled Python objects.
* Add upstream metadata.
* Update gbp.conf and Vcs-Git URL to use the experimental branch.
* Update watch file for GRASS 7.0.
* Drop build dependencies for Tcl/Tk, add build dependencies:
  python-numpy, libnetcdf-dev, netcdf-bin, libblas-dev, liblapack-dev
* Update Vcs-Browser URL to use cgit instead of gitweb.
* Update paths to use grass70.
* Add configure options: --with-netcdf, --with-blas, --with-lapack,
  remove --with-tcltk-includes.
* Update patches for GRASS 7.
* Update copyright file, changes:
  - Update copyright years
  - Group files by license
  - Remove unused license sections
* Add patches for various typos.
* Fix desktop file with patch instead of d/rules.
* Use minimal dh rules.
* Bump Standards-Version to 3.9.6, no changes.
* Use dpkg-maintscript-helper to replace directories with symlinks.
  (closes: #776349)
* Update my email to use @debian.org address.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
#!/bin/sh
2
 
# Parameters: 1, 2, 3 - number of LANDSAT band
3
 
# written by Markus Neteler 21. Jul. 1998, 5. Jan. 1999
4
 
#            neteler geog.uni-hannover.de | neteler itc.it
5
 
 
6
 
 
7
 
# submodule of i.oif
8
 
if [ $# -ne 3 ] ; then
9
 
    g.message -e "You must use i.oif instead of i.oifcalc (this is a submodule)"
10
 
    exit 1
11
 
fi
12
 
 
13
 
if [ $1 -lt 1 ] || [ $1 -gt 7 ] || [ $2 -lt 1 ] || [ $2 -gt 7 ] || [ $3 -lt 1 ] || [ $3 -gt 7 ] ; then
14
 
    g.message -e "Invalid channel combination ($1 $2 $3)"
15
 
    exit 1
16
 
fi
17
 
 
18
 
PROG=`basename $0`
19
 
 
20
 
#### check if we have awk
21
 
if [ ! -x "`which awk`" ] ; then
22
 
    g.message -e "awk required, please install awk or gawk first" 
23
 
    exit 1
24
 
fi
25
 
 
26
 
# setting environment, so that awk works properly in all languages
27
 
unset LC_ALL
28
 
LC_NUMERIC=C
29
 
export LC_NUMERIC
30
 
 
31
 
# calculate SUM of Stddeviations:
32
 
"$GISBASE"/etc/i.oif/m.cutmatrix "$temp_stddev" 1 $1 >  "$temp_sum"
33
 
"$GISBASE"/etc/i.oif/m.cutmatrix "$temp_stddev" 1 $2 >> "$temp_sum"
34
 
"$GISBASE"/etc/i.oif/m.cutmatrix "$temp_stddev" 1 $3 >> "$temp_sum"
35
 
 
36
 
cat "$temp_sum" | awk -v temp_file="$temp_calc" \
37
 
'BEGIN {sum = 0.0} 
38
 
NR == 1{}
39
 
        {sum += $1 ; N++}
40
 
END{
41
 
print sum > temp_file
42
 
}'
43
 
 
44
 
# calculate SUM of absolute(Correlation values):
45
 
"$GISBASE"/etc/i.oif/m.cutmatrix "$temp_correlation" $1 $2 >  "$temp_sum"
46
 
"$GISBASE"/etc/i.oif/m.cutmatrix "$temp_correlation" $1 $3 >> "$temp_sum"
47
 
"$GISBASE"/etc/i.oif/m.cutmatrix "$temp_correlation" $2 $3 >> "$temp_sum"
48
 
 
49
 
cat "$temp_sum" | awk -v temp_file="$temp_calc" \
50
 
'BEGIN {sum = 0.0}
51
 
NR == 1{}
52
 
        {sum += sqrt($1*$1) ; N++}  # sqrt(x^2) is my ABS-function
53
 
END{
54
 
print sum >> temp_file
55
 
}'
56
 
 
57
 
# Calculate OIF index:
58
 
#     Divide (SUM of Stddeviations) and (SUM of Correlation)
59
 
cat "$temp_calc" | awk 'BEGIN {}
60
 
{count = divisor; divisor = $1;}      # value shift - no better idea ;-)
61
 
END{
62
 
print count / divisor
63
 
}'