From 9adfff7942d92eac877fda6d3c28fad9d3b14c38 Mon Sep 17 00:00:00 2001 From: cyschneck <22159116+cyschneck@users.noreply.github.com> Date: Thu, 22 Aug 2024 23:04:49 -0600 Subject: [PATCH] backend function underscore error_handling.py --- centerline_width/__init__.py | 20 ++++---- centerline_width/channelMigration.py | 4 +- centerline_width/error_handling.py | 61 +++++++++++++----------- centerline_width/getCoordinatesKML.py | 15 +++--- centerline_width/plotDiagrams.py | 4 +- centerline_width/riverCenterlineClass.py | 2 +- centerline_width/riverFeatures.py | 2 +- centerline_width/saveOutput.py | 4 +- centerline_width/width.py | 2 +- 9 files changed, 60 insertions(+), 54 deletions(-) diff --git a/centerline_width/__init__.py b/centerline_width/__init__.py index da91fa0..554e8cb 100644 --- a/centerline_width/__init__.py +++ b/centerline_width/__init__.py @@ -49,15 +49,15 @@ from .plotDiagrams import plot_centerline_width # channelMigration.py function calls -from .channelMigration import centerlineMigrationRate +from .channelMigration import _centerline_migration_rate # error_handling.py function calls -from .error_handling import errrorHandlingTxtToCSV -from .error_handling import errorHandlingPlotCenterline -from .error_handling import errorHandlingPlotCenterlineWidth -from .error_handling import errorHandlingWidth -from .error_handling import errorHandlingSaveCenterlineCSV -from .error_handling import errorHandlingSaveCenterlineMAT -from .error_handling import errorHandlingKmlToCSV -from .error_handling import errorHandlingCenterlineWidth -from .error_handling import errorHandlingIncrementalSinuosity +from .error_handling import _error_handling_plot_centerline +from .error_handling import _error_handling_plot_centerline_width +from .error_handling import _error_handling_width +from .error_handling import _error_handling_save_centerline_csv +from .error_handling import _error_handling_save_centerline_mat +from .error_handling import _errror_handling_txt_to_csv +from .error_handling import _error_handling_kml_to_csv +from .error_handling import _error_handling_centerline_width +from .error_handling import _error_handling_incremental_sinuosity diff --git a/centerline_width/channelMigration.py b/centerline_width/channelMigration.py index 7e3f0be..f5c0df9 100644 --- a/centerline_width/channelMigration.py +++ b/centerline_width/channelMigration.py @@ -17,7 +17,7 @@ import centerline_width -def centerlineMigrationRate(start: centerline_width.CenterlineWidth = None, - end: centerline_width.CenterlineWidth = None): +def _centerline_migration_rate(start: centerline_width.CenterlineWidth = None, + end: centerline_width.CenterlineWidth = None): # Calculate the river channel migration through the lateral migration of the centerline pass diff --git a/centerline_width/error_handling.py b/centerline_width/error_handling.py index 831e974..d25b9de 100644 --- a/centerline_width/error_handling.py +++ b/centerline_width/error_handling.py @@ -26,7 +26,7 @@ ## Error Handling: plotDiagrams.py -def errorHandlingPlotCenterline( +def _error_handling_plot_centerline( river_object: centerline_width.CenterlineWidth = None, centerline_type: str = None, marker_type: str = None, @@ -121,7 +121,8 @@ def errorHandlingPlotCenterline( ) -def errorHandlingPlotCenterlineWidth( +## Error Handling: plotDiagrams.py +def _error_handling_plot_centerline_width( river_object: centerline_width.CenterlineWidth = None, plot_title: str = None, save_plot: str = None, @@ -222,15 +223,16 @@ def errorHandlingPlotCenterlineWidth( ) -## Error Handling: centerline.py -def errorHandlingWidth(river_object: centerline_width.CenterlineWidth = None, - transect_span_distance: int = None, - transect_slope: str = None, - apply_smoothing: bool = None, - remove_intersections: bool = None, - coordinate_unit: str = None, - coordinate_reference: str = None, - save_to_csv: str = None) -> None: +## Error Handling: width.py +def _error_handling_width( + river_object: centerline_width.CenterlineWidth = None, + transect_span_distance: int = None, + transect_slope: str = None, + apply_smoothing: bool = None, + remove_intersections: bool = None, + coordinate_unit: str = None, + coordinate_reference: str = None, + save_to_csv: str = None) -> None: # Error Handling for width() if river_object is None: raise ValueError( @@ -307,7 +309,8 @@ def errorHandlingWidth(river_object: centerline_width.CenterlineWidth = None, ) -def errorHandlingSaveCenterlineCSV( +## Error Handling: saveOutput.py +def _error_handling_save_centerline_csv( river_object: centerline_width.CenterlineWidth = None, latitude_header: str = None, longitude_header: str = None, @@ -370,7 +373,8 @@ def errorHandlingSaveCenterlineCSV( ) -def errorHandlingSaveCenterlineMAT( +## Error Handling: saveOutput.py +def _error_handling_save_centerline_mat( river_object: centerline_width.CenterlineWidth = None, latitude_header: str = None, longitude_header: str = None, @@ -445,8 +449,8 @@ def errorHandlingSaveCenterlineMAT( # Error Handling: getCoordinatesKML.py -def errrorHandlingTxtToCSV(txt_input: str = None, - flip_direction: bool = None) -> None: +def _errror_handling_txt_to_csv(txt_input: str = None, + flip_direction: bool = None) -> None: # Error handling for txt_to_csv() if txt_input is None: raise ValueError("[txt_input]: Requires text file") @@ -467,11 +471,12 @@ def errrorHandlingTxtToCSV(txt_input: str = None, ) -def errorHandlingKmlToCSV(left_kml: str = None, - right_kml: str = None, - flip_direction: bool = None, - csv_output: str = None, - text_output_name: str = None) -> None: +# Error Handling: getCoordinatesKML.py +def _error_handling_kml_to_csv(left_kml: str = None, + right_kml: str = None, + flip_direction: bool = None, + csv_output: str = None, + text_output_name: str = None) -> None: # Error Handling for kml_to_csv() if left_kml is None: raise ValueError("[left_kml]: Requires left_kml file") @@ -536,13 +541,13 @@ def errorHandlingKmlToCSV(left_kml: str = None, ## Error Handling: riverCenterlineClass.py -def errorHandlingCenterlineWidth(csv_data: str = None, - cutoff: int = None, - interpolate_data: bool = None, - interpolate_n: int = None, - interpolate_n_centerpoints: int = None, - equal_distance: [int, float] = None, - ellipsoid: str = None) -> None: +def _error_handling_centerline_width(csv_data: str = None, + cutoff: int = None, + interpolate_data: bool = None, + interpolate_n: int = None, + interpolate_n_centerpoints: int = None, + equal_distance: [int, float] = None, + ellipsoid: str = None) -> None: # Error Handling for CenterlineWidth() if csv_data is None: raise ValueError("[csv_data]: Requires csv_data location") @@ -607,7 +612,7 @@ def errorHandlingCenterlineWidth(csv_data: str = None, ## Error Handling: riverFeatures.py -def errorHandlingIncrementalSinuosity( +def _error_handling_incremental_sinuosity( river_object: centerline_width.CenterlineWidth = None, incremental_points: int = 10, save_to_csv: str = None) -> None: diff --git a/centerline_width/getCoordinatesKML.py b/centerline_width/getCoordinatesKML.py index 7436b95..a444e95 100644 --- a/centerline_width/getCoordinatesKML.py +++ b/centerline_width/getCoordinatesKML.py @@ -66,11 +66,12 @@ def kml_to_csv(left_kml: str = None, ### Pending Deprecated argument "text_output_name" replaced with "csv_output" - centerline_width.errorHandlingKmlToCSV(left_kml=left_kml, - right_kml=right_kml, - flip_direction=flip_direction, - csv_output=csv_output, - text_output_name=text_output_name) + centerline_width._error_handling_kml_to_csv( + left_kml=left_kml, + right_kml=right_kml, + flip_direction=flip_direction, + csv_output=csv_output, + text_output_name=text_output_name) def extractKML(kml_file: str = None) -> (list, list): # extract points from kml file for the given bank @@ -132,8 +133,8 @@ def txt_to_csv(txt_input: str = None, stacklevel=2) txt_input = text_file - centerline_width.errrorHandlingTxtToCSV(txt_input=txt_input, - flip_direction=flip_direction) + centerline_width._errror_handling_txt_to_csv(txt_input=txt_input, + flip_direction=flip_direction) left_rows = [] right_rows = [] diff --git a/centerline_width/plotDiagrams.py b/centerline_width/plotDiagrams.py index 94fb7d0..b1b2095 100644 --- a/centerline_width/plotDiagrams.py +++ b/centerline_width/plotDiagrams.py @@ -203,7 +203,7 @@ def plot_centerline(river_object: centerline_width.CenterlineWidth = None, stacklevel=2) save_plot = save_plot_name - centerline_width.errorHandlingPlotCenterline( + centerline_width._error_handling_plot_centerline( river_object=river_object, centerline_type=centerline_type, marker_type=marker_type, @@ -307,7 +307,7 @@ def plot_centerline_width( stacklevel=2) save_plot = save_plot_name - centerline_width.errorHandlingPlotCenterlineWidth( + centerline_width._error_handling_plot_centerline_width( river_object=river_object, plot_title=plot_title, save_plot=save_plot, diff --git a/centerline_width/riverCenterlineClass.py b/centerline_width/riverCenterlineClass.py index b60fb72..0a29cbb 100644 --- a/centerline_width/riverCenterlineClass.py +++ b/centerline_width/riverCenterlineClass.py @@ -35,7 +35,7 @@ def __init__(self, equal_distance: int = 10, ellipsoid: str = "WGS84"): - centerline_width.errorHandlingCenterlineWidth( + centerline_width._error_handling_centerline_width( csv_data=csv_data, cutoff=cutoff, interpolate_data=interpolate_data, diff --git a/centerline_width/riverFeatures.py b/centerline_width/riverFeatures.py index 5e95e47..d2f007f 100644 --- a/centerline_width/riverFeatures.py +++ b/centerline_width/riverFeatures.py @@ -79,7 +79,7 @@ def incremental_sinuosity( # Return the sinuosity of the river in increments # (Centerline Coordinate Start, Centerline Coordinate End Longtiude, Sinuosity) - centerline_width.errorHandlingIncrementalSinuosity( + centerline_width._error_handling_incremental_sinuosity( river_object=river_object, incremental_points=incremental_points, save_to_csv=save_to_csv) diff --git a/centerline_width/saveOutput.py b/centerline_width/saveOutput.py index 8f18dde..c43e319 100644 --- a/centerline_width/saveOutput.py +++ b/centerline_width/saveOutput.py @@ -40,7 +40,7 @@ def save_centerline_csv(river_object: centerline_width.CenterlineWidth = None, coordinate_unit: str = "Decimal Degrees") -> None: # Save Centerline Coordinates to .CSV - centerline_width.errorHandlingSaveCenterlineCSV( + centerline_width._error_handling_save_centerline_csv( river_object=river_object, save_to_csv=save_to_csv, latitude_header=latitude_header, @@ -103,7 +103,7 @@ def save_centerline_mat(river_object: centerline_width.CenterlineWidth = None, coordinate_unit: str = "Decimal Degrees") -> None: # Save Centerline Coordinates generated by Voronoi Diagram to .MAT - centerline_width.errorHandlingSaveCenterlineMAT( + centerline_width._error_handling_save_centerline_mat( river_object=river_object, save_to_mat=save_to_mat, latitude_header=latitude_header, diff --git a/centerline_width/width.py b/centerline_width/width.py index 925ce99..4fa361f 100644 --- a/centerline_width/width.py +++ b/centerline_width/width.py @@ -336,7 +336,7 @@ def width(river_object: centerline_width.CenterlineWidth = None, # Width is measured to the bank, relative to the center point (normal of the centerline) # { [centerline latitude, centerline longitude] : widthValue } - centerline_width.errorHandlingWidth( + centerline_width._error_handling_width( river_object=river_object, transect_span_distance=transect_span_distance, transect_slope=transect_slope,