Skip to content

Commit

Permalink
backend function underscore error_handling.py
Browse files Browse the repository at this point in the history
  • Loading branch information
cyschneck committed Aug 23, 2024
1 parent ea41689 commit 9adfff7
Show file tree
Hide file tree
Showing 9 changed files with 60 additions and 54 deletions.
20 changes: 10 additions & 10 deletions centerline_width/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
4 changes: 2 additions & 2 deletions centerline_width/channelMigration.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
61 changes: 33 additions & 28 deletions centerline_width/error_handling.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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")
Expand All @@ -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")
Expand Down Expand Up @@ -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")
Expand Down Expand Up @@ -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:
Expand Down
15 changes: 8 additions & 7 deletions centerline_width/getCoordinatesKML.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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 = []
Expand Down
4 changes: 2 additions & 2 deletions centerline_width/plotDiagrams.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion centerline_width/riverCenterlineClass.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion centerline_width/riverFeatures.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions centerline_width/saveOutput.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion centerline_width/width.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit 9adfff7

Please sign in to comment.