Exemplo n.º 1
0
    def setUp(self):
        def add_cast(lat, lon):
            self.lib.ssp.cur.meta.latitude = lat
            self.lib.ssp.cur.meta.longitude = lon
            self.lib.ssp.cur.meta.utc_time = datetime.now()
            self.lib.ssp.cur.init_data(self.levels)
            self.lib.ssp.cur.data.depth[:self.levels] = self.depth
            self.lib.ssp.cur.data.speed[:self.levels] = 1415
            self.lib.restart_proc()
            self.lib.store_data()

        self.max_pk = 5
        self.levels = self.max_pk * self.max_pk
        self.depth = np.array(range(self.levels))
        projects_folder = os.path.abspath(os.curdir)
        project_name = 'unittest'
        db_name = '%s.db' % project_name
        self.db_path = os.path.join(projects_folder, db_name)
        self.tearDown()
        self.lib = SoundSpeedLibrary()
        self.lib.projects_folder = projects_folder
        self.lib.current_project = project_name
        self.lib.ssp = ProfileList()
        self.lib.ssp.append()
        if len(self.lib.db_list_profiles()) < self.max_pk:
            for i in range(self.max_pk):
                add_cast(20 + i, -75)
Exemplo n.º 2
0
 def test_creation_of_Gomofs(self):
     prj = SoundSpeedLibrary(data_folder=self.cur_dir)
     gomofs = RegOfsOnline(data_folder=prj.regofs_folder,
                           prj=prj,
                           model=RegOfsOnline.Model.GoMOFS)
     self.assertTrue('regofs' in gomofs.data_folder)
     self.assertFalse(gomofs.is_present())
     prj.close()
Exemplo n.º 3
0
    def test_creation_of_Atlases(self):
        lib = SoundSpeedLibrary(data_folder=self.cur_dir)
        atl = atlases.Atlases(prj=lib)

        self.assertTrue("atlases" in atl.rtofs_folder)
        self.assertTrue("woa" in atl.woa09_folder)
        self.assertTrue("woa" in atl.woa13_folder)

        lib.close()
Exemplo n.º 4
0
    def test_download_db_from_Rtofs(self):
        prj = SoundSpeedLibrary(data_folder=self.cur_dir)
        rtofs = Rtofs(data_folder=prj.data_folder, prj=prj)
        rtofs.download_db(server_mode=True)

        # to avoid test failures
        if not rtofs.is_present():
            logger.warning("unable to download RTOFS data")
        # self.assertTrue(rtofs.is_present())

        prj.close()
Exemplo n.º 5
0
    def test_download_db_from_Gomofs(self):
        prj = SoundSpeedLibrary(data_folder=self.cur_dir)
        gomofs = RegOfsOnline(data_folder=prj.regofs_folder,
                              prj=prj,
                              model=RegOfsOnline.Model.GoMOFS)
        gomofs.download_db(server_mode=True)

        # to avoid test failures
        if not gomofs.is_present():
            logger.warning("unable to download GoMOFS data")
        # self.assertTrue(rtofs.is_present())

        prj.close()
Exemplo n.º 6
0
class TestSoundSpeedDb(unittest.TestCase):
    def setUp(self):
        def add_cast(lat, lon):
            self.lib.ssp.cur.meta.latitude = lat
            self.lib.ssp.cur.meta.longitude = lon
            self.lib.ssp.cur.meta.utc_time = datetime.now()
            self.lib.ssp.cur.init_data(self.levels)
            self.lib.ssp.cur.data.depth[:self.levels] = self.depth
            self.lib.ssp.cur.data.speed[:self.levels] = 1415
            self.lib.restart_proc()
            self.lib.store_data()

        self.max_pk = 5
        self.levels = self.max_pk * self.max_pk
        self.depth = np.array(range(self.levels))
        projects_folder = os.path.abspath(os.curdir)
        project_name = 'unittest'
        db_name = '%s.db' % project_name
        self.db_path = os.path.join(projects_folder, db_name)
        self.tearDown()
        self.lib = SoundSpeedLibrary()
        self.lib.projects_folder = projects_folder
        self.lib.current_project = project_name
        self.lib.ssp = ProfileList()
        self.lib.ssp.append()
        if len(self.lib.db_list_profiles()) < self.max_pk:
            for i in range(self.max_pk):
                add_cast(20 + i, -75)

    def tearDown(self):
        if os.path.exists(self.db_path):
            os.remove(self.db_path)

    # @unittest.skipUnless(sys.platform.startswith("win"), "only works with GDAL < 2.0 on Windows")
    def test_save_load_cast(self):
        def test_pk(pkey):
            self.lib.ssp = self.lib.db_retrieve_profile(pkey)
            self.lib.store_data()
            self.lib.ssp = self.lib.db_retrieve_profile(pkey)
            sum_ = len(self.lib.ssp.cur.proc.speed) + len(
                self.lib.ssp.cur.proc.depth)
            sum_ += len(self.lib.ssp.cur.data.speed) + len(
                self.lib.ssp.cur.data.depth)
            self.assertEqual(sum_, self.levels * 4)
            self.assertTrue((self.lib.ssp.cur.data.depth == self.depth).all())
            self.assertTrue((self.lib.ssp.cur.proc.depth == self.depth).all())

        for i in range(self.levels):
            # pk = random.randint(1, self.max_pk)
            pk = i % self.max_pk + 1
            test_pk(pk)
Exemplo n.º 7
0
def gui():
    """Run the Sound Speed Settings gui"""

    app = QtWidgets.QApplication(sys.argv)
    app.setStyleSheet(AppStyle.load_stylesheet())

    lib = SoundSpeedLibrary()
    main = MainWin(lib=lib)
    main.show()

    sys.exit(app.exec_())
Exemplo n.º 8
0
def gui():
    """Run the Sound Speed Settings gui"""
    from hyo2.soundspeedsettings.mainwin import MainWin
    from hyo2.soundspeed.soundspeed import SoundSpeedLibrary

    app = QtWidgets.QApplication(sys.argv)
    app.setStyleSheet(AppStyle.load_stylesheet())

    lib = SoundSpeedLibrary()
    main = MainWin(lib=lib)
    main.show()

    sys.exit(app.exec_())
    def test_available_projects(self):

        lib = SoundSpeedLibrary()
        ssp_list = lib.db_list_profiles()
        self.assertGreaterEqual(len(ssp_list), 0)

        prj_list = lib.list_projects()
        self.assertGreaterEqual(len(prj_list), 1)

        lib.close()
Exemplo n.º 10
0
    def _run(self, filters):
        # create a project with test-callbacks
        lib = SoundSpeedLibrary(callbacks=TestCallbacks())

        # set the current project name
        lib.setup.current_project = 'test_read_store_and_write'

        tests = self.testing.input_dict_test_files(inclusive_filters=filters)
        data_outputs = dict()
        for format in self.output_formats:
            data_outputs[format] = self.data_output

        for idx, testfile in enumerate(tests.keys()):

            if reduced_testing and (os.path.basename(testfile)[0] != "_"):
                continue
            logger.info("test: * New profile: #%03d * -> %s" % (idx, os.path.basename(testfile)))

            lib.import_data(data_path=testfile, data_format=tests[testfile].name)

            lib.store_data()

            lib.export_data(data_paths=data_outputs, data_formats=self.output_formats)
