g.gui.tplot.py 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. #!/usr/bin/env python
  2. ############################################################################
  3. #
  4. # MODULE: g.gui.tplot.py
  5. # AUTHOR(S): Luca Delucchi
  6. # PURPOSE: Temporal Plot Tool is a wxGUI component (based on matplotlib)
  7. # the user to see in a plot the values of one or more temporal
  8. # datasets for a queried point defined by a coordinate pair.
  9. # COPYRIGHT: (C) 2014 by Luca Delucchi, and the GRASS Development Team
  10. #
  11. # This program is free software; you can redistribute it and/or modify
  12. # it under the terms of the GNU General Public License as published by
  13. # the Free Software Foundation; either version 2 of the License, or
  14. # (at your option) any later version.
  15. #
  16. # This program is distributed in the hope that it will be useful,
  17. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  18. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  19. # GNU General Public License for more details.
  20. #
  21. ############################################################################
  22. #%module
  23. #% description: Allows the user to see in a plot the values of one or more temporal datasets for a queried point defined by a coordinate pair.
  24. #% keywords: general
  25. #% keywords: GUI
  26. #% keywords: temporal
  27. #%end
  28. #%option G_OPT_STDS_INPUTS
  29. #% required: no
  30. #%end
  31. #%option G_OPT_M_COORDS
  32. #% required: no
  33. #%end
  34. #%option G_OPT_F_OUTPUT
  35. #% required: no
  36. #%end
  37. #%option
  38. #% key: dpi
  39. #% type: integer
  40. #% label: The DPI for output image
  41. #% description: To use only with output parameters
  42. #% required: no
  43. #%end
  44. ## #%flag
  45. ## #% key: 3
  46. ## #% description: Show also 3D plot of spatio-temporal extents
  47. ## #%end
  48. import wx
  49. import grass.script as grass
  50. from core.utils import GuiModuleMain
  51. def main():
  52. try:
  53. from tplot.frame import TplotFrame
  54. except ImportError as e:
  55. grass.fatal(e.message)
  56. datasets = options['inputs'].strip().split(',')
  57. datasets = [data for data in datasets if data]
  58. coords = options['coordinates'].strip().split(',')
  59. output = options['output']
  60. dpi = options['dpi']
  61. # view3d = flags['3']
  62. if dpi and not output:
  63. grass.warning(_("No output filename set, so DPI option will not used"))
  64. app = wx.App()
  65. frame = TplotFrame(None)
  66. frame.SetDatasets(datasets, coords, output, dpi)
  67. if output:
  68. return
  69. # frame.Show3D(view3d)
  70. frame.Show()
  71. app.MainLoop()
  72. if __name__ == '__main__':
  73. options, flags = grass.parser()
  74. GuiModuleMain(main)