Skip to content

Commit

Permalink
run ruff fix
Browse files Browse the repository at this point in the history
  • Loading branch information
slawler committed Jun 27, 2024
1 parent f49c8ec commit 9288d5b
Show file tree
Hide file tree
Showing 11 changed files with 113 additions and 96 deletions.
3 changes: 2 additions & 1 deletion ripple/conflate/rasfim.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,8 @@ class RasFimConflater:
load_data (bool, optional): Load the data on initialization. Defaults to True.
bucket (str, optional): S3 bucket to read data from. Defaults to "fim".
Raises:
Raises
------
ValueError: Required layer not found in the GeoPackage
DriverError: Unable to read the GeoPackage
"""
Expand Down
46 changes: 23 additions & 23 deletions ripple/errors.py
Original file line number Diff line number Diff line change
@@ -1,90 +1,90 @@
class ProjectionNotFoundError(Exception):
pass
class ProjectionNotFoundError(Exception): # noqa: D100
"""TODO."""


class NoDefaultEPSGError(Exception):
pass
"""TODO."""


class ModelNotFoundError(Exception):
pass
"""TODO."""


class NotGeoreferencedError(Exception):
pass
"""TODO."""


class CouldNotIdentifyPrimaryPlanError(Exception):
pass
"""TODO."""


class NoFlowFileSpecifiedError(Exception):
pass
"""TODO."""


class NoGeometryFileSpecifiedError(Exception):
pass
"""TODO."""


class NotAPrjFile(Exception):
pass
"""TODO."""


class NoCRSInferredError(Exception):
pass
"""TODO."""


class UnkownCRSUnitsError(Exception):
pass
"""TODO."""


class HECRASVersionNotInstalledError(Exception):
pass
"""TODO."""


class NoRiverLayerError(Exception):
pass
"""TODO."""


class NoCrossSectionLayerError(Exception):
pass
"""TODO."""


class FlowTitleAlreadyExistsError(Exception):
pass
"""TODO."""


class PlanTitleAlreadyExistsError(Exception):
pass
"""TODO."""


class CouldNotFindAnyPlansError(Exception):
pass
"""TODO."""


class ToManyPlansError(Exception):
pass
"""TODO."""


class RASComputeTimeoutError(Exception):
"""Raised on timeout of API call to Compute_CurrentPlan."""


class RASComputeError(Exception):
"""Raised when *.pNN.computeMsgs.txt indicates error"""
"""Raised when *.pNN.computeMsgs.txt indicates error."""


class RASComputeMeshError(Exception):
"""Raised when *.pNN.computeMsgs.txt indicates mesh-specific error"""
"""Raised when *.pNN.computeMsgs.txt indicates mesh-specific error."""


class RASGeometryError(Exception):
"""Raised when *.pNN.computeMsgs.txt indicates geometry-specific error"""
"""Raised when *.pNN.computeMsgs.txt indicates geometry-specific error."""


class RASStoreAllMapsError(Exception):
"""Raised when *.pNN.computeMsgs.txt indicates StoreAllMaps error (related to RAS Mapper postprocessing)"""
"""Raised when *.pNN.computeMsgs.txt indicates StoreAllMaps error (related to RAS Mapper postprocessing)."""


class DepthGridNotFoundError(Exception):
"""Raised when a depth grid is not found when clipping raw RAS output"""
"""Raised when a depth grid is not found when clipping raw RAS output."""
1 change: 0 additions & 1 deletion ripple/ops/create_ras_terrain.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ def write_projection_file(crs: CRS, terrain_directory: str):

def main(output_terrain_hdf_filepath: str, gpkg_path: str, conflation_parameters: dict):
"""Requires Windows with geospatial libs, so typically run using OSGeo4W shell."""

if conflation_parameters["us_xs"]["xs_id"] == "-9999":
print(f"skipping {nwm_id}; no cross sections conflated.")
else:
Expand Down
1 change: 0 additions & 1 deletion ripple/ops/subset_gpkg.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ def new_gpkg(
"""
Using ripple conflation data, creates a new GPKG from an existing ras geopackage
"""

if ripple_parameters["us_xs"]["xs_id"] == "-9999":
ripple_parameters["messages"] = f"skipping {nwm_id}; no cross sections conflated."
print(ripple_parameters["messages"])
Expand Down
4 changes: 2 additions & 2 deletions ripple/process.py
Original file line number Diff line number Diff line change
Expand Up @@ -246,10 +246,10 @@ def create_flow_depth_combinations(
of the downstream cross section of the reach
min_depths (pd.Series): minimum depth to be included. (typically derived from a previous noraml depth run)
Returns:
Returns
-------
tuple: tuple of depths, flows, and wses
"""