set_logging(ns_list=ns_list)

logger = logging.getLogger(__name__)

# examples of test position:
# - offshore Portsmouth: 43.026480, -70.318824
# - Indian Ocean: -19.1, 74.16
# - middle of Africa (in land): 18.2648113, 16.1761115

switch = "LEOFS"  # WOA09 or WOA13 or RTOFS or GoMOFS or LEOFS or LHOFS

app = QtWidgets.QApplication([])  # PySide stuff (start)
mw = QtWidgets.QMainWindow()
mw.show()

lib = SoundSpeedLibrary(progress=QtProgress(parent=mw),
                        callbacks=QtCallbacks(parent=mw))

if switch == "WOA09":

    # download the WOA09 if not present
    if not lib.has_woa09():
        success = lib.download_woa09()
        if not success:
            raise RuntimeError("unable to download")
    logger.info("has WOA09: %s" % lib.has_woa09())

    # ask user for location and timestamp
    lib.retrieve_woa09()
    logger.info("retrieved WOA09 profiles: %s" % lib.ssp)

elif switch == "WOA13":
Exemplo n.º 12
0
 def test_creation_of_Gomofs(self):
     prj = SoundSpeedLibrary(data_folder=self.cur_dir)
     gomofs = Gomofs(data_folder=prj.gomofs_folder, prj=prj)
     self.assertTrue('gomofs' in gomofs.data_folder)
     self.assertFalse(gomofs.is_present())
     prj.close()
Exemplo n.º 13
0
 def test_creation_of_Rtofs(self):
     prj = SoundSpeedLibrary(data_folder=self.cur_dir)
     rtofs = Rtofs(data_folder=prj.rtofs_folder, prj=prj)
     self.assertTrue('rtofs' in rtofs.data_folder)
     self.assertFalse(rtofs.is_present())
     prj.close()
from hyo2.soundspeedmanager import AppInfo
from hyo2.soundspeed.soundspeed import SoundSpeedLibrary
from hyo2.soundspeed.base.testing import SoundSpeedTesting
from hyo2.soundspeed.base.callbacks.fake_callbacks import FakeCallbacks
from hyo2.abc.lib.logging import set_logging

ns_list = [
    "hyo2.soundspeed", "hyo2.soundspeedmanager", "hyo2.soundspeedsettings"
]
set_logging(ns_list=ns_list)

logger = logging.getLogger(__name__)

# create a project with test-callbacks
lib = SoundSpeedLibrary(callbacks=FakeCallbacks())

# set the current project name
lib.setup.current_project = 'test'

data_folder = os.path.abspath(
    os.path.join(os.path.dirname(__file__), os.pardir, os.pardir))
testing = SoundSpeedTesting(root_folder=data_folder)

# retrieve data input/output folders
data_input = testing.input_data_folder()
logger.info('input folder: %s' % data_input)
data_output = testing.output_data_folder()
logger.info('output folder: %s' % data_output)

# test readers/writers
from hyo2.abc.lib.gdal_aux import GdalAux
from hyo2.abc.lib.logging import set_logging
# noinspection PyUnresolvedReferences
from hyo2.soundspeedmanager import app_info
from hyo2.soundspeed.soundspeed import SoundSpeedLibrary

set_logging(ns_list=[
    "hyo2.abc", "hyo2.soundspeed", "hyo2.soundspeedmanager",
    "hyo2.soundspeedsettings"
])
logger = logging.getLogger(__name__)

# create a project
data_folder = os.path.abspath(
    os.path.join(os.path.dirname(__file__), os.pardir, os.pardir))
lib = SoundSpeedLibrary()

# set the current project name
lib.setup.current_project = 'default'
lib.setup.save_to_db()

# retrieve all the id profiles from db
lst = lib.db_list_profiles()
logger.info("Profiles: %s" % len(lst))

# plots/maps/exports
# - mapt
lib.map_db_profiles(show_plot=True)
lib.save_map_db_profiles()

# - aggregate plot
Exemplo n.º 16
0
import time
import logging

from hyo2.soundspeedmanager import app_info
from hyo2.soundspeed.soundspeed import SoundSpeedLibrary
from hyo2.soundspeed.server.server import Server
from hyo2.abc.lib.logging import set_logging

ns_list = [
    "hyo2.soundspeed", "hyo2.soundspeedmanager", "hyo2.soundspeedsettings"
]
set_logging(ns_list=ns_list)

logger = logging.getLogger(__name__)

lib = SoundSpeedLibrary()
lib.listen_sis()
time.sleep(3)  # for SIS emulator

server = Server(prj=lib)

success = server.check_settings()
if not success:
    exit("Issue while checking the settings")
logger.debug("Settings successfully checked")

server.start()
time.sleep(20)

server.force_send = True
time.sleep(10)
Exemplo n.º 17
0
import logging

from hyo2.soundspeed.soundspeed import SoundSpeedLibrary

logging.basicConfig(level=logging.DEBUG)
logger = logging.getLogger(__name__)


# initialize the library
lib = SoundSpeedLibrary()

# print(lib)

# # exploring folders
# lib.open_data_folder()
# lib.open_release_folder()
# lib.open_projects_folder()
# lib.open_atlases_folder()

ssp_list = lib.db_list_profiles()
logger.debug('profiles in db: %d' % len(ssp_list))

logger.debug('setup version: %s' % lib.setup.setup_version)

lib.close()
Exemplo n.º 18
0
 def test_init(self):
     prj = SoundSpeedLibrary(data_folder=self.cur_dir)
     _ = RegOfsOffline(data_folder=prj.regofs_folder, prj=prj)
     prj.close()

ns_list = ["hyo2.soundspeed", "hyo2.soundspeedmanager", "hyo2.soundspeedsettings"]
set_logging(ns_list=ns_list)

logger = logging.getLogger(__name__)

testing = Testing(root_folder=os.path.abspath(os.path.join(os.path.dirname(__file__), os.pardir, os.pardir, os.pardir)))

nc_path = testing.download_test_files(ext=".nc", subfolder="sfbofs")[0]

app = QtWidgets.QApplication([])  # PySide stuff (start)
mw = QtWidgets.QMainWindow()
mw.show()

lib = SoundSpeedLibrary(progress=QtProgress(parent=mw), callbacks=QtCallbacks(parent=mw))

