Skip to content

Commit

Permalink
remove the exception from the `ExternalForcingConverter._convert_forc…
Browse files Browse the repository at this point in the history
…ing`
  • Loading branch information
MAfarrag committed Feb 10, 2025
1 parent 2a1214d commit 76c015e
Showing 1 changed file with 23 additions and 30 deletions.
53 changes: 23 additions & 30 deletions hydrolib/tools/ext_old_to_new/main_converter.py
Original file line number Diff line number Diff line change
Expand Up @@ -257,39 +257,32 @@ def update(
def _convert_forcing(self, forcing) -> Union[Boundary, Lateral, Meteo, SourceSink]:
"""Convert a single forcing block to the appropriate new format."""

try:
converter_class = ConverterFactory.create_converter(forcing.quantity)
converter_class.root_dir = self.root_dir

# only the SourceSink converter needs the quantities' list
if converter_class.__class__.__name__ == "SourceSinkConverter":

if self.mdu_info is None:
raise ValueError(
"FM model is required to convert SourcesSink quantities."
)
else:
temp_salinity_mdu = self.mdu_info
start_time = self.mdu_info.get("refdate")

quantities = self.extold_model.quantities
new_quantity_block = converter_class.convert(
forcing, quantities, start_time=start_time, **temp_salinity_mdu
converter_class = ConverterFactory.create_converter(forcing.quantity)
converter_class.root_dir = self.root_dir

# only the SourceSink converter needs the quantities' list
if converter_class.__class__.__name__ == "SourceSinkConverter":

if self.mdu_info is None:
raise ValueError(
"FM model is required to convert SourcesSink quantities."
)
elif converter_class.__class__.__name__ == "BoundaryConditionConverter":
if self.mdu_info is None:
raise ValueError(
"FM model is required to convert Boundary conditions."
)
else:
start_time = self.mdu_info.get("refdate")
new_quantity_block = converter_class.convert(forcing, start_time)
else:
new_quantity_block = converter_class.convert(forcing)
temp_salinity_mdu = self.mdu_info
start_time = self.mdu_info.get("refdate")

except ValueError:
# While this tool is in progress, accept that we do not convert all quantities yet.
new_quantity_block = None
quantities = self.extold_model.quantities
new_quantity_block = converter_class.convert(
forcing, quantities, start_time=start_time, **temp_salinity_mdu
)
elif converter_class.__class__.__name__ == "BoundaryConditionConverter":
if self.mdu_info is None:
raise ValueError("FM model is required to convert Boundary conditions.")
else:
start_time = self.mdu_info.get("refdate")
new_quantity_block = converter_class.convert(forcing, start_time)
else:
new_quantity_block = converter_class.convert(forcing)

return new_quantity_block

Expand Down

0 comments on commit 76c015e

Please sign in to comment.