depths, flows, wses = [], [], []
for wse, depth in zip(ds_wses, ds_depths):

Expand Down
30 changes: 14 additions & 16 deletions ripple/ras.py
Original file line number Diff line number Diff line change
Expand Up @@ -323,7 +323,6 @@ def run_sim(
close_ras (bool, optional): boolean to close RAS or not after computing. Defaults to True.
show_ras (bool, optional): boolean to show RAS or not when computing. Defaults to True.
"""

compute_message_file = self.ras_project._ras_root_path + f"{self.plan.file_extension}.computeMsgs.txt"

RC = win32com.client.Dispatch(f"RAS{self.version}.HECRASCONTROLLER")
Expand Down Expand Up @@ -429,7 +428,6 @@ def update_rasmapper_for_mapping(self):
"""
Write a rasmapper file to output depth grids for the current plan
"""

# manage rasmapper
map_file = f"{self.ras_project._ras_root_path}.rasmap"

Expand Down Expand Up @@ -694,10 +692,10 @@ def new_plan_contents(self, title: str, short_id: str, flow, geom, run_rasmapper
"""
populate the content of the plan with basic attributes (title, short_id, flow, and geom)
Raises:
Raises
------
RuntimeError: raise run time error if the plan already has content associated with it
"""

if self.contents:
raise RuntimeError(f"content already exists for this plan: {self._ras_text_file_path}")

Expand Down Expand Up @@ -729,13 +727,14 @@ def read_rating_curves(self) -> dict:
"""
Read the flow and water surface elevations resulting from the computed plan
Raises:
Raises
------
FileNotFoundError: _description_
Returns:
Returns
-------
dict: A dictionary containing "wse" and "flow" keys whose values are pandas dataframes
"""

# check if the hdf file exists; raise error if it does not
if not self.hdf_file:
self.hdf_file = self.text_file + ".hdf"
Expand Down Expand Up @@ -976,7 +975,8 @@ def write_headers(self, title: str, profile_names: list[str]):
title (str): title of the flow
profile_names (list[str]): profile names for the flow
Returns:
Returns
-------
list (list[str]): lines of the flow content
"""
lines = [
Expand All @@ -996,7 +996,6 @@ def write_discharges(self, flows: list, river: str, reach: str, river_station: f
reach (str): Ras reach
river_station (float): Ras river station
"""

lines = []
lines.append(f"River Rch & RM={river},{reach.ljust(16,' ')},{str(river_station).ljust(8,' ')}")
line = ""
Expand Down Expand Up @@ -1113,7 +1112,8 @@ def read_contents(self):
"""
Read contents of the file. Searches for the file locally and on s3.
Raises:
Raises
------
FileNotFoundError:
"""
if os.path.exists(self.text_file):
Expand All @@ -1140,10 +1140,10 @@ def update_crs(self, projection_file: str):
Args:
projection_file (str): path to projeciton file containing the coordinate system (.prj)
Raises:
Raises
------
FileNotFoundError:
"""

directory = os.path.dirname(self.text_file)
crs_base = os.path.basename(projection_file)

Expand All @@ -1167,7 +1167,6 @@ def add_result_layers(self, plan_short_id: str, profiles: list[str], variable: s
profiles (list[str]): Profiles for the output raster(s)
variable (str): Variable to create rasters for. Currently "Depth" is the only supported variable.
"""

if variable not in ["Depth"]:
raise NotImplementedError(
f"Variable {variable} not currently implemented. Currently only Depth is supported."
Expand Down Expand Up @@ -1218,7 +1217,6 @@ def add_terrain(self, terrain_name: str, terrain_path: str):
"""
Add Terrain to RasMap content
"""

lines = []
for line in self.contents.splitlines():

Expand All @@ -1235,7 +1233,6 @@ def write(self):
"""
write Ras Map contents to file
"""

logging.info(f"writing: {self.text_file}")

with open(self.text_file, "w") as f:
Expand Down Expand Up @@ -1277,7 +1274,8 @@ def get_new_extension_number(dict_of_ras_subclasses: dict) -> str:
dict_of_ras_subclasses (dict): A dictionary containing plan/geom/flow titles as keys
and objects plan/geom/flow as values.
Returns:
Returns
-------
new file extension (str): The new file exension.
"""
extension_number = []
Expand Down
1 change: 0 additions & 1 deletion ripple/stacio/fim_collection.py
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,6 @@ def add_ripple_params(
TODO: Placeholder function for adding ripple-params to FIM collection items.
This assumes the conflation output is in the same directory as the `project-file` asset
"""

if asset_role != "project-file":
raise NotImplementedError("Only project-file is supported at this time.")

Expand Down
Loading

0 comments on commit 9288d5b

Please sign in to comment.