Beispiel #1
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)
Beispiel #2
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()
Beispiel #3
0
def bakfile(projectfile):
    """A path to a valid project backup file."""
    project = ProjetReader(projectfile)
    project.backup_project_file()
    project.close()
    assert osp.exists(projectfile + '.bak')
    return projectfile + '.bak'
Beispiel #4
0
    def restore_from_backup(self, filename):
        """
        Try to restore the project from its backup file.
        """
        self.close_projet()
        msg_box = QMessageBox(
            QMessageBox.Warning,
            "Restore project warning",
            ("<b>Failed to restore the project.</b><br><br>"
             "We are very sorry for the inconvenience. "
             "Please submit a bug report on our GitHub issue tracker."),
            buttons=QMessageBox.Ok,
            parent=self)

        # First we check that the backup is ok.
        try:
            backup = ProjetReader(filename + '.bak')
            assert backup.check_project_file() is True
            backup.close()
        except Exception:
            msg_box.exec_()
            return False

        # Then we try to restore the project from the backup.
        print("Restoring project from backup... ", end='')
        try:
            os.remove(filename)
            copyfile(filename + '.bak', filename)
        except (OSError, PermissionError):
            print('failed')
            msg_box.exec_()
            return False
        else:
            print('done')
            return self.load_project(filename)
Beispiel #5
0
    def save_project(self):
        name = self.name.text()
        if name == '':
            print('Please enter a valid Project name')
            return

        rootname = self.directory.text()
        dirname = os.path.join(rootname, name)

        # If directory already exist, a number is added at the end within ().

        count = 1
        while os.path.exists(dirname):
            dirname = os.path.join(rootname, '%s (%d)' % (name, count))
            count += 1

        print('\n---------------')
        print('Creating files and folder achitecture for the new project in:')
        print(dirname)
        print

        # ---- Create Files and Folders ----

        os.makedirs(dirname)

        # ---- folder architecture ----

        folders = [
            os.path.join(dirname, 'Meteo', 'Raw'),
            os.path.join(dirname, 'Meteo', 'Input'),
            os.path.join(dirname, 'Meteo', 'Output'),
            os.path.join(dirname, 'Water Levels')
        ]

        for f in folders:
            if not os.path.exists(f):
                os.makedirs(f)

        # ---- project.what ----

        fname = os.path.join(dirname, '%s.gwt' % name)

        projet = ProjetReader(fname)
        projet.name = self.name.text()
        projet.author = self.author.text()
        projet.created = self.date.text()
        projet.modified = self.date.text()
        projet.version = self.createdby.text()
        projet.lat = self.lat_spinbox.value()
        projet.lon = self.lon_spinbox.value()

        del projet

        print('Creating file %s.gwt' % name)
        print('---------------')

        self.close()
        self.sig_new_project.emit(fname)
Beispiel #6
0
def project(projectpath):
    # Create a project and add add the wldset to it.
    project = ProjetReader(
        osp.join(projectpath, "project_test_hydroprint.gwt"))

    # Add the weather datasets to the project.
    for wxfilename in WXFILENAMES:
        wxdset = WXDataFrame(wxfilename)
        project.add_wxdset(wxdset['Station Name'], wxdset)

    # Add the water level dataset to the project.
    wldset = WLDataFrame(WLFILENAME)
    project.add_wldset(wldset['Well'], wldset)
    return project
Beispiel #7
0
    def load_project(self, filename):
        if not osp.exists(filename):
            self.__projet = None
            msg = """
                  <p>
                    <b>Failed to load the project.</b><br><br>
                    The project file<br>%s<br>
                    does not exist.<br><br>
                    Please open an existing project or create a new one.
                  </p>
                """ % osp.abspath(filename)
            QMessageBox.warning(self, 'Warning', msg, QMessageBox.Ok)
            return False

        try:
            self.__projet = projet = ProjetReader(filename)
        except Exception:
            self.__projet = None
            msg = """
                  <p>
                    <b>Failed to load the project.</b><br><br>
                    The project file<br>%s<br>
                    is not valid.<br><br>
                    Please open a valid project or create a new one.
                  </p>
                """ % osp.abspath(filename)
            QMessageBox.warning(self, 'Warning', msg, QMessageBox.Ok)
            return False
        else:
            wldir = os.path.join(projet.dirname, "Water Levels")
            init_waterlvl_measures(wldir)
            self.project_display.setText(projet.name)
            self.project_display.adjustSize()
            self.currentProjetChanged.emit(projet)
            return True
