Skip to content

Commit

Permalink
backend function underscore relativeDistance.py, riverFeatures.py, wi…
Browse files Browse the repository at this point in the history
…dth.py
  • Loading branch information
cyschneck committed Aug 25, 2024
1 parent e44b17b commit 0a450ae
Show file tree
Hide file tree
Showing 9 changed files with 166 additions and 168 deletions.
18 changes: 9 additions & 9 deletions centerline_width/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,20 +42,20 @@
from .riverCenterlineClass import CenterlineWidth

# relativeDistance.py function calls
from .relativeDistance import relativeSingleCoordinate
from .relativeDistance import relativeBankCoordinates
from .relativeDistance import relativeCenterlineCoordinates
from .relativeDistance import relativeRidgeCoordinates
from .relativeDistance import relativeWidthCoordinates
from .relativeDistance import _relative_single_coordinate
from .relativeDistance import _relative_bank_coordinates
from .relativeDistance import _relative_centerline_coordinates
from .relativeDistance import _relative_ridge_coordinates
from .relativeDistance import _relative_width_coordinates

# riverFeatures.py function calls
from .riverFeatures import centerlineLength
from .riverFeatures import calculateRiverArea
from .riverFeatures import calculateSinuosity
from .riverFeatures import _calculate_river_area
from .riverFeatures import _centerline_length
from .riverFeatures import _calculate_sinuosity
from .riverFeatures import incremental_sinuosity

# width.py function calls
from .width import riverWidthFromCenterlineCoordinates
from .width import _width_from_centerline_coordinates
from .width import width

