Skip to content

Commit

Permalink
deleted obsolete subfunctions
Browse files Browse the repository at this point in the history
  • Loading branch information
ValentinGebhart committed Aug 26, 2024
1 parent b62af52 commit de81342
Showing 1 changed file with 0 additions and 67 deletions.
67 changes: 0 additions & 67 deletions climada/engine/impact.py
Original file line number Diff line number Diff line change
Expand Up @@ -1478,36 +1478,6 @@ def run(i_time):

return imp_list

#TODO: rewrite and deprecate method
def _loc_return_imp(self, return_periods, imp, exc_imp):
"""Compute local exceedence impact for given return period.
Parameters
----------
return_periods : np.array
return periods to consider
cen_pos :int
centroid position
Returns
-------
np.array
"""
# sorted impacts
sort_pos = np.argsort(imp, axis=0)[::-1, :]
columns = np.ones(imp.shape, int)
# pylint: disable=unsubscriptable-object # pylint/issues/3139
columns *= np.arange(columns.shape[1])
imp_sort = imp[sort_pos, columns]
# cummulative frequency at sorted intensity
freq_sort = self.frequency[sort_pos]
np.cumsum(freq_sort, axis=0, out=freq_sort)

for cen_idx in range(imp.shape[1]):
exc_imp[:, cen_idx] = self._cen_return_imp(
imp_sort[:, cen_idx], freq_sort[:, cen_idx],
0, return_periods)

def _build_exp(self):
return Exposures(
data={
Expand Down Expand Up @@ -1542,43 +1512,6 @@ def _build_exp_event(self, event_id):
meta=None
)

@staticmethod
def _cen_return_imp(imp, freq, imp_th, return_periods):
"""From ordered impact and cummulative frequency at centroid, get
exceedance impact at input return periods.
Parameters
----------
imp : np.array
sorted impact at centroid
freq : np.array
cummulative frequency at centroid
imp_th : float
impact threshold
return_periods : np.array
return periods
Returns
-------
np.array
"""
imp_th = np.asarray(imp > imp_th).squeeze()
imp_cen = imp[imp_th]
freq_cen = freq[imp_th]
if not imp_cen.size:
return np.zeros((return_periods.size,))
try:
with warnings.catch_warnings():
warnings.simplefilter("ignore")
pol_coef = np.polyfit(np.log(freq_cen), imp_cen, deg=1)
except ValueError:
pol_coef = np.polyfit(np.log(freq_cen), imp_cen, deg=0)
imp_fit = np.polyval(pol_coef, np.log(1 / return_periods))
wrong_inten = (return_periods > np.max(1 / freq_cen)) & np.isnan(imp_fit)
imp_fit[wrong_inten] = 0.

return imp_fit

def select(

Check warning on line 1515 in climada/engine/impact.py

View check run for this annotation

Jenkins - WCR / Pylint

too-complex

LOW: 'select' is too complex. The McCabe rating is 12
Raw output
no description found

Check warning on line 1515 in climada/engine/impact.py

View check run for this annotation

Jenkins - WCR / Pylint

too-many-locals

LOW: Too many local variables (16/15)
Raw output
Used when a function or method has too many local variables.

Check warning on line 1515 in climada/engine/impact.py

View check run for this annotation

Jenkins - WCR / Pylint

too-many-branches

LOW: Too many branches (13/12)
Raw output
Used when a function or method has too many branches, making it hard tofollow.
self,
event_ids=None,
Expand Down

0 comments on commit de81342

Please sign in to comment.