t.time.rel.py 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. #!/usr/bin/env python
  2. # -*- coding: utf-8 -*-
  3. ############################################################################
  4. #
  5. # MODULE: t.time.rel
  6. # AUTHOR(S): Soeren Gebbert
  7. #
  8. # PURPOSE: Set the relative valid time interval for raster maps
  9. # COPYRIGHT: (C) 2011 by the GRASS Development Team
  10. #
  11. # This program is free software under the GNU General Public
  12. # License (version 2). Read the file COPYING that comes with GRASS
  13. # for details.
  14. #
  15. #############################################################################
  16. #%module
  17. #% description: Set the relative valid time interval for maps of type raster, vector and raster3d
  18. #% keywords: time
  19. #% keywords: relative
  20. #% keywords: raster
  21. #% keywords: vector
  22. #% keywords: raster3d
  23. #%end
  24. #%option
  25. #% key: maps
  26. #% type: string
  27. #% description: Name(s) of existing raster map(s)
  28. #% required: yes
  29. #% multiple: yes
  30. #%end
  31. #%option
  32. #% key: start
  33. #% type: double
  34. #% description: The valid start time value in [days]
  35. #% required: yes
  36. #% multiple: no
  37. #%end
  38. #%option
  39. #% key: end
  40. #% type: double
  41. #% description: The valid end time value in [days]
  42. #% required: no
  43. #% multiple: no
  44. #%end
  45. #%option
  46. #% key: increment
  47. #% type: double
  48. #% description: Time increment between maps for valid time interval creation [days]
  49. #% required: no
  50. #% multiple: no
  51. #%end
  52. #%flag
  53. #% key: i
  54. #% description: Create an interval (start and end time) in case an increment is provided
  55. #%end
  56. import grass.script as grass
  57. import grass.temporal as tgis
  58. ############################################################################
  59. def main():
  60. # Get the options
  61. maps = options["maps"]
  62. start = options["start"]
  63. end = options["end"]
  64. increment = options["increment"]
  65. interval = flags["i"]
  66. # Make sure the temporal database exists
  67. tgis.create_temporal_database()
  68. # Set valid relative time to maps
  69. tgis.assign_valid_time_to_maps(type="raster", maps=maps, ttype="relative", \
  70. start=start, end=end, increment=increment, \
  71. dbif=None, interval=interval)
  72. if __name__ == "__main__":
  73. options, flags = grass.parser()
  74. main()