Skip to content

Commit 09fd55b

Browse files
committed
add from hazard as class method
1 parent 2d15a81 commit 09fd55b

File tree

1 file changed

+19
-18
lines changed

1 file changed

+19
-18
lines changed

climada/hazard/forecast.py

Lines changed: 19 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@
2323

2424
import numpy as np
2525

26-
from climada.engine.forecast import Forecast
2726
from climada.hazard.base import Hazard
27+
from climada.util.forecast import Forecast
2828

2929
LOGGER = logging.getLogger(__name__)
3030

@@ -39,20 +39,21 @@ def __init__(
3939
):
4040
super().__init__(lead_time=lead_time, member=member, **hazard_kwargs)
4141

42-
def from_hazard(self, hazard: Hazard):
43-
return cls(
44-
lead_time=self.lead_time,
45-
member=self.member,
46-
haz_type=hazard.haz_type,
47-
pool=hazard.pool,
48-
units=hazard.units,
49-
centroids=hazard.centroids,
50-
event_id=hazard.event_id,
51-
frequency=hazard.frequency,
52-
frequency_unit=hazard.frequency_unit,
53-
event_name=hazard.event_name,
54-
date=hazard.date,
55-
orig=hazard.orig,
56-
intensity=hazard.intensity,
57-
fraction=hazard.fraction,
58-
)
42+
@classmethod
43+
def from_hazard(self, hazard: Hazard):
44+
return cls(
45+
lead_time=self.lead_time,
46+
member=self.member,
47+
haz_type=hazard.haz_type,
48+
pool=hazard.pool,
49+
units=hazard.units,
50+
centroids=hazard.centroids,
51+
event_id=hazard.event_id,
52+
frequency=hazard.frequency,
53+
frequency_unit=hazard.frequency_unit,
54+
event_name=hazard.event_name,
55+
date=hazard.date,
56+
orig=hazard.orig,
57+
intensity=hazard.intensity,
58+
fraction=hazard.fraction,
59+
)

0 commit comments

Comments
 (0)