Beispiel #8
0
    def save_project(self):
        name = self.name.text()
        if name == '':
            print('Please enter a valid Project name')
            return

        rootname = self.directory.text()
        dirname = os.path.join(rootname, name)

        # If directory already exist, a number is added at the end within ().

        count = 1
        while os.path.exists(dirname):
            dirname = os.path.join(rootname, '%s (%d)' % (name, count))
            count += 1

        print('\n---------------')
        print('Creating files and folder achitecture for the new project in:')
        print(dirname)
        print

        # ---- Create Files and Folders ----

        os.makedirs(dirname)

        # ---- folder architecture ----

        folders = [os.path.join(dirname, 'Meteo', 'Raw'),
                   os.path.join(dirname, 'Meteo', 'Input'),
                   os.path.join(dirname, 'Meteo', 'Output'),
                   os.path.join(dirname, 'Water Levels')]

        for f in folders:
            if not os.path.exists(f):
                os.makedirs(f)

        # ---- project.what ----

        fname = os.path.join(dirname, '%s.gwt' % name)

        projet = ProjetReader(fname)
        projet.name = self.name.text()
        projet.author = self.author.text()
        projet.created = self.date.text()
        projet.modified = self.date.text()
        projet.version = self.createdby.text()
        projet.lat = self.lat_spinbox.value()
        projet.lon = self.lon_spinbox.value()

        del projet

        print('Creating file %s.gwt' % name)
        print('---------------')

        self.close()
        self.sig_new_project.emit(fname)
Beispiel #9
0
def data_manager_bot(qtbot):
    data_manager = DataManager(projet=ProjetReader(projetpath),
                               pytesting=True)
    qtbot.addWidget(data_manager)
    qtbot.addWidget(data_manager.new_waterlvl_win)
    qtbot.addWidget(data_manager.new_weather_win)

    return data_manager, qtbot
Beispiel #10
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
Beispiel #11
0
def test_clear_hydrograph(hydroprint, mocker, tmp_path):
    """
    Test that the hydrograph is cleared correctly when the water level or
    weather dataset become None at some point.
    """
    assert hydroprint.hydrograph.isHydrographExists is True
    empty_project = ProjetReader(osp.join(tmp_path, "empty_project.gwt"))
    hydroprint.dmngr.set_projet(empty_project)
    assert hydroprint.hydrograph.isHydrographExists is False
Beispiel #12
0
def hydrocalc_bot(qtbot):
    pf = os.path.join(working_dir, "@ new-prô'jèt!.gwt")
    pr = ProjetReader(pf)

    dm = DataManager()
    dm.set_projet(pr)

    hydrocalc = WLCalc(dm)
    qtbot.addWidget(hydrocalc)

    return hydrocalc, qtbot
Beispiel #13
0
def projectfile(projectpath):
    """A path to a valid existing project file."""
    project = ProjetReader(projectpath)
    assert osp.exists(projectpath)

    project.name = NAME
    project.author = NAME
    project.lat = LAT
    project.lon = LON

    project.close()

    return projectpath
Beispiel #14
0
def hydroprint_bot(qtbot):
    pf = os.path.join(working_dir, "@ new-prô'jèt!.gwt")
    pr = ProjetReader(pf)

    dm = DataManager()
    dm.set_projet(pr)

    hydroprint = HydroprintGUI(dm)
    qtbot.addWidget(hydroprint)
    qtbot.addWidget(hydroprint.page_setup_win)

    return hydroprint, qtbot
Beispiel #15
0
def bakfile(projectfile):
    """A path to a valid project backup file."""
    project = ProjetReader(projectfile)
    project.backup_project_file()
    project.close()
    assert osp.exists(projectfile + '.bak')
    return projectfile + '.bak'