# Choose test location
tests = [

    # (-19.1, 74.16),              # Indian Ocean
    # (72.852028, -67.315431)      # Baffin Bay
    # (18.2648113, 16.1761115),    # in land -> middle of Africa
    # (39.725989, -104.967745)     # in land -> Denver, CO
    # (37.985427, -76.311156),     # Chesapeake Bay
    # (39.162802, -75.278057),     # Deleware Bay
    # (43.026480, -70.318824),     # offshore Portsmouth
    # (40.662218, -74.049306),     # New York Harbor
    # (30.382518, -81.573615),     # Mill Cove, St. Johns River
    # (28.976225, -92.078882),     # Offshore Louisiana
    # (27.762904, -82.557280),     # Tampa Bay
Exemplo n.º 20
0
class MainWin(QtWidgets.QMainWindow):

    def __init__(self):
        QtWidgets.QMainWindow.__init__(self)

        logger.info("* > APP: initializing ...")

        # set the application name and the version
        self.name = app_info.app_name
        self.version = app_info.app_version
        self.setWindowTitle('%s v.%s' % (self.name, self.version))
        # noinspection PyArgumentList
        _app = QtCore.QCoreApplication.instance()
        _app.setApplicationName('%s' % self.name)
        _app.setOrganizationName("HydrOffice")
        _app.setOrganizationDomain("hydroffice.org")

        # set the minimum and the initial size
        self.setMinimumSize(640, 480)
        self.resize(920, 640)

        # set icons
        self.setWindowIcon(QtGui.QIcon(app_info.app_icon_path))

        # check if setup db exists; if yes, ask to copy
        has_setup = SoundSpeedLibrary.setup_exists()
        logger.info("setup exists: %s" % has_setup)
        if not has_setup:
            other_setups = SoundSpeedLibrary.list_other_setups()
            if len(other_setups) != 0:
                logger.debug("other existing setups: %d" % len(other_setups))
                # noinspection PyCallByClass
                sel, ok = QtWidgets.QInputDialog.getItem(self, 'Do you want to copy an existing setup?',
                                                         'Select one (or click on Cancel to create a new one):',
                                                         other_setups, 0, False)
                if ok:
                    SoundSpeedLibrary.copy_setup(input_setup=sel)

        # create the project
        self.lib = SoundSpeedLibrary(callbacks=QtCallbacks(parent=self), progress=QtProgress(parent=self))
        logger.info("current configuration:\n%s" % Helper(lib_info=lib_info).package_info())
        self.check_woa09()
        self.check_woa13()
        # self.check_rtofs()  # no need to wait for the download at the beginning
        self.check_sis4()
        self.check_sis5()
        self.check_sippican()
        self.check_mvp()

        # init default settings
        settings = QtCore.QSettings()
        export_folder = settings.value("export_folder")
        if (export_folder is None) or (not os.path.exists(export_folder)):
            settings.setValue("export_folder", self.lib.data_folder)
        import_folder = settings.value("import_folder")
        if (import_folder is None) or (not os.path.exists(import_folder)):
            settings.setValue("import_folder", self.lib.data_folder)

        # menu

        self.menu = self.menuBar()
        self.file_menu = self.menu.addMenu("File")
        self.edit_menu = self.menu.addMenu("Process")
        self.database_menu = self.menu.addMenu("Database")
        self.monitor_menu = self.menu.addMenu("Monitor")
        self.server_menu = self.menu.addMenu("Server")
        self.setup_menu = self.menu.addMenu("Setup")
        self.help_menu = self.menu.addMenu("Help")

        # make tabs
        self.tabs = QtWidgets.QTabWidget()
        self.setCentralWidget(self.tabs)
        self.tabs.setIconSize(QtCore.QSize(42, 42))
        self.tabs.blockSignals(True)  # during the initialization
        # noinspection PyUnresolvedReferences
        self.tabs.currentChanged.connect(self.on_change)  # changed!
        # editor
        self.tab_editor = Editor(lib=self.lib, main_win=self)
        self.idx_editor = self.tabs.insertTab(0, self.tab_editor,
                                              QtGui.QIcon(os.path.join(app_info.app_media_path, 'editor.png')), "")
        self.tabs.setTabToolTip(self.idx_editor, "Editor")
        # database
        self.tab_database = Database(lib=self.lib, main_win=self)
        self.idx_database = self.tabs.insertTab(1, self.tab_database,
                                                QtGui.QIcon(os.path.join(app_info.app_media_path, 'database.png')), "")
        self.tabs.setTabToolTip(self.idx_database, "Database")
        # survey data monitor
        self.has_sdm_support = True
        try:  # try.. except to make SSM working also without SDM
            # noinspection PyUnresolvedReferences
            from hyo2.surveydatamonitor.app.widgets.monitor import SurveyDataMonitor
            self.tab_monitor = SurveyDataMonitor(lib=self.lib, main_win=self)
            self.idx_monitor = self.tabs.insertTab(3, self.tab_monitor,
                                                   QtGui.QIcon(
                                                       os.path.join(app_info.app_media_path, 'surveydatamonitor.png')),
                                                   "")
            self.tabs.setTabToolTip(self.idx_monitor, "Survey Data Monitor")
            logger.info("Support for Survey Monitor: ON")
        except Exception as e:
            traceback.print_exc()
            self.has_sdm_support = False
            logger.info("Support for Survey Monitor: OFF(%s)" % e)
        # server
        self.tab_server = Server(lib=self.lib, main_win=self)
        self.idx_server = self.tabs.insertTab(4, self.tab_server,
                                              QtGui.QIcon(os.path.join(app_info.app_media_path, 'server.png')), "")
        self.tabs.setTabToolTip(self.idx_server, "Synthetic Profile Server")

        # refraction
        # self.tab_refraction = Refraction(lib=self.lib, main_win=self)
        # idx = self.tabs.insertTab(5, self.tab_refraction,
        #                           QtGui.QIcon(os.path.join(app_info.app_media_path, 'refraction.png')), "")
        # self.tabs.setTabToolTip(idx, "Refraction Monitor")
        # setup
        self.tab_setup = Settings(lib=self.lib, main_win=self)
        self.idx_setup = self.tabs.insertTab(6, self.tab_setup,
                                             QtGui.QIcon(os.path.join(app_info.app_media_path, 'settings.png')), "")
        self.tabs.setTabToolTip(self.idx_setup, "Setup")
        # info
        self.tab_info = InfoTab(main_win=self, lib_info=lib_info, app_info=app_info,
                                with_online_manual=True,
                                with_offline_manual=True,
                                with_bug_report=True,
                                with_hydroffice_link=True,
                                with_ccom_link=True,
                                with_noaa_link=True,
                                with_unh_link=True,
                                with_license=True)
        self.idx_info = self.tabs.insertTab(6, self.tab_info,
                                            QtGui.QIcon(os.path.join(app_info.app_media_path, 'info.png')), "")
        self.tabs.setTabToolTip(self.idx_info, "Info")
        # Help menu
        self.help_menu.addAction(self.tab_info.open_online_manual_action)
        self.help_menu.addAction(self.tab_info.open_offline_manual_action)
        self.help_menu.addAction(self.tab_info.fill_bug_report_action)
        self.help_menu.addAction(self.tab_info.authors_action)
        self.help_menu.addAction(self.tab_info.show_about_action)

        self.statusBar().setStyleSheet("QStatusBar{color:rgba(0,0,0,128);font-size: 8pt;}")
        self.status_bar_normal_style = self.statusBar().styleSheet()
        self.statusBar().showMessage("%s" % app_info.app_name, 2000)
        self.releaseInfo = QtWidgets.QLabel()
        self.statusBar().addPermanentWidget(self.releaseInfo)
        self.releaseInfo.setStyleSheet("QLabel{color:rgba(0,0,0,128);font-size: 8pt;}")
        timer = QtCore.QTimer(self)
        # noinspection PyUnresolvedReferences
        timer.timeout.connect(self.update_gui)
        timer.start(1500)
        self.timer_execs = 0

        self.data_cleared()
        self.tabs.blockSignals(False)

        logger.info("* > APP: initialized!")

    def on_change(self, i):
        # logger.debug("Current Tab Index: %s" % type(self.tabs.widget(i)))
        if type(self.tabs.widget(i)) == Settings:
            self.tab_setup.setup_changed()

    def switch_to_editor_tab(self):
        if self.tabs.currentIndex() != self.idx_editor:
            self.tabs.setCurrentIndex(self.idx_editor)

    def switch_to_database_tab(self):
        if self.tabs.currentIndex() != self.idx_database:
            self.tabs.setCurrentIndex(self.idx_database)

    def switch_to_monitor_tab(self):
        if self.tabs.currentIndex() != self.idx_monitor:
            self.tabs.setCurrentIndex(self.idx_monitor)

    def switch_to_server_tab(self):
        if self.tabs.currentIndex() != self.idx_server:
            self.tabs.setCurrentIndex(self.idx_server)

    def switch_to_setup_tab(self):
        if self.tabs.currentIndex() != self.idx_setup:
            self.tabs.setCurrentIndex(self.idx_setup)

    def switch_to_info_tab(self):
        if self.tabs.currentIndex() != self.idx_info:
            self.tabs.setCurrentIndex(self.idx_info)

    def check_woa09(self):
        """ helper function that looks after WOA09 database"""
        if not self.lib.use_woa09():
            logger.debug('WOA09: disabled by settings')
            return

        if self.lib.has_woa09():
            logger.debug('WOA09: enabled')
            return

        msg = 'The WOA09 atlas is required by some advanced application functions.\n\n' \
              'The data set (~120MB) can be retrieved from:\n' \
              '   ftp.ccom.unh.edu/fromccom/hydroffice/woa09.red.zip\n' \
              'then unzipped it into:\n' \
              '   %s\n\n' \
              'Do you want that I perform this operation for you?\n' \
              'Internet connection is required!\n' % self.lib.woa09_folder
        # noinspection PyCallByClass
        ret = QtWidgets.QMessageBox.information(self, "Sound Speed Manager - WOA09 Atlas", msg,
                                                QtWidgets.QMessageBox.Ok | QtWidgets.QMessageBox.No)
        if ret == QtWidgets.QMessageBox.No:
            msg = 'You can also manually install it. The steps are:\n' \
                  ' - download the archive from (anonymous ftp):\n' \
                  '   ftp.ccom.unh.edu/fromccom/hydroffice/woa09.red.zip\n' \
                  ' - unzip the archive into:\n' \
                  '   %s\n' \
                  ' - restart Sound Speed Manager\n' % self.lib.woa09_folder
            # noinspection PyCallByClass
            QtWidgets.QMessageBox.information(self, "Sound Speed Manager - WOA09 Atlas", msg,
                                              QtWidgets.QMessageBox.Ok)
            logger.debug('WOA09: disabled')
            return

        success = self.lib.download_woa09()
        if not success:
            msg = 'Unable to retrieve the WOA09 atlas.\n\n ' \
                  'You may manually install it. The steps are:\n' \
                  ' - download the archive from (anonymous ftp):\n' \
                  '   ftp.ccom.unh.edu/fromccom/hyo/woa09.red.zip\n' \
                  ' - unzip the archive into:\n' \
                  '   %s\n' \
                  ' - restart Sound Speed Manager\n' % self.lib.woa09_folder
            # noinspection PyCallByClass
            QtWidgets.QMessageBox.warning(self, "Sound Speed Manager - WOA09 Atlas", msg,
                                          QtWidgets.QMessageBox.Ok)
            logger.debug('WOA09: disabled')
            return

        logger.debug('WOA09: enabled')

    def check_woa13(self):
        """ helper function that looks after WOA13 database"""
        if not self.lib.use_woa13():
            logger.debug('WOA13: disabled by settings')
            return

        if self.lib.has_woa13():
            logger.debug('WOA13: enabled')
            return

        msg = 'The WOA13 atlas is required by some advanced application functions.\n\n' \
              'The data set (~4GB) can be retrieved from:\n' \
              '   ftp.ccom.unh.edu/fromccom/hydroffice/woa13_temp.red.zip\n' \
              '   ftp.ccom.unh.edu/fromccom/hydroffice/woa13_sal.red.zip\n' \
              'then unzipped it into:\n' \
              '   %s\n\n' \
              'Do you want that I perform this operation for you?\n' \
              'Internet connection is required!\n' % self.lib.woa13_folder
        # noinspection PyCallByClass
        ret = QtWidgets.QMessageBox.information(self, "Sound Speed Manager - WOA13 Atlas", msg,
                                                QtWidgets.QMessageBox.Ok | QtWidgets.QMessageBox.No)
        if ret == QtWidgets.QMessageBox.No:
            msg = 'You can also manually install it. The steps are:\n' \
                  ' - download the archive from (anonymous ftp):\n' \
                  '   ftp.ccom.unh.edu/fromccom/hydroffice/woa13_temp.red.zip\n' \
                  '   ftp.ccom.unh.edu/fromccom/hydroffice/woa13_sal.red.zip\n' \
                  ' - unzip the archive into:\n' \
                  '   %s\n' \
                  ' - restart Sound Speed Manager\n' % self.lib.woa13_folder
            # noinspection PyCallByClass
            QtWidgets.QMessageBox.information(self, "Sound Speed Manager - WOA13 Atlas", msg,
                                              QtWidgets.QMessageBox.Ok)
            logger.debug('WOA13: disabled')
            return

        success = self.lib.download_woa13()
        if not success:
            msg = 'Unable to retrieve the WOA13 atlas.\n\n ' \
                  'You may manually install it. The steps are:\n' \
                  ' - download the archive from (anonymous ftp):\n' \
                  '   ftp.ccom.unh.edu/fromccom/hyo/woa13_temp.red.zip\n' \
                  '   ftp.ccom.unh.edu/fromccom/hyo/woa13_sal.red.zip\n' \
                  ' - unzip the archive into:\n' \
                  '   %s\n' \
                  ' - restart Sound Speed Manager\n' % self.lib.woa13_folder
            # noinspection PyCallByClass
            QtWidgets.QMessageBox.warning(self, "Sound Speed Manager - WOA13 Atlas", msg,
                                          QtWidgets.QMessageBox.Ok)
            logger.debug('WOA13: disabled')
            return

        logger.debug('WOA13: enabled')

    def check_rtofs(self):
        """ helper function that looks after RTOFS connection"""
        if not self.lib.use_rtofs():
            logger.debug('RTOFS: disabled by settings')
            return

        if self.lib.has_rtofs():
            logger.debug('RTOFS: enabled')
            return

        success = self.lib.download_rtofs()
        if not success:
            msg = 'Unable to retrieve the RTOFS atlas.\n\n ' \
                  'The application needs an internet connection to access\n' \
                  'this server (with port 9090 open):\n' \
                  ' - http://nomads.ncep.noaa.gov:9090\n\n' \
                  'You can disable the RTOFS support in Settings/Basic/Use RTOFS.\n'
            # noinspection PyCallByClass
            QtWidgets.QMessageBox.warning(self, "Sound Speed Manager - RTOFS Atlas", msg,
                                          QtWidgets.QMessageBox.Ok)
            logger.debug('RTOFS: disabled')
            return

        logger.debug('RTOFS: enabled')

    def check_sis4(self):
        if self.lib.use_sis4():
            if not self.lib.listen_sis4():
                msg = 'Unable to listen SIS4.'
                # noinspection PyCallByClass
                QtWidgets.QMessageBox.warning(self, "Sound Speed Manager - SIS4", msg,
                                              QtWidgets.QMessageBox.Ok)
        else:
            if not self.lib.stop_listen_sis4():
                msg = 'Unable to stop listening SIS.'
                # noinspection PyCallByClass
                QtWidgets.QMessageBox.warning(self, "Sound Speed Manager - SIS4", msg,
                                              QtWidgets.QMessageBox.Ok)

    def check_sis5(self):
        if self.lib.use_sis5():
            if not self.lib.listen_sis5():
                msg = 'Unable to listen SIS5.'
                # noinspection PyCallByClass
                QtWidgets.QMessageBox.warning(self, "Sound Speed Manager - SIS5", msg,
                                              QtWidgets.QMessageBox.Ok)
        else:
            if not self.lib.stop_listen_sis5():
                msg = 'Unable to stop listening SIS5.'
                # noinspection PyCallByClass
                QtWidgets.QMessageBox.warning(self, "Sound Speed Manager - SIS5", msg,
                                              QtWidgets.QMessageBox.Ok)

    def check_sippican(self):
        if self.lib.use_sippican():
            if not self.lib.listen_sippican():
                msg = 'Unable to listening Sippican.'
                # noinspection PyCallByClass
                QtWidgets.QMessageBox.warning(self, "Sound Speed Manager - Sippican", msg,
                                              QtWidgets.QMessageBox.Ok)
        else:
            if not self.lib.stop_listen_sippican():
                msg = 'Unable to stop listening Sippican.'
                # noinspection PyCallByClass
                QtWidgets.QMessageBox.warning(self, "Sound Speed Manager - Sippican", msg,
                                              QtWidgets.QMessageBox.Ok)

    def check_mvp(self):
        if self.lib.use_mvp():
            if not self.lib.listen_mvp():
                msg = 'Unable to listening MVP.'
                # noinspection PyCallByClass
                QtWidgets.QMessageBox.warning(self, "Sound Speed Manager - MVP", msg,
                                              QtWidgets.QMessageBox.Ok)
        else:
            if not self.lib.stop_listen_mvp():
                msg = 'Unable to stop listening MVP.'
                # noinspection PyCallByClass
                QtWidgets.QMessageBox.warning(self, "Sound Speed Manager - MVP", msg,
                                              QtWidgets.QMessageBox.Ok)

    def data_cleared(self):
        self.tab_editor.data_cleared()
        self.tab_database.data_cleared()
        self.tab_server.data_cleared()
        # self.tab_refraction.data_cleared()
        self.tab_setup.data_cleared()

    def data_imported(self):
        self.tab_editor.data_imported()
        self.tab_database.data_imported()
        self.tab_server.data_imported()
        # self.tab_refraction.data_imported()
        self.tab_setup.data_imported()

    def data_stored(self):
        self.tab_editor.data_stored()
        self.tab_database.data_stored()
        self.tab_server.data_stored()
        # self.tab_refraction.data_stored()
        self.tab_setup.data_stored()

    def data_removed(self):
        self.tab_editor.data_removed()
        self.tab_database.data_removed()
        self.tab_server.data_removed()
        # self.tab_refraction.data_removed()
        self.tab_setup.data_removed()

    def server_started(self):
        # clear widgets as for data clear
        self.data_cleared()

        self.tab_editor.server_started()
        self.tab_database.server_started()
        self.tab_server.server_started()
        # self.tab_refraction.server_started()
        self.tab_setup.server_started()
        self.statusBar().setStyleSheet("QStatusBar{color:rgba(0,0,0,128);"
                                       "font-size: 8pt;background-color:rgba(51,204,255,128);}")

    def server_stopped(self):
        self.tab_editor.server_stopped()
        self.tab_database.server_stopped()
        self.tab_server.server_stopped()
        # self.tab_refraction.server_stopped()
        self.tab_setup.server_stopped()
        self.statusBar().setStyleSheet(self.status_bar_normal_style)

    def _check_latest_release(self):

        new_release = False
        new_bugfix = False
        latest_version = None
        try:
            response = urlopen('http://www.hydroffice.org/latest/soundspeedmanager.txt', timeout=2)
            latest_version = response.read().split()[0].decode()

            cur_maj, cur_min, cur_fix = app_info.app_version.split('.')
            lat_maj, lat_min, lat_fix = latest_version.split('.')

            if int(lat_maj) > int(cur_maj):
                new_release = True

            elif (int(lat_maj) == int(cur_maj)) and (int(lat_min) > int(cur_min)):
                new_release = True

            elif (int(lat_maj) == int(cur_maj)) and (int(lat_min) == int(cur_min)) and (int(lat_fix) > int(cur_fix)):
                new_bugfix = True

        except (URLError, ssl.SSLError, socket.timeout, ConnectionResetError, ValueError) as e:
            logger.info("unable to check latest release (reason: %s)" % e)

        if new_release:
            logger.info("new release available: %s" % latest_version)
            self.releaseInfo.setText("New release available: %s" % latest_version)
            self.releaseInfo.setStyleSheet("QLabel{background-color:rgba(255,0,0,128);"
                                           "color:rgba(0,0,0,128);"
                                           "font-size: 8pt;}")

        elif new_bugfix:
            logger.info("new bugfix available: %s" % latest_version)
            self.releaseInfo.setText("New bugfix available: %s" % latest_version)
            self.releaseInfo.setStyleSheet("QLabel{background-color:rgba(255,255,0,128);"
                                           "color:rgba(0,0,0,128);"
                                           "font-size: 8pt;}")

    def update_gui(self):

        if self.timer_execs % 200 == 0:
            # logger.debug("timer executions: %d" % self.timer_execs)
            self._check_latest_release()

        self.timer_execs += 1

        # if self.lib.setup.noaa_tools:
        #     self.tab_seacat.setEnabled(True)
        # else:
        #     self.tab_seacat.setDisabled(True)

        # update the windows title
        self.setWindowTitle('%s v.%s [project: %s]' % (self.name, self.version, self.lib.current_project))

        msg = str()

        tokens = list()
        if self.lib.server.is_alive():
            tokens.append("SRV")
        if self.lib.has_ref():
            tokens.append("REF")
        if self.lib.use_rtofs():
            tokens.append("RTF")
        if self.lib.use_gomofs():
            tokens.append("GoM")
        if self.lib.use_woa09():
            tokens.append("W09")
        if self.lib.use_woa13():
            tokens.append("W13")
        if self.lib.use_sippican():
            tokens.append("SIP")
        if self.lib.use_mvp():
            tokens.append("MVP")
        if self.lib.use_sis4():
            tokens.append("SIS4")
        if self.lib.use_sis5():
            tokens.append("SIS5")
        msg += "|".join(tokens)

        if (not self.lib.use_sis4()) and (not self.lib.use_sis5()):  # in case that SIS was disabled
            self.statusBar().showMessage(msg, 1000)
            return

        msg += "  -  "  # add some spacing

        if self.lib.use_sis4():

            if self.lib.listeners.sis4.nav is not None:
                # time stamp
                msg += "time:"
                if self.lib.listeners.sis4.nav.dg_time is not None:
                    msg += "%s, " % (self.lib.listeners.sis4.nav.dg_time.strftime("%H:%M:%S"))

                else:
                    msg += "NA, "

                # position
                msg += "pos:"
                if (self.lib.listeners.sis4.nav.latitude is not None) and \
                        (self.lib.listeners.sis4.nav.longitude is not None):

                    latitude = self.lib.listeners.sis4.nav.latitude
                    if latitude >= 0:
                        letter = "N"
                    else:
                        letter = "S"
                    lat_min = float(60 * math.fabs(latitude - int(latitude)))
                    lat_str = "%02d\N{DEGREE SIGN}%7.3f'%s" % (int(math.fabs(latitude)), lat_min, letter)

                    longitude = self.lib.listeners.sis4.nav.longitude
                    if longitude < 0:
                        letter = "W"
                    else:
                        letter = "E"
                    lon_min = float(60 * math.fabs(longitude - int(longitude)))
                    lon_str = "%03d\N{DEGREE SIGN}%7.3f'%s" % (int(math.fabs(longitude)), lon_min, letter)

                    msg += "(%s, %s),  " % (lat_str, lon_str)

                else:
                    msg += "(NA, NA),  "

            if self.lib.listeners.sis4.xyz88 is not None:
                msg += 'tss:'
                if self.lib.listeners.sis4.xyz88.sound_speed is not None:
                    msg += '%.1f m/s,  ' % self.lib.listeners.sis4.xyz88.sound_speed

                else:
                    msg += 'NA m/s,  '

                msg += 'avg.depth:'
                mean_depth = self.lib.listeners.sis4.xyz88.mean_depth
                if mean_depth:
                    msg += '%.1f m' % mean_depth
                else:
                    msg += 'NA m'

            else:
                msg += 'XYZ88 NA [pinging?]'

        if self.lib.use_sis5():

            if self.lib.listeners.sis5.spo is not None:
                # time stamp
                msg += "time:"
                if self.lib.listeners.sis5.spo.dg_time is not None:
                    msg += "%s, " % (self.lib.listeners.sis5.spo.dg_time.strftime("%H:%M:%S"))

                else:
                    msg += "NA, "

                # position
                msg += "pos:"
                if (self.lib.listeners.sis5.spo.latitude is not None) and \
                        (self.lib.listeners.sis5.spo.longitude is not None):

                    latitude = self.lib.listeners.sis5.spo.latitude
                    if latitude >= 0:
                        letter = "N"
                    else:
                        letter = "S"
                    lat_min = float(60 * math.fabs(latitude - int(latitude)))
                    lat_str = "%02d\N{DEGREE SIGN}%7.3f'%s" % (int(math.fabs(latitude)), lat_min, letter)

                    longitude = self.lib.listeners.sis5.spo.longitude
                    if longitude < 0:
                        letter = "W"
                    else:
                        letter = "E"
                    lon_min = float(60 * math.fabs(longitude - int(longitude)))
                    lon_str = "%03d\N{DEGREE SIGN}%7.3f'%s" % (int(math.fabs(longitude)), lon_min, letter)

                    msg += "(%s, %s),  " % (lat_str, lon_str)

                else:
                    msg += "(NA, NA),  "

            if self.lib.listeners.sis5.mrz is not None:
                msg += 'tss:'
                if self.lib.listeners.sis5.mrz.tss is not None:
                    msg += '%.1f m/s,  ' % self.lib.listeners.sis5.mrz.tss

                else:
                    msg += 'NA m/s,  '

                msg += 'avg.depth:'
                mean_depth = self.lib.listeners.sis5.mrz.mean_depth
                if mean_depth:
                    msg += '%.1f m' % mean_depth
                else:
                    msg += 'NA m'

            else:
                msg += 'MRZ NA [pinging?]'

        self.statusBar().showMessage(msg, 2000)
        if self.lib.has_ssp():

            if self.lib.server.is_alive():  # server mode
                if not self.tab_server.dataplots.is_drawn:
                    self.tab_server.dataplots.reset()
                    self.tab_server.dataplots.on_first_draw()

                self.tab_server.dataplots.update_data()
                self.tab_server.dataplots.redraw()

            else:  # user mode
                if self.lib.has_mvp_to_process() or self.lib.has_sippican_to_process():
                    # logger.debug("data to import from listeners")
                    # logger.debug("plot drawn: %s" % self.tab_editor.dataplots.is_drawn)
                    if not self.tab_editor.dataplots.is_drawn:
                        self.data_imported()

                    if self.lib.cur.listener_completed and not self.lib.cur.listener_displayed:
                        self.tab_editor.dataplots.on_first_draw()
                        self.lib.cur.listener_displayed = True

                self.tab_editor.dataplots.update_data()
                self.tab_editor.dataplots.redraw()

        if not self.lib.server.is_alive():  # user mode - listeners
            if self.lib.has_mvp_to_process() or self.lib.has_sippican_to_process():
                self.statusBar().setStyleSheet("QStatusBar{color:rgba(0,0,0,128);"
                                               "font-size: 8pt;background-color:rgba(255,163,102,128);}")
            else:
                self.statusBar().setStyleSheet(self.status_bar_normal_style)

    def change_info_url(self, url):
        self.tab_info.change_url(url)

    def exception_hook(self, ex_type: type, ex_value: BaseException, tb: traceback) -> None:
        sys.__excepthook__(ex_type, ex_value, tb)

        # first manage case of not being an exception (e.g., keyboard interrupts)
        if not issubclass(ex_type, Exception):
            msg = str(ex_value)
            if not msg:
                msg = ex_value.__class__.__name__
            logger.info(msg)
            self.close()
            return

        dlg = ExceptionDialog(app_info=app_info, lib_info=lib_info, ex_type=ex_type, ex_value=ex_value, tb=tb)
        ret = dlg.exec_()
        if ret == QtWidgets.QDialog.Rejected:
            if not dlg.user_triggered:
                self.close()
        else:
            logger.warning("ignored exception")

    # Quitting #

    def _do_you_really_want(self, title="Quit", text="quit"):
        """helper function that show to the user a message windows asking to confirm an action"""
        msg_box = QtWidgets.QMessageBox(self)
        msg_box.setWindowTitle(title)
        msg_box.setIconPixmap(QtGui.QPixmap(app_info.app_icon_path).scaled(QtCore.QSize(36, 36)))
        msg_box.setText('Do you really want to %s?' % text)
        msg_box.setStandardButtons(QtWidgets.QMessageBox.Yes | QtWidgets.QMessageBox.No)
        msg_box.setDefaultButton(QtWidgets.QMessageBox.No)
        return msg_box.exec_()

    def closeEvent(self, event):
        """ actions to be done before close the app """
        reply = self._do_you_really_want("Quit", "quit %s" % app_info.app_name)
        # reply = QtWidgets.QMessageBox.Yes
        if reply == QtWidgets.QMessageBox.Yes:
            event.accept()
            self.lib.close()
            if self.has_sdm_support:
                self.tab_monitor.stop_plotting()
            super(MainWin, self).closeEvent(event)
        else:
            event.ignore()

    # -------------------------- development-only --------------------------

    def do(self):
        """ development-mode only helper function """
        pass
Exemplo n.º 21
0
import logging

from hyo2.soundspeedmanager import app_info
from hyo2.soundspeed.soundspeed import SoundSpeedLibrary
from hyo2.abc.lib.logging import set_logging

ns_list = [
    "hyo2.soundspeed", "hyo2.soundspeedmanager", "hyo2.soundspeedsettings"
]
set_logging(ns_list=ns_list)

logger = logging.getLogger(__name__)

# initialize the library
lib = SoundSpeedLibrary()

prj_list = lib.list_projects()
logger.debug("projects: %s" % len(prj_list))
for prj in prj_list:
    logger.debug('- %s' % prj)

lib.current_project = "test2"

ssp_list = lib.db_list_profiles()
logger.debug('profiles in db: %d' % len(ssp_list))

lib.close()
def main():
    # create a project
    lib = SoundSpeedLibrary()

    # set the current project name
    lib.setup.current_project = 'test'
    lib.setup.save_to_db()

    # retrieve all the id profiles from db
    lst = lib.db_list_profiles()
    logger.info("Profiles: %s" % len(lst))

    # plots/maps/exports
    # - map
    lib.map_db_profiles()
    lib.save_map_db_profiles()

    # - aggregate plot
    ssp_times = lib.db_timestamp_list()
    dates = [ssp_times[0][0].date(), ssp_times[-1][0].date()]
    lib.aggregate_plot(dates=dates)
    lib.save_aggregate_plot(dates=dates)

    # - daily plots
    lib.plot_daily_db_profiles()
    lib.save_daily_db_profiles()

    # - exports
    lib.export_db_profiles_metadata(ogr_format=GdalAux.ogr_formats[b'KML'])
    lib.export_db_profiles_metadata(ogr_format=GdalAux.ogr_formats[b'CSV'])
    lib.export_db_profiles_metadata(
        ogr_format=GdalAux.ogr_formats[b'ESRI Shapefile'])

    logger.info('test: *** END ***')
    def test_new_projects(self):

        lib = SoundSpeedLibrary()
        ssp_list = lib.db_list_profiles()
        self.assertGreaterEqual(len(ssp_list), 0)

        lib.current_project = "zzz"
        ssp_list = lib.db_list_profiles()
        self.assertGreaterEqual(len(ssp_list), 0)

        prj_list = lib.list_projects()
        self.assertGreaterEqual(len(prj_list), 2)

        lib.current_project = "aaa"
        lib.remove_project("zzz")
        prj_list = lib.list_projects()
        self.assertGreaterEqual(len(prj_list), 1)

        lib.close()
Exemplo n.º 24
0
import os
import logging

from hyo2.soundspeedmanager import app_info
from hyo2.soundspeed.soundspeed import SoundSpeedLibrary
from hyo2.soundspeed.base.testing import SoundSpeedTesting
from hyo2.soundspeed.base.callbacks.test_callbacks import TestCallbacks

logging.basicConfig(level=logging.DEBUG)
logger = logging.getLogger(__name__)

# create a project with test-callbacks
lib = SoundSpeedLibrary(callbacks=TestCallbacks())

# set the current project name
lib.setup.current_project = 'test'

data_folder = os.path.abspath(
    os.path.join(os.path.dirname(__file__), os.pardir, os.pardir))
testing = SoundSpeedTesting(root_folder=data_folder)

# retrieve data input/output folders
data_input = testing.input_data_folder()
logger.info('input folder: %s' % data_input)
data_output = testing.output_data_folder()
logger.info('output folder: %s' % data_output)

# test readers/writers
logger.info('test: *** START ***')
filters = [
    "valeport",
Exemplo n.º 25
0
import os
import logging
from PySide2 import QtWidgets
from matplotlib import pyplot as plt

from hyo2.soundspeedmanager import app_info
from hyo2.soundspeed.soundspeed import SoundSpeedLibrary
from hyo2.soundspeed.base.testing import SoundSpeedTesting
from hyo2.soundspeed.base.callbacks.test_callbacks import TestCallbacks

logging.basicConfig(level=logging.DEBUG)
logger = logging.getLogger(__name__)

# create a project with test-callbacks
lib = SoundSpeedLibrary(callbacks=TestCallbacks())

# set the current project name
lib.setup.current_project = 'test'

data_folder = os.path.abspath(
    os.path.join(os.path.dirname(__file__), os.pardir, os.pardir))
testing = SoundSpeedTesting(root_folder=data_folder)

# retrieve data input/output folders
data_input = testing.input_data_folder()
logger.info('input folder: %s' % data_input)
data_output = testing.output_data_folder()
logger.info('output folder: %s' % data_output)

# test readers/writers
logger.info('test: *** START ***')
Exemplo n.º 26
0
from hyo2.soundspeedmanager.dialogs.text_editor_dialog import TextEditorDialog
from hyo2.soundspeed.soundspeed import SoundSpeedLibrary

logging.basicConfig(level=logging.DEBUG)
logger = logging.getLogger(__name__)

app = QtWidgets.QApplication([])
# noinspection PyArgumentList
app.setApplicationName('test')
app.setOrganizationName("HydrOffice")
app.setOrganizationDomain("hydroffice.org")

mw = QtWidgets.QMainWindow()
mw.show()

lib = SoundSpeedLibrary()

body = "<pre style='margin:3px;'><b>Test!</b>   #001:            OK</pre>" \
       "<pre style='margin:3px;'><b>Test!</b>   #002:            KO</pre>"

dlg = TextEditorDialog(title="Text",
                       basename="test",
                       body=body,
                       main_win=mw,
                       lib=lib,
                       parent=None)
dlg.exec_()

# app.exec_()
Exemplo n.º 27
0
    def __init__(self):
        QtWidgets.QMainWindow.__init__(self)

        logger.info("* > APP: initializing ...")

        # set the application name and the version
        self.name = app_info.app_name
        self.version = app_info.app_version
        self.setWindowTitle('%s v.%s' % (self.name, self.version))
        # noinspection PyArgumentList
        _app = QtCore.QCoreApplication.instance()
        _app.setApplicationName('%s' % self.name)
        _app.setOrganizationName("HydrOffice")
        _app.setOrganizationDomain("hydroffice.org")

        # set the minimum and the initial size
        self.setMinimumSize(640, 480)
        self.resize(920, 640)

        # set icons
        self.setWindowIcon(QtGui.QIcon(app_info.app_icon_path))

        # check if setup db exists; if yes, ask to copy
        has_setup = SoundSpeedLibrary.setup_exists()
        logger.info("setup exists: %s" % has_setup)
        if not has_setup:
            other_setups = SoundSpeedLibrary.list_other_setups()
            if len(other_setups) != 0:
                logger.debug("other existing setups: %d" % len(other_setups))
                # noinspection PyCallByClass
                sel, ok = QtWidgets.QInputDialog.getItem(self, 'Do you want to copy an existing setup?',
                                                         'Select one (or click on Cancel to create a new one):',
                                                         other_setups, 0, False)
                if ok:
                    SoundSpeedLibrary.copy_setup(input_setup=sel)

        # create the project
        self.lib = SoundSpeedLibrary(callbacks=QtCallbacks(parent=self), progress=QtProgress(parent=self))
        logger.info("current configuration:\n%s" % Helper(lib_info=lib_info).package_info())
        self.check_woa09()
        self.check_woa13()
        # self.check_rtofs()  # no need to wait for the download at the beginning
        self.check_sis4()
        self.check_sis5()
        self.check_sippican()
        self.check_mvp()

        # init default settings
        settings = QtCore.QSettings()
        export_folder = settings.value("export_folder")
        if (export_folder is None) or (not os.path.exists(export_folder)):
            settings.setValue("export_folder", self.lib.data_folder)
        import_folder = settings.value("import_folder")
        if (import_folder is None) or (not os.path.exists(import_folder)):
            settings.setValue("import_folder", self.lib.data_folder)

        # menu

        self.menu = self.menuBar()
        self.file_menu = self.menu.addMenu("File")
        self.edit_menu = self.menu.addMenu("Process")
        self.database_menu = self.menu.addMenu("Database")
        self.monitor_menu = self.menu.addMenu("Monitor")
        self.server_menu = self.menu.addMenu("Server")
        self.setup_menu = self.menu.addMenu("Setup")
        self.help_menu = self.menu.addMenu("Help")

        # make tabs
        self.tabs = QtWidgets.QTabWidget()
        self.setCentralWidget(self.tabs)
        self.tabs.setIconSize(QtCore.QSize(42, 42))
        self.tabs.blockSignals(True)  # during the initialization
        # noinspection PyUnresolvedReferences
        self.tabs.currentChanged.connect(self.on_change)  # changed!
        # editor
        self.tab_editor = Editor(lib=self.lib, main_win=self)
        self.idx_editor = self.tabs.insertTab(0, self.tab_editor,
                                              QtGui.QIcon(os.path.join(app_info.app_media_path, 'editor.png')), "")
        self.tabs.setTabToolTip(self.idx_editor, "Editor")
        # database
        self.tab_database = Database(lib=self.lib, main_win=self)
        self.idx_database = self.tabs.insertTab(1, self.tab_database,
                                                QtGui.QIcon(os.path.join(app_info.app_media_path, 'database.png')), "")
        self.tabs.setTabToolTip(self.idx_database, "Database")
        # survey data monitor
        self.has_sdm_support = True
        try:  # try.. except to make SSM working also without SDM
            # noinspection PyUnresolvedReferences
            from hyo2.surveydatamonitor.app.widgets.monitor import SurveyDataMonitor
            self.tab_monitor = SurveyDataMonitor(lib=self.lib, main_win=self)
            self.idx_monitor = self.tabs.insertTab(3, self.tab_monitor,
                                                   QtGui.QIcon(
                                                       os.path.join(app_info.app_media_path, 'surveydatamonitor.png')),
                                                   "")
            self.tabs.setTabToolTip(self.idx_monitor, "Survey Data Monitor")
            logger.info("Support for Survey Monitor: ON")
        except Exception as e:
            traceback.print_exc()
            self.has_sdm_support = False
            logger.info("Support for Survey Monitor: OFF(%s)" % e)
        # server
        self.tab_server = Server(lib=self.lib, main_win=self)
        self.idx_server = self.tabs.insertTab(4, self.tab_server,
                                              QtGui.QIcon(os.path.join(app_info.app_media_path, 'server.png')), "")
        self.tabs.setTabToolTip(self.idx_server, "Synthetic Profile Server")

        # refraction
        # self.tab_refraction = Refraction(lib=self.lib, main_win=self)
        # idx = self.tabs.insertTab(5, self.tab_refraction,
        #                           QtGui.QIcon(os.path.join(app_info.app_media_path, 'refraction.png')), "")
        # self.tabs.setTabToolTip(idx, "Refraction Monitor")
        # setup
        self.tab_setup = Settings(lib=self.lib, main_win=self)
        self.idx_setup = self.tabs.insertTab(6, self.tab_setup,
                                             QtGui.QIcon(os.path.join(app_info.app_media_path, 'settings.png')), "")
        self.tabs.setTabToolTip(self.idx_setup, "Setup")
        # info
        self.tab_info = InfoTab(main_win=self, lib_info=lib_info, app_info=app_info,
                                with_online_manual=True,
                                with_offline_manual=True,
                                with_bug_report=True,
                                with_hydroffice_link=True,
                                with_ccom_link=True,
                                with_noaa_link=True,
                                with_unh_link=True,
                                with_license=True)
        self.idx_info = self.tabs.insertTab(6, self.tab_info,
                                            QtGui.QIcon(os.path.join(app_info.app_media_path, 'info.png')), "")
        self.tabs.setTabToolTip(self.idx_info, "Info")
        # Help menu
        self.help_menu.addAction(self.tab_info.open_online_manual_action)
        self.help_menu.addAction(self.tab_info.open_offline_manual_action)
        self.help_menu.addAction(self.tab_info.fill_bug_report_action)
        self.help_menu.addAction(self.tab_info.authors_action)
        self.help_menu.addAction(self.tab_info.show_about_action)

        self.statusBar().setStyleSheet("QStatusBar{color:rgba(0,0,0,128);font-size: 8pt;}")
        self.status_bar_normal_style = self.statusBar().styleSheet()
        self.statusBar().showMessage("%s" % app_info.app_name, 2000)
        self.releaseInfo = QtWidgets.QLabel()
        self.statusBar().addPermanentWidget(self.releaseInfo)
        self.releaseInfo.setStyleSheet("QLabel{color:rgba(0,0,0,128);font-size: 8pt;}")
        timer = QtCore.QTimer(self)
        # noinspection PyUnresolvedReferences
        timer.timeout.connect(self.update_gui)
        timer.start(1500)
        self.timer_execs = 0

        self.data_cleared()
        self.tabs.blockSignals(False)

        logger.info("* > APP: initialized!")
    LOOFS = 33  # RG = False
    LSOFS = 34  # RG = False

    # Pacific Coast
    CREOFS = 40  # RG = True     # Format is GoMOFS
    SFBOFS = 41  # RG = True     # Format is GoMOFS


# Choose Model
switch = ModelOptions.CBOFS  # Choose a ModelOptions Value to test

app = QtWidgets.QApplication([])  # PySide stuff (start)
mw = QtWidgets.QMainWindow()
mw.show()

lib = SoundSpeedLibrary(progress=QtProgress(parent=mw),
                        callbacks=QtCallbacks(parent=mw))

# Choose test location
tests = [

    # (-19.1, 74.16, dt.utcnow()),              # Indian Ocean
    # (72.852028, -67.315431, dt.utcnow())      # Baffin Bay
    # (18.2648113, 16.1761115, dt.utcnow()),    # in land -> middle of Africa
    # (39.725989, -104.967745, dt.utcnow())     # in land -> Denver, CO
    (37.985427, -76.311156, dt.utcnow()),  # Chesapeake Bay
    # (39.162802, -75.278057, dt.utcnow()),     # Deleware Bay
    # (43.026480, -70.318824, dt.utcnow()),     # offshore Portsmouth
    # (40.662218, -74.049306, dt.utcnow())      # New York Harbor
    # (30.382518, -81.573615, dt.utcnow())      # Mill Cove, St. Johns River
    # (28.976225, -92.078882, dt. utcnow())     # Offshore Louisiana
    # (27.762904, -82.557280, dt.utcnow())      # Tampa Bay