Ejemplo n.º 1
0
def test_run_kgs_brf(brf_manager_bot):
    brf_manager, qtbot = brf_manager_bot
    brf_manager.show()

    # Set the water level dataset and assert the expected values are displayed
    # correctly in the GUI.
    ppath = osp.join(os.getcwd(), "@ new-prô'jèt!", "@ new-prô'jèt!.gwt")
    projet = ProjetReader(ppath)
    wldset = projet.get_wldset(projet.wldsets[0])
    brf_manager.set_wldset(wldset)

    assert brf_manager.lagBP == 300
    assert brf_manager.lagET == 300
    assert brf_manager.detrend == 'Yes'
    assert brf_manager.correct_WL == 'No'
    assert brf_manager.brfperiod == (41241.0, 41584.0)

    brf_manager.set_datarange((41300.0, 41400.0))
    assert brf_manager.brfperiod == (41300.0, 41400.0)

    # Calcul the brf and assert the the results are plotted as expected.
    assert brf_manager.viewer.tbar.isEnabled() is False
    assert brf_manager.viewer.current_brf.value() == 0
    brf_manager.calc_brf()
    assert brf_manager.viewer.current_brf.value() == 1
    assert brf_manager.viewer.tbar.isEnabled()
Ejemplo n.º 2
0
def test_save_brf_figure(brf_manager_bot, mocker):
    """
    Test that the BRF figures are saved correctly from the GUI.
    """
    brf_manager, qtbot = brf_manager_bot
    brf_manager.show()

    # Set the water level dataset.
    ppath = osp.join(os.getcwd(), "@ new-prô'jèt!", "@ new-prô'jèt!.gwt")
    projet = ProjetReader(ppath)
    wldset = projet.get_wldset(projet.wldsets[0])
    brf_manager.set_wldset(wldset)

    qtbot.mouseClick(brf_manager.btn_show, Qt.LeftButton)
    qtbot.waitExposed(brf_manager.viewer)

    # Save the figure in the file system.
    filename = "brf_fig1.pdf"
    mocker.patch.object(QFileDialog,
                        'getSaveFileName',
                        return_value=(filename, "*.pdf"))

    qtbot.mouseClick(brf_manager.viewer.btn_save, Qt.LeftButton)
    qtbot.waitUntil(lambda: osp.exists(filename))
    os.remove(filename)
Ejemplo n.º 3
0
def test_del_brf_result(brf_manager_bot, mocker):
    """
    Test that the BRF figures are saved correctly from the GUI.
    """
    brf_manager, qtbot = brf_manager_bot
    brf_manager.show()

    # Set the water level dataset.
    ppath = osp.join(os.getcwd(), "@ new-prô'jèt!", "@ new-prô'jèt!.gwt")
    projet = ProjetReader(ppath)
    wldset = projet.get_wldset(projet.wldsets[0])
    brf_manager.set_wldset(wldset)

    # Delete the brf and assert the GUI is updated as expected.
    assert brf_manager.viewer.current_brf.value() == 1
    qtbot.mouseClick(brf_manager.viewer.btn_del, Qt.LeftButton)
    assert brf_manager.viewer.current_brf.value() == 0
    assert brf_manager.viewer.tbar.isEnabled() is False
Ejemplo n.º 4
0
    from gwhat.projet.reader_projet import ProjetReader

    app = QApplication(sys.argv)

    # ---- load data

    path_projet = "E:\\GWHAT\\Projects\\Pont-Rouge\\Pont-Rouge.what"
    projet = ProjetReader(path_projet)

    # projname = "E:\\GWHAT\\Projects\\Pont-Rouge\\Pont-Rouge.what"
    # dirname = '../Projects/Pont-Rouge'
    # fmeteo = dirname + '/Meteo/Output/STE CHRISTINE (7017000)_1960-2015.out'
    # finfo = dirname + '/Meteo/Output/STE CHRISTINE (7017000)_1960-2015.log'
    # fwaterlvl = dirname + '/Water Levels/5080001.xls'

    wldset = projet.get_wldset('#5080001')
    wxdset = projet.get_wxdset('STE CHRISTINE')

    # ---------------------------------------------------- set up hydrograph --

    hydrograph = Hydrograph()
    hydrograph.set_wldset(wldset)
    hydrograph.set_wxdset(wxdset)
    hydrograph.language = 'english'

    what = ['normal', 'MRC', 'GLUE'][0]

    if what == 'normal':
        hydrograph.fwidth = 11.  # Width of the figure in inches
        hydrograph.fheight = 8.5
Ejemplo n.º 5
0