Beispiel #16
0
def test_last_opened_datasets(qtbot, projectpath):
    """
    Test that the data manager recall correctly the water level and weather
    datasets that were last opened when opening a new project.

    Cover the new feature added in PR #267.
    """
    datamanager = DataManager(projet=ProjetReader(projectpath))
    qtbot.addWidget(datamanager)
    datamanager.show()

    # Add some water level dataset.
    for name in ['wldset1', 'wldset2', 'wldset3']:
        datamanager.new_wldset_imported(name, WLDataFrame(WLFILENAME))
    assert datamanager.get_current_wldset().name == 'wldset3'

    # Add some weather dataset.
    for name in ['wxdset1', 'wxdset2', 'wxdset3']:
        datamanager.new_wxdset_imported(name, WXDataFrame(WXFILENAME))
    assert datamanager.get_current_wxdset().name == 'wxdset3'

    # Change the current water level and weather datasets.
    datamanager.set_current_wldset('wldset2')
    assert datamanager.get_current_wldset().name == 'wldset2'
    datamanager.set_current_wxdset('wxdset2')
    assert datamanager.get_current_wxdset().name == 'wxdset2'

    # Close the datamanager and its project.
    datamanager.projet.close()
    datamanager.close()

    # Create a new datamanager and assert that the last opened water level
    # and weather datasets are remembered correctly.
    datamanager2 = DataManager(projet=ProjetReader(projectpath))
    qtbot.addWidget(datamanager2)
    datamanager2.show()

    assert datamanager2.get_current_wldset().name == 'wldset2'
    assert datamanager2.get_current_wxdset().name == 'wxdset2'
Beispiel #17
0
def projectfile(projectpath):
    """A path to a valid existing project file."""
    project = ProjetReader(projectpath)
    assert osp.exists(projectpath)

    project.name = NAME
    project.author = NAME
    project.lat = LAT
    project.lon = LON

    project.close()

    return projectpath
Beispiel #18
0
def test_clear_hydrograph(hydroprint_bot, mocker):
    """
    Test that the hydrograph is cleared correctly when the water level or
    weather dataset become None at some point.
    """
    hydroprint, qtbot = hydroprint_bot
    hydroprint.show()
    assert hydroprint.hydrograph.isHydrographExists is False

    hydroprint.wldset_changed()
    assert hydroprint.hydrograph.isHydrographExists is True

    empty_project = ProjetReader('empty_project.gwt')
    hydroprint.dmngr.set_projet(empty_project)

    assert hydroprint.hydrograph.isHydrographExists is False
Beispiel #19
0
def project(projectpath):
    # Create a project and add add the wldset to it.
    project = ProjetReader(osp.join(projectpath, "project_test_hydrocalc.gwt"))

    # Add the weather dataset to the project.
    wxdset = WXDataFrame(WXFILENAME)
    project.add_wxdset(wxdset.metadata['Station Name'], wxdset)

    # Add the water level dataset to the project.
    wldset = WLDataFrame(WLFILENAME)
    project.add_wldset(wldset['Well'], wldset)
    return project
Beispiel #20
0
def project(projectfile):
    """Create a generic GWHAT project at the specified path."""
    project = ProjetReader(projectfile)
    return project
Beispiel #21
0
if __name__ == '__main__':

    from PyQt5.QtWidgets import QApplication
    import sys
    from mplFigViewer3 import ImageViewer
    from gwhat.projet.reader_waterlvl import read_water_level_datafile
    from gwhat.meteo.weather_reader import WXDataFrame
    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)
Beispiel #22
0
        self.hide()
        self.sig_new_dataset_imported.emit(self.name, self._dataset)
        self.close()

    # ---- Display Handlers

    def close(self):
        """Qt method override."""
        super(NewDatasetDialog, self).close()
        self._dataset = None
        self.directory.clear()
        self.update_gui()


if __name__ == '__main__':
    import sys
    from gwhat.projet.reader_projet import ProjetReader

    app = QApplication(sys.argv)

    ft = app.font()
    ft.setFamily('Segoe UI')
    ft.setPointSize(11)
    app.setFont(ft)

    dm = DataManager(projet=ProjetReader(
        "C:\\Users\\User\\gwhat\\Projects\\Example\\Example.gwt"))
    dm.show()

    app.exec_()
Beispiel #23
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)
Beispiel #24
0
def project(tmp_path_factory):
    basetemp = tmp_path_factory.getbasetemp()
    return ProjetReader(osp.join(basetemp, "mainwindow_test.gwt"))
Beispiel #25
0
    return tf, wlf


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
Beispiel #26
0
def project(projectpath):
    # Create a project and add add the wldset to it.
    return ProjetReader(projectpath)
Beispiel #27
0
def project(tmp_path_factory):
    # Create a project and add add the wldset to it.
    basetemp = tmp_path_factory.getbasetemp()
    return ProjetReader(osp.join(basetemp, "brf_test.gwt"))
