Skip to content

Commit

Permalink
added functions to check correspondance between depth and uncertainty
Browse files Browse the repository at this point in the history
  • Loading branch information
giumas committed Jul 5, 2024
1 parent 224c7c4 commit 900186b
Show file tree
Hide file tree
Showing 6 changed files with 428 additions and 2 deletions.
50 changes: 50 additions & 0 deletions examples/bag_depth_has_uncertainty.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
import os
import logging

from hyo2.abc2.lib.logging import set_logging
from hyo2.abc2.lib.testing import Testing
from hyo2.abc2.lib.gdal_aux import GdalAux
from hyo2.bag.bag import BAGFile
from hyo2.bag.meta import Meta
from hyo2.qc4.lib.common.writers.s57_writer import S57Writer
from hyo2.qc4.lib.common.writers.kml_writer import KmlWriter
from hyo2.qc4.lib.common.writers.shp_writer import ShpWriter

set_logging(ns_list=['hyo2.bag'])
logger = logging.getLogger(__name__)

# file_bag_0 = os.path.join(Helper.samples_folder(), "bdb_01.bag")
file_bag_0 = r"D:\google_drive\_ccom\QC Tools\data\survey\QC Tools 4\BAG_Checks\depth_without_uncertainty\depth_no_unc.bag"

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

GdalAux.push_gdal_error_handler()
GdalAux.check_gdal_data(verbose=True)

if os.path.exists(file_bag_0):
logger.debug("- file_bag_0: %s" % file_bag_0)

bag_0 = BAGFile(file_bag_0, mode="r")
logger.debug(bag_0)

meta = Meta(bag_0.metadata())

ret = bag_0.depth_has_uncertainty()
logger.debug(ret)

if not ret:
logger.info("No flags")
exit()

s57_bn_path = os.path.join(testing.output_data_folder(), "%s.blue_notes.000" % os.path.basename(file_bag_0))
s57_ss_path = os.path.join(testing.output_data_folder(), "%s.soundings.000" % os.path.basename(file_bag_0))

flags_for_blue_notes = list()
for entry in ret:
flags_for_blue_notes.append([entry[0], entry[1], "%.2f" % entry[2]])

S57Writer.write_bluenotes(feature_list=flags_for_blue_notes, path=s57_bn_path, list_of_list=False)
S57Writer.write_soundings(feature_list=ret, path=s57_ss_path, list_of_list=False)
KmlWriter().write_bluenotes(feature_list=ret, path=s57_ss_path[:-4], list_of_list=False)
ShpWriter().write_bluenotes(feature_list=ret, path=s57_ss_path[:-4], list_of_list=False)
50 changes: 50 additions & 0 deletions examples/bag_uncertainty_has_depth.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
import os
import logging

from hyo2.abc2.lib.logging import set_logging
from hyo2.abc2.lib.testing import Testing
from hyo2.abc2.lib.gdal_aux import GdalAux
from hyo2.bag.bag import BAGFile
from hyo2.bag.meta import Meta
from hyo2.qc4.lib.common.writers.s57_writer import S57Writer
from hyo2.qc4.lib.common.writers.kml_writer import KmlWriter
from hyo2.qc4.lib.common.writers.shp_writer import ShpWriter

set_logging(ns_list=['hyo2.bag'])
logger = logging.getLogger(__name__)

# file_bag_0 = os.path.join(Helper.samples_folder(), "bdb_01.bag")
file_bag_0 = r"D:\google_drive\_ccom\QC Tools\data\survey\QC Tools 4\BAG_Checks\uncertainty_without_depth\unc_no_depth.bag"

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

GdalAux.push_gdal_error_handler()
GdalAux.check_gdal_data(verbose=True)

if os.path.exists(file_bag_0):
logger.debug("- file_bag_0: %s" % file_bag_0)

bag_0 = BAGFile(file_bag_0, mode="r")
logger.debug(bag_0)

meta = Meta(bag_0.metadata())

ret = bag_0.uncertainty_has_depth()
logger.debug(ret)

if not ret:
logger.info("No flags")
exit()

s57_bn_path = os.path.join(testing.output_data_folder(), "%s.blue_notes.000" % os.path.basename(file_bag_0))
s57_ss_path = os.path.join(testing.output_data_folder(), "%s.soundings.000" % os.path.basename(file_bag_0))

flags_for_blue_notes = list()
for entry in ret:
flags_for_blue_notes.append([entry[0], entry[1], "%.2f" % entry[2]])

S57Writer.write_bluenotes(feature_list=flags_for_blue_notes, path=s57_bn_path, list_of_list=False)
S57Writer.write_soundings(feature_list=ret, path=s57_ss_path, list_of_list=False)
KmlWriter().write_bluenotes(feature_list=ret, path=s57_ss_path[:-4], list_of_list=False)
ShpWriter().write_bluenotes(feature_list=ret, path=s57_ss_path[:-4], list_of_list=False)
50 changes: 50 additions & 0 deletions examples/bag_vr_depth_has_uncertainty.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
import os
import logging

