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

« back to all changes in this revision

Viewing changes to temporal/t.rast3d.algebra/t.rast3d.algebra.py

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
#!/usr/bin/env python
 
2
# -*- coding: utf-8 -*-
 
3
############################################################################
 
4
#
 
5
# MODULE:       t.rast3d.algebra
 
6
# AUTHOR(S):    Thomas Leppelt, Soeren Gebbert
 
7
#
 
8
# PURPOSE:      Provide temporal 3D raster algebra to perform spatial an temporal operations
 
9
#               for space time datasets by topological relationships to other space time
 
10
#               datasets.
 
11
# COPYRIGHT:    (C) 2014 by the GRASS Development Team
 
12
#
 
13
#               This program is free software under the GNU General Public
 
14
#               License (version 2). Read the file COPYING that comes with GRASS
 
15
#               for details.
 
16
#
 
17
#############################################################################
 
18
 
 
19
#%module
 
20
#% description: Apply temporal and spatial operations on space time 3D raster datasets using temporal 3D raster algebra.
 
21
#% keyword: temporal
 
22
#% keyword: algebra
 
23
#% keyword: raster3d
 
24
#% keyword: voxel
 
25
#%end
 
26
 
 
27
#%option
 
28
#% key: expression
 
29
#% type: string
 
30
#% description: Algebraic expression for temporal and spatial analysis of space time 3D raster datasets
 
31
#% required : yes
 
32
#%end
 
33
 
 
34
#%option
 
35
#% key: basename
 
36
#% type: string
 
37
#% label: Basename of the new generated output maps
 
38
#% description: A numerical suffix separated by an underscore will be attached to create a unique identifier
 
39
#% required: yes
 
40
#%end
 
41
 
 
42
#%option
 
43
#% key: nprocs
 
44
#% type: integer
 
45
#% description: Number of r3.mapcalc processes to run in parallel
 
46
#% required: no
 
47
#% multiple: no
 
48
#% answer: 1
 
49
#%end
 
50
 
 
51
#%flag
 
52
#% key: s
 
53
#% description: Activate spatial topology
 
54
#%end
 
55
 
 
56
#%flag
 
57
#% key: n
 
58
#% description: Register Null maps
 
59
#%end
 
60
 
 
61
#%flag
 
62
#% key: g
 
63
#% description: Use granularity sampling instead of the temporal topology approach
 
64
#%end
 
65
 
 
66
 
 
67
import grass.script
 
68
import grass.temporal as tgis
 
69
import sys
 
70
 
 
71
def main():
 
72
    expression = options['expression']
 
73
    basename = options['basename']
 
74
    nprocs = options["nprocs"]
 
75
    spatial = flags["s"]
 
76
    register_null = flags["n"]
 
77
    granularity = flags["g"]
 
78
 
 
79
    # Check for PLY istallation
 
80
    try:
 
81
        import ply.lex as lex
 
82
        import ply.yacc as yacc
 
83
    except:
 
84
        grass.script.fatal(_("Please install PLY (Lex and Yacc Python implementation) to use the temporal algebra modules. "
 
85
                             "You can use t.rast3d.mapcalc that provides a limited but useful alternative to "
 
86
                             "t.rast3d.mapcalc2 without PLY requirement."))
 
87
 
 
88
    tgis.init(True)
 
89
    p = tgis.TemporalRaster3DAlgebraParser(run = True, debug=False, spatial = spatial, nprocs = nprocs, register_null = register_null)
 
90
    
 
91
    if granularity:
 
92
        if not p.setup_common_granularity(expression=expression,  stdstype = 'str3ds',  lexer = tgis.TemporalRasterAlgebraLexer()):
 
93
            grass.script.fatal(_("Unable to process the expression in granularity algebra mode"))
 
94
            
 
95
    p.parse(expression, basename, grass.script.overwrite())
 
96
 
 
97
if __name__ == "__main__":
 
98
    options, flags = grass.script.parser()
 
99
    sys.exit(main())
 
100