# saveOutput.py function calls
Expand Down
2 changes: 1 addition & 1 deletion centerline_width/centerline.py
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ def _evenly_spaced_centerline(centerline_coordinates: list = None,
return interpolated_centerline_coordinates


def _smoothed_centerline(river_object: centerline_width.CenterlineWidth = None,
def _smoothed_centerline(river_object=None,
centerline_coordinates: list = None,
interprolate_num: int = None) -> list:
# return a list coordinates after applying b-spline (smoothing)
Expand Down
3 changes: 1 addition & 2 deletions centerline_width/channelMigration.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
import centerline_width


def _centerline_migration_rate(start: centerline_width.CenterlineWidth = None,
end: centerline_width.CenterlineWidth = None):
def _centerline_migration_rate(start=None, end=None):
# Calculate the river channel migration through the lateral migration of the centerline
pass
102 changes: 48 additions & 54 deletions centerline_width/error_handling.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,19 +26,18 @@


## Error Handling: plotDiagrams.py
def _error_handling_plot_centerline(
river_object: centerline_width.CenterlineWidth = None,
centerline_type: str = None,
marker_type: str = None,
centerline_color: str = None,
dark_mode: bool = None,
equal_axis: bool = None,
display_all_possible_paths: bool = None,
plot_title: str = None,
save_plot: str = None,
display_voronoi: bool = None,
show_plot: bool = None,
coordinate_unit: str = None) -> None:
def _error_handling_plot_centerline(river_object=None,
centerline_type: str = None,
marker_type: str = None,
centerline_color: str = None,
dark_mode: bool = None,
equal_axis: bool = None,
display_all_possible_paths: bool = None,
plot_title: str = None,
save_plot: str = None,
display_voronoi: bool = None,
show_plot: bool = None,
coordinate_unit: str = None) -> None:

# Error handling for plot_centerline()
if river_object is None:
Expand Down Expand Up @@ -122,20 +121,19 @@ def _error_handling_plot_centerline(


## Error Handling: plotDiagrams.py
def _error_handling_plot_centerline_width(
river_object: centerline_width.CenterlineWidth = None,
plot_title: str = None,
save_plot: str = None,
display_true_centerline: bool = None,
transect_span_distance: int = None,
transect_slope: str = None,
apply_smoothing: bool = None,
flag_intersections: bool = None,
remove_intersections: bool = None,
dark_mode: bool = None,
equal_axis: bool = None,
show_plot: bool = None,
coordinate_unit: str = None):
def _error_handling_plot_centerline_width(river_object=None,
plot_title: str = None,
save_plot: str = None,
display_true_centerline: bool = None,
transect_span_distance: int = None,
transect_slope: str = None,
apply_smoothing: bool = None,
flag_intersections: bool = None,
remove_intersections: bool = None,
dark_mode: bool = None,
equal_axis: bool = None,
show_plot: bool = None,
coordinate_unit: str = None):
# Error handling for plot_centerline_width()
if river_object is None:
raise ValueError(
Expand Down Expand Up @@ -224,15 +222,14 @@ def _error_handling_plot_centerline_width(


## 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:
def _error_handling_width(river_object=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 @@ -310,13 +307,12 @@ def _error_handling_width(


## Error Handling: saveOutput.py
def _error_handling_save_centerline_csv(
river_object: centerline_width.CenterlineWidth = None,
latitude_header: str = None,
longitude_header: str = None,
save_to_csv: str = None,
centerline_type: str = None,
coordinate_unit: str = None) -> None:
def _error_handling_save_centerline_csv(river_object=None,
latitude_header: str = None,
longitude_header: str = None,
save_to_csv: str = None,
centerline_type: str = None,
coordinate_unit: str = None) -> None:
# Error Handling for save_centerline_csv()
if river_object is None:
raise ValueError(
Expand Down Expand Up @@ -374,13 +370,12 @@ def _error_handling_save_centerline_csv(


## Error Handling: saveOutput.py
def _error_handling_save_centerline_mat(
river_object: centerline_width.CenterlineWidth = None,
latitude_header: str = None,
longitude_header: str = None,
save_to_mat: str = None,
centerline_type: str = None,
coordinate_unit: str = None) -> None:
def _error_handling_save_centerline_mat(river_object=None,
latitude_header: str = None,
longitude_header: str = None,
save_to_mat: str = None,
centerline_type: str = None,
coordinate_unit: str = None) -> None:
# Error Handling for save_centerline_mat()
if river_object is None:
raise ValueError(
Expand Down Expand Up @@ -612,10 +607,9 @@ def _error_handling_centerline_width(csv_data: str = None,


## Error Handling: riverFeatures.py
def _error_handling_incremental_sinuosity(
river_object: centerline_width.CenterlineWidth = None,
incremental_points: int = 10,
save_to_csv: str = None) -> None:
def _error_handling_incremental_sinuosity(river_object=None,
incremental_points: int = 10,
save_to_csv: str = None) -> None:
# Error Handling for incremental_sinuosity()
if river_object is None:
raise ValueError(
Expand Down
52 changes: 25 additions & 27 deletions centerline_width/plotDiagrams.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,15 +36,14 @@
logger.addHandler(stream_handler)


def plotCenterlineBackend(
river_object: centerline_width.CenterlineWidth = None,
display_true_centerline: bool = True,
centerline_type: str = "Voronoi",
marker_type: str = "line",
centerline_color: str = "black",
dark_mode: bool = False,
equal_axis: bool = False,
coordinate_unit: str = None):
def plotCenterlineBackend(river_object=None,
display_true_centerline: bool = True,
centerline_type: str = "Voronoi",
marker_type: str = "line",
centerline_color: str = "black",
dark_mode: bool = False,
equal_axis: bool = False,
coordinate_unit: str = None):
# Shared components between plot_centerline() and plotCenterlineWidth
coordinate_unit = coordinate_unit.title()

Expand Down Expand Up @@ -182,7 +181,7 @@ def plotCenterlineBackend(
return fig, ax, valid_path_through


def plot_centerline(river_object: centerline_width.CenterlineWidth = None,
def plot_centerline(river_object=None,
centerline_type: str = "Voronoi",
marker_type: str = "line",
centerline_color: str = "black",
Expand Down Expand Up @@ -284,21 +283,20 @@ def plot_centerline(river_object: centerline_width.CenterlineWidth = None,
if save_plot: fig.savefig(save_plot)


def plot_centerline_width(
river_object: centerline_width.CenterlineWidth = None,
plot_title: str = None,
save_plot_name: str = None,
save_plot: str = None,
display_true_centerline: bool = True,
transect_span_distance: int = 3,
transect_slope: str = "Average",
apply_smoothing: bool = False,
flag_intersections: bool = True,
remove_intersections: bool = False,
dark_mode: bool = False,
equal_axis: bool = False,
show_plot: bool = True,
coordinate_unit: str = "Decimal Degrees") -> None:
def plot_centerline_width(river_object=None,
plot_title: str = None,
save_plot_name: str = None,
save_plot: str = None,
display_true_centerline: bool = True,
transect_span_distance: int = 3,
transect_slope: str = "Average",
apply_smoothing: bool = False,
flag_intersections: bool = True,
remove_intersections: bool = False,
dark_mode: bool = False,
equal_axis: bool = False,
show_plot: bool = True,
coordinate_unit: str = "Decimal Degrees") -> None:
# Plot Width Lines based on Centerline
if save_plot_name is not None and save_plot is None:
warnings.warn(
Expand Down Expand Up @@ -344,7 +342,7 @@ def plot_centerline_width(

# if using smoothing, replace left/right coordinates with the smoothed variation
if apply_smoothing:
right_width_coordinates, left_width_coordinates, num_intersection_coordinates = centerline_width.riverWidthFromCenterlineCoordinates(
right_width_coordinates, left_width_coordinates, num_intersection_coordinates = centerline_width._width_from_centerline_coordinates(
river_object=river_object,
centerline_coordinates=river_object.centerline_smoothed,
transect_span_distance=transect_span_distance,
Expand All @@ -367,7 +365,7 @@ def plot_centerline_width(
s=5)
else:
# recreate the centerline with evenly spaced points
right_width_coordinates, left_width_coordinates, num_intersection_coordinates = centerline_width.riverWidthFromCenterlineCoordinates(
right_width_coordinates, left_width_coordinates, num_intersection_coordinates = centerline_width._width_from_centerline_coordinates(
river_object=river_object,
centerline_coordinates=river_object.
centerline_evenly_spaced,
Expand Down
Loading

0 comments on commit 0a450ae

Please sign in to comment.