g.gui.tplot.py 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  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. #% label: Name for output file
  37. #% description: Add extension to specify format (.png, .pdf, .svg)
  38. #%end
  39. #%option
  40. #% key: dpi
  41. #% type: integer
  42. #% label: The DPI for output image
  43. #% description: To use only with output parameter
  44. #% required: no
  45. #%end
  46. import wx
  47. import grass.script as grass
  48. from core.utils import GuiModuleMain
  49. def main():
  50. try:
  51. from tplot.frame import TplotFrame
  52. except ImportError as e:
  53. grass.fatal(e.message)
  54. datasets = options['inputs'].strip().split(',')
  55. datasets = [data for data in datasets if data]
  56. coords = options['coordinates'].strip().split(',')
  57. output = options['output']
  58. dpi = options['dpi']
  59. dpi = int(dpi) if dpi else None
  60. if dpi and not output:
  61. grass.warning(_("No output filename set, so DPI option will not used"))
  62. app = wx.App()
  63. frame = TplotFrame(None)
  64. frame.SetDatasets(datasets, coords, output, dpi)
  65. if output:
  66. return
  67. frame.Show()
  68. app.MainLoop()
  69. if __name__ == '__main__':
  70. options, flags = grass.parser()
  71. GuiModuleMain(main)