Beispiel #28
0
    def load_project(self, filename):
        """
        Load the project from the specified filename.
        """
        self.close_projet()

        # If the project doesn't exist.
        if not osp.exists(filename):
            msg_box = QMessageBox(
                QMessageBox.Warning,
                "Open project warning",
                ("<b>Failed to open the project.</b><br><br>"
                 "The project file does not exist. Please open an existing "
                 "project or create a new one."
                 "<br><br><i>{}</i>").format(osp.abspath(filename)),
                buttons=QMessageBox.Ok,
                parent=self)
            msg_box.exec_()
            return False

        # If the project fails to load.
        try:
            projet = ProjetReader(filename)
        except Exception:
            if osp.exists(filename + '.bak'):
                msg_box = QMessageBox(
                    QMessageBox.Question,
                    "Open project warning",
                    ("<b>Failed to open the project.</b><br><br>"
                     "The project file may be corrupt. Do you want to "
                     "restore the project from the last project backup?"
                     "<br><br><i>{}</i>").format(osp.abspath(filename)),
                    buttons=QMessageBox.Yes | QMessageBox.Cancel,
                    parent=self)
                reply = msg_box.exec_()
                if reply == QMessageBox.Yes:
                    return self.restore_from_backup(filename)
                else:
                    return False
            else:
                msg_box = QMessageBox(
                    QMessageBox.Warning,
                    "Open project warning",
                    ("<b>Failed to open the project.</b><br><br>"
                     "The project file is not valid. Please open an existing "
                     "valid project or create a new one."
                     "<br><br><i>{}</i>").format(osp.abspath(filename)),
                    buttons=QMessageBox.Ok,
                    parent=self)
                msg_box.exec_()
                return False
        else:
            self.projet = projet

        # If the project is corrupt.
        if self.projet.check_project_file() is True:
            self.projet.backup_project_file()
        else:
            if osp.exists(filename + '.bak'):
                msg_box = QMessageBox(
                    QMessageBox.Question,
                    "Open project warning",
                    ("<b>The project file may be corrupt.</b><br><br>"
                     "Would you like to restore the project from the last "
                     "project backup?<br><br>"
                     "Click <i>Yes</i> to restore the project, click "
                     "<i>Ignore</i> to open the project anyway, "
                     "or click <i>Cancel</i> to not open any project."
                     "<br><br><i>{}</i>").format(osp.abspath(filename)),
                    buttons=(QMessageBox.Yes |
                             QMessageBox.Ignore |
                             QMessageBox.Cancel),
                    parent=self)
                reply = msg_box.exec_()
                if reply == QMessageBox.Yes:
                    return self.restore_from_backup(filename)
                if reply == QMessageBox.Ignore:
                    pass
                else:
                    self.close_projet()
                    return False
            else:
                msg_box = QMessageBox(
                    QMessageBox.Question,
                    "Open project warning",
                    ("<b>The project file appears to be corrupt.</b><br><br>"
                     "Do you want open the project anyway?"
                     "<br><br><i>{}</i>").format(osp.abspath(filename)),
                    buttons=QMessageBox.Yes | QMessageBox.Cancel,
                    parent=self)
                reply = msg_box.exec_()
                if reply == QMessageBox.Yes:
                    pass
                else:
                    self.close_projet()
                    return False

        init_waterlvl_measures(osp.join(self.projet.dirname, "Water Levels"))
        self.project_display.setText(self.projet.name)
        self.project_display.adjustSize()
        self.currentProjetChanged.emit(self.projet)
        return True
Beispiel #29
0
            QApplication.processEvents()
            try:
                self.model.export_dataset_to_file(savefilename, time_frame)
            except PermissionError:
                self.show_permission_error()
                self.select_export_file(time_frame, savefilename)
            QApplication.restoreOverrideCursor()


if __name__ == '__main__':
    from gwhat.projet.reader_projet import ProjetReader
    app = QApplication(sys.argv)

    ft = app.font()
    ft.setFamily('Segoe UI')
    ft.setPointSize(11)
    app.setFont(ft)

    fname = ("C:\\Users\\User\\gwhat\\Projects\\Example\\Example.gwt")
    project = ProjetReader(fname)
    wxdset = project.get_wxdset('Marieville')

    w = WeatherViewer()
    w.save_fig_dir = os.getcwd()

    w.set_lang('French')
    w.set_weather_dataset(wxdset)
    w.show()

    app.exec_()
Beispiel #30
0
if __name__ == '__main__':

    from PyQt5.QtWidgets import QApplication
    import sys
    from mplFigViewer3 import ImageViewer
    from gwhat.projet.reader_waterlvl import read_water_level_datafile
    from gwhat.meteo.weather_reader import WXDataFrame
    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)