Skip to content

Commit

Permalink
instead of saving the name, also save the index in the cyc_db as ther…
Browse files Browse the repository at this point in the history
…e can be duplicate names.
  • Loading branch information
LuukBlom committed Nov 1, 2024
1 parent a4c1736 commit ac15f72
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 8 deletions.
8 changes: 2 additions & 6 deletions flood_adapt/object_model/hazard/event/historical_hurricane.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,12 +80,8 @@ def save_additional(self, toml_path: Path | str | os.PathLike) -> None:

# @gundula is this the correct way to handle this?
# Should we save .cyc AND/ OR .spw files?
ind = (
Database()
.cyclone_track_database.list_names()
.index(self.attrs.track_name)
)
track = Database().cyclone_track_database.get_track(ind)

track = Database().cyclone_track_database.get_track(self.attrs.track_index)
self.write_cyc(Path(toml_path).parent, track)

def make_spw_file(self, event_path: Path, model_dir: Path):
Expand Down
3 changes: 2 additions & 1 deletion flood_adapt/object_model/interface/events.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

import numpy as np
import pandas as pd
from pydantic import BaseModel
from pydantic import BaseModel, Field

from flood_adapt.object_model.interface.object_model import IObject, IObjectModel
from flood_adapt.object_model.interface.path_builder import (
Expand Down Expand Up @@ -205,6 +205,7 @@ class HistoricalHurricaneModel(EventModel):

hurricane_translation: TranslationModel
track_name: str
track_index: int = Field(None, ge=0)


EventModelType = TypeVar("EventModelType", bound=EventModel)
Expand Down
1 change: 0 additions & 1 deletion tests/test_object_model/test_strategies.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,6 @@ def setup_strategy_with_overlapping_measures(test_db, test_data_dir, test_buyout
test_buyout = Buyout(attrs)

measures.append(test_buyout.attrs.name)
print(test_buyout.attrs.polygon_file)
test_db.measures.save(test_buyout)

strategy_model = {
Expand Down

0 comments on commit ac15f72

Please sign in to comment.