g.gui.tplot.py 2.4 KB

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