def main(): # create a project with test-callbacks lib = SoundSpeedLibrary(callbacks=TestCallbacks()) # set the current project name lib.setup.current_project = 'test' # 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 = [ "aml", ] tests = testing.input_dict_test_files(inclusive_filters=filters) # print(tests) # import each identified file for idx, testfile in enumerate(tests.keys()): logger.debug("filename: %s" % testfile) if idx > 4: # FILE FILTER break logger.info("test: * New profile: #%03d *" % idx) # import lib.import_data(data_path=testfile, data_format=tests[testfile].name) # print(lib.cur) lib.plot_ssp(more=True, show=False) # store the current profile success = lib.store_data() logger.info("stored: %s" % success) from matplotlib import pyplot as plt plt.show() # retrieve all the id profiles from db lst = lib.db_list_profiles() logger.info("Profiles: %s" % len(lst)) for p in lst: logger.info(p) # retrieve a specific profile and delete it ssp_pk = lst[0][0] ssp = lib.db_retrieve_profile(pk=ssp_pk) logger.info("Retrieved profile:\n%s" % ssp) ret = lib.delete_db_profile(pk=ssp_pk) logger.info("Deleted profile: %s" % ret) logger.info('test: *** END ***')
def main(): ftp = Ftp(host="ftp.ccom.unh.edu", password="******", show_progress=True, debug_mode=True) ftp.get_file(file_src="fromccom/hydroffice/Caris_Support_Files_5_5.zip", file_dst=os.path.join(testing.output_data_folder(), "test.zip"))
def setUp(self): self.formats = [ "caris", "csv", "elac", "hypack", "ixblue", "asvp", "qps", "sonardyne", "unb", ] self.data_output = testing.output_data_folder()
def test_use_of_Gdal_aux(self): from hyo.soundspeed.base.testing import output_data_folder aux = GdalAux() for fmt in aux.ogr_formats: # get a driver drv = aux.get_ogr_driver(GdalAux.ogr_formats[fmt]) self.assertEqual(drv.name, fmt) # create a file output_path = os.path.join(output_data_folder(), 'test_gdal_aux') src = aux.create_ogr_data_source(ogr_format=GdalAux.ogr_formats[fmt], output_path=output_path) self.assertNotEqual(src, None)
def main(): print("test data folder: %s" % testing.root_data_folder()) # helper.explore_folder(testing.root_data_folder()) # - input print("test input folder: %s" % testing.input_data_folder()) # helper.explore_folder(testing.input_data_folder()) print("test input sub-folders: %s" % testing.input_data_sub_folders()) print( "test files in input sub-folder: %s" % testing.input_test_files(testing.input_data_sub_folders()[0], '.asvp')) # - download print("test download folder: %s" % testing.download_data_folder()) # helper.explore_folder(testing.download_data_folder()) print("test files in download folder: %s" % testing.download_test_files(".txt")) # - output print("test output folder: %s" % testing.output_data_folder()) # helper.explore_folder(testing.output_data_folder()) # - aux methods print("\npairing readers and folders (no filters):") pair_dict = testing.pair_readers_and_folders( folders=testing.input_data_sub_folders()) for fmt in pair_dict: print("- %s: %s" % (fmt, pair_dict[fmt])) print("\npairing readers and folders (with valeport filter):") filters = [ "valeport", ] pair_dict = testing.pair_readers_and_folders( folders=testing.input_data_sub_folders(), inclusive_filters=filters) for fmt in pair_dict: print("- %s: %s" % (fmt, pair_dict[fmt])) print("\ngetting dict of files and readers:") files_dict = testing.dict_test_files( data_folder=testing.input_data_folder(), pairs=pair_dict) for fid in files_dict: print("- %s: %s" % (fid, files_dict[fid])) print("\ngetting dict of input files and readers:") input_dict = testing.input_dict_test_files() for fid in input_dict: print("- %s: %s" % (fid, input_dict[fid]))
def main(): # create a project with test-callbacks lib = SoundSpeedLibrary(callbacks=TestCallbacks()) # set the current project name lib.setup.current_project = 'test' # 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 = [ "castaway", ] formats = [ "asvp", ] data_outputs = [ data_output, ] tests = testing.input_dict_test_files(inclusive_filters=filters) # print(tests) # import each identified file for idx, testfile in enumerate(tests.keys()): # # just 1 file # if idx != 1: # continue logger.info("test: * New profile: #%03d *" % idx) # import lib.import_data(data_path=testfile, data_format=tests[testfile].name) # replace temp and salinity lib.replace_cur_temp_sal() # export lib.export_data(data_paths=data_outputs, data_formats=formats) logger.info('test: *** END ***')
def main(): # create a project with test-callbacks lib = SoundSpeedLibrary(callbacks=TestCallbacks()) # set the current project name lib.setup.current_project = 'test' # 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", ] formats = ["caris", "csv", "elac", "hypack", "ixblue", "asvp", "qps", "sonardyne", "unb", ] data_outputs = dict() for format in formats: data_outputs[format] = data_output tests = testing.input_dict_test_files(inclusive_filters=filters) # print(tests) # import each identified file for idx, testfile in enumerate(tests.keys()): logger.info("test: * New profile: #%03d *" % idx) # import lib.import_data(data_path=testfile, data_format=tests[testfile].name) # export # lib.export_data(data_path=data_output, data_formats=lib.name_writers) lib.export_data(data_paths=data_outputs, data_formats=formats) logger.info('test: *** END ***')
import os from hyo.soundspeed.logging import test_logging import logging logger = logging.getLogger() from hyo.soundspeed.base.gdal_aux import GdalAux from hyo.soundspeed.base.testing import output_data_folder GdalAux.list_ogr_drivers() aux = GdalAux() for fmt in aux.ogr_formats: drv = aux.get_ogr_driver(ogr_format=aux.ogr_formats[fmt]) out_path = os.path.join(output_data_folder(), "ex_gdal_aux") ds = aux.create_ogr_data_source(ogr_format=aux.ogr_formats[fmt], output_path=out_path)
from hyo.soundspeed.logging.sqlitelogging import SqliteLogging from hyo.soundspeed.base import testing import os from hyo.soundspeed.logging import test_logging import logging logger = logging.getLogger() # create sqlite_log = SqliteLogging(output_folder=testing.output_data_folder()) # activate sqlite_log.activate_user_db() print("- user logging: %s" % sqlite_log.user_active) sqlite_log.activate_server_db() print("- server logging: %s" % sqlite_log.user_active) for i in range(100): logger.debug("test0") logger.info("test1") logger.warning("test2") logger.error("test3") # deactivate sqlite_log.deactivate_user_db() print("- user logging: %s" % sqlite_log.user_active) sqlite_log.deactivate_server_db() print("- server logging: %s" % sqlite_log.user_active)