if __name__ == '__main__':
    from PyQt5.QtWidgets import QApplication
    import sys
    from mplFigViewer3 import ImageViewer
    from gwhat.meteo.weather_reader import WXDataFrame
    from gwhat.projet.reader_projet import ProjetReader

    app = QApplication(sys.argv)

    # ---- Load the data
    path_projet = "C:\\Users\\User\\gwhat\\Projects\\Example\\Example.gwt"
    projet = ProjetReader(path_projet)

    wldset = projet.get_wldset('3040002_15min')
    wxdset = projet.get_wxdset('Marieville')

    # ---- Setup the hydrograph

    hydrograph = Hydrograph()
    hydrograph.set_wldset(wldset)
    hydrograph.set_wxdset(wxdset)
    hydrograph.language = 'english'

    hydrograph.fwidth = 11.  # Width of the figure in inches
    hydrograph.fheight = 8.5

    hydrograph.WLdatum = 0  # 0 -> mbgs ; 1 -> masl
    hydrograph.trend_line = False
    hydrograph.gridLines = 2  # Gridlines Style
Ejemplo n.º 6
0
    from gwhat.projet.reader_projet import ProjetReader

    app = QApplication(sys.argv)

    # ---- load data

    path_projet = "E:\\GWHAT\\Projects\\Pont-Rouge\\Pont-Rouge.what"
    projet = ProjetReader(path_projet)

    # projname = "E:\\GWHAT\\Projects\\Pont-Rouge\\Pont-Rouge.what"
    # dirname = '../Projects/Pont-Rouge'
    # fmeteo = dirname + '/Meteo/Output/STE CHRISTINE (7017000)_1960-2015.out'
    # finfo = dirname + '/Meteo/Output/STE CHRISTINE (7017000)_1960-2015.log'
    # fwaterlvl = dirname + '/Water Levels/5080001.xls'

    wldset = projet.get_wldset('#5080001')
    wxdset = projet.get_wxdset('STE CHRISTINE')

    # ---------------------------------------------------- set up hydrograph --

    hydrograph = Hydrograph()
    hydrograph.set_wldset(wldset)
    hydrograph.set_wxdset(wxdset)
    hydrograph.language = 'english'

    what = ['normal', 'MRC', 'GLUE'][0]

    if what == 'normal':
        hydrograph.fwidth = 11.  # Width of the figure in inches
        hydrograph.fheight = 8.5
Ejemplo n.º 7
0
def test_graph_panel(brf_manager_bot, mocker):
    brf_manager, qtbot = brf_manager_bot
    brf_manager.show()
    graph_opt_panel = brf_manager.viewer.graph_opt_panel

    # Set the water level dataset.
    ppath = osp.join(os.getcwd(), "@ new-prô'jèt!", "@ new-prô'jèt!.gwt")
    projet = ProjetReader(ppath)
    wldset = projet.get_wldset(projet.wldsets[0])
    brf_manager.set_wldset(wldset)

    qtbot.mouseClick(brf_manager.btn_show, Qt.LeftButton)
    qtbot.waitExposed(brf_manager.viewer)

    # Toggle on the panel and assert it is shown correctly.
    assert (graph_opt_panel.isVisible() is False)
    qtbot.mouseClick(brf_manager.viewer.btn_setp, Qt.LeftButton)
    assert (graph_opt_panel.isVisible())

    # Assert the default values for the y-axis :

    assert (graph_opt_panel.ymin is None)
    assert (graph_opt_panel.ymax is None)
    assert (graph_opt_panel.yscale is None)

    graph_opt_panel._ylim['auto'].setChecked(False)
    assert (graph_opt_panel.ymin == 0)
    assert (graph_opt_panel.ymax == 1)

    # Assert the default values for the x-axis :

    assert (graph_opt_panel.xmin is None)
    assert (graph_opt_panel.xmax is None)
    assert (graph_opt_panel.xscale is None)
    assert (graph_opt_panel.time_units is 'auto')

    graph_opt_panel._xlim['auto'].setChecked(False)
    assert (graph_opt_panel.xmin == 0)
    assert (graph_opt_panel._xlim['min'].value() == 0)
    assert (graph_opt_panel.xmax == 1)
    assert (graph_opt_panel._xlim['max'].value() == 1)
    assert (graph_opt_panel.xscale == 1)
    assert (graph_opt_panel._xlim['scale'].value() == 1)
    assert (graph_opt_panel.time_units == 'days')

    # Assert when the value of time_units change :

    graph_opt_panel._xlim['units'].setCurrentIndex(0)
    assert (graph_opt_panel.time_units == 'hours')
    assert (graph_opt_panel.xmin == 0)
    assert (graph_opt_panel._xlim['min'].value() == 0)
    assert (graph_opt_panel.xmax == 1)
    assert (graph_opt_panel._xlim['max'].value() == 24)
    assert (graph_opt_panel.xscale == 1)
    assert (graph_opt_panel._xlim['scale'].value() == 24)

    # Assert the default values for the artists :

    assert graph_opt_panel.show_ebar is True
    assert graph_opt_panel.draw_line is False
    assert graph_opt_panel.markersize == 5

    # Toggle off the panel and assert it is hidden correctly.
    qtbot.mouseClick(brf_manager.viewer.btn_setp, Qt.LeftButton)
    assert (brf_manager.viewer.graph_opt_panel.isVisible() is False)