from hyo2.abc2.lib.logging import set_logging
from hyo2.abc2.lib.testing import Testing
from hyo2.abc2.lib.gdal_aux import GdalAux
from hyo2.bag.bag import BAGFile
from hyo2.bag.meta import Meta
from hyo2.qc4.lib.common.writers.s57_writer import S57Writer
from hyo2.qc4.lib.common.writers.kml_writer import KmlWriter
from hyo2.qc4.lib.common.writers.shp_writer import ShpWriter

set_logging(ns_list=['hyo2.bag'])
logger = logging.getLogger(__name__)

# file_bag_0 = os.path.join(Helper.samples_folder(), "bdb_01.bag")
file_bag_0 = r"D:\google_drive\_ccom\QC Tools\data\survey\BAG Checks\H13275_MB_VR_MLLW.bag"

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

GdalAux.push_gdal_error_handler()
GdalAux.check_gdal_data(verbose=True)

if os.path.exists(file_bag_0):
logger.debug("- file_bag_0: %s" % file_bag_0)

bag_0 = BAGFile(file_bag_0, mode="r")
logger.debug(bag_0)

meta = Meta(bag_0.metadata())

ret = bag_0.vr_depth_has_uncertainty()
logger.debug(ret)

if not ret:
logger.info("No flags")
exit()

s57_bn_path = os.path.join(testing.output_data_folder(), "%s.blue_notes.000" % os.path.basename(file_bag_0))
s57_ss_path = os.path.join(testing.output_data_folder(), "%s.soundings.000" % os.path.basename(file_bag_0))

flags_for_blue_notes = list()
for entry in ret:
flags_for_blue_notes.append([entry[0], entry[1], "%.2f" % entry[2]])

S57Writer.write_bluenotes(feature_list=flags_for_blue_notes, path=s57_bn_path, list_of_list=False)
S57Writer.write_soundings(feature_list=ret, path=s57_ss_path, list_of_list=False)
KmlWriter().write_bluenotes(feature_list=ret, path=s57_ss_path[:-4], list_of_list=False)
ShpWriter().write_bluenotes(feature_list=ret, path=s57_ss_path[:-4], list_of_list=False)
50 changes: 50 additions & 0 deletions examples/bag_vr_uncertainty_has_depth.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
import os
import logging

from hyo2.abc2.lib.logging import set_logging
from hyo2.abc2.lib.testing import Testing
from hyo2.abc2.lib.gdal_aux import GdalAux
from hyo2.bag.bag import BAGFile
from hyo2.bag.meta import Meta
from hyo2.qc4.lib.common.writers.s57_writer import S57Writer
from hyo2.qc4.lib.common.writers.kml_writer import KmlWriter
from hyo2.qc4.lib.common.writers.shp_writer import ShpWriter

set_logging(ns_list=['hyo2.bag'])
logger = logging.getLogger(__name__)

# file_bag_0 = os.path.join(Helper.samples_folder(), "bdb_01.bag")
file_bag_0 = r"D:\google_drive\_ccom\QC Tools\data\survey\BAG Checks\H13275_MB_VR_MLLW.bag"

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

GdalAux.push_gdal_error_handler()
GdalAux.check_gdal_data(verbose=True)

if os.path.exists(file_bag_0):
logger.debug("- file_bag_0: %s" % file_bag_0)

bag_0 = BAGFile(file_bag_0, mode="r")
logger.debug(bag_0)

meta = Meta(bag_0.metadata())

ret = bag_0.vr_uncertainty_has_depth()
logger.debug(ret)

if not ret:
logger.info("No flags")
exit()

s57_bn_path = os.path.join(testing.output_data_folder(), "%s.blue_notes.000" % os.path.basename(file_bag_0))
s57_ss_path = os.path.join(testing.output_data_folder(), "%s.soundings.000" % os.path.basename(file_bag_0))

flags_for_blue_notes = list()
for entry in ret:
flags_for_blue_notes.append([entry[0], entry[1], "%.2f" % entry[2]])

S57Writer.write_bluenotes(feature_list=flags_for_blue_notes, path=s57_bn_path, list_of_list=False)
S57Writer.write_soundings(feature_list=ret, path=s57_ss_path, list_of_list=False)
KmlWriter().write_bluenotes(feature_list=ret, path=s57_ss_path[:-4], list_of_list=False)
ShpWriter().write_bluenotes(feature_list=ret, path=s57_ss_path[:-4], list_of_list=False)
2 changes: 1 addition & 1 deletion hyo2/bag/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"""

name = 'BAG'
__version__ = '1.2.6'
__version__ = '1.2.7'
__author__ = '[email protected]'
__license__ = 'LGPLv3 license'
__copyright__ = 'Copyright (c) 2024, University of New Hampshire, Center for Coastal and Ocean Mapping'
Loading

0 comments on commit 900186b

Please sign in to comment.