@@ -452,10 +452,9 @@ def local_exceedance_intensity(
452452 self ,
453453 return_periods = (25 , 50 , 100 , 250 ),
454454 method = 'interpolate' ,
455- intensity_cutoff = None ,
455+ min_intensity = None ,
456456 log_frequeny = True ,
457- log_intensity = True ,
458- extrapolation = True
457+ log_intensity = True
459458 ):
460459 """Compute local exceedance intensity for given return periods. The default method
461460 is fitting the ordered intensitites per centroid to the corresponding cummulated
@@ -467,10 +466,15 @@ def local_exceedance_intensity(
467466 User-specified return periods for which the exceedance intensity should be calculated
468467 locally (at each centroid). Defaults to (25, 50, 100, 250).
469468 method : str
470- Method to interpolate to new return periods. Currently available are "interpolate" and
471- "stepfunction". Defauls to "interpolate".
472- intensity_cutoff : float, optional
473- Minimal threshold to filter the hazard intensity. If set to None, self.intensity_thres
469+ Method to interpolate to new return periods. Currently available are "interpolate",
470+ "extrapolate" and "stepfunction". If set to "interpolate" or "stepfunction", return
471+ periods larger than the Hazard object's observed local return periods will be assigned
472+ the largest local intensity, and return periods smaller than the Hazard object's
473+ observed local return periods will be assigned 0. If set to "extrapolate", local
474+ exceedance intensities will be extrapolated (and interpolated).
475+ Defauls to "interpolate".
476+ min_intensity : float, optional
477+ Minimum threshold to filter the hazard intensity. If set to None, self.intensity_thres
474478 will be used. Defaults to None.
475479 log_frequency : bool, optional
476480 This parameter is only used if method is set to "interpolate". If set to True,
@@ -480,12 +484,6 @@ def local_exceedance_intensity(
480484 This parameter is only used if method is set to "interpolate". If set to True,
481485 intensity values are converted to log scale before inter- and extrapolation.
482486 Defaults to True.
483- extrapolation : bool, optional
484- This parameter is only used if method is set to "interpolate". If set to True, local
485- exceedance intensities will be extrapolated. If set to False, return periods larger than
486- the Hazard object's observed local return periods will be assigned the largest
487- local intensity, and return periods smaller than the Impact object's observed local
488- return periods will be assigned 0. Defaults to True.
489487
490488 Returns
491489 -------
@@ -499,8 +497,8 @@ def local_exceedance_intensity(
499497 column_label : function
500498 Column-label-generating function, for reporting and plotting
501499 """
502- if not intensity_cutoff and intensity_cutoff != 0 :
503- intensity_cutoff = self .intensity_thres
500+ if not min_intensity and min_intensity != 0 :
501+ min_intensity = self .intensity_thres
504502 #check frequency unit
505503 if self .frequency_unit in ['1/year' , 'annual' , '1/y' , '1/a' ]:
506504 return_period_unit = 'years'
@@ -528,16 +526,17 @@ def local_exceedance_intensity(
528526
529527 # fit intensities to cummulative frequencies
530528 frequency = np .cumsum (frequency [::- 1 ])[::- 1 ]
531- if method == 'interpolate' :
532- inten_stats [:,i ] = u_interp .interpolate_ev (
533- 1 / np .array (return_periods ), frequency [::- 1 ], intensity [::- 1 ], logx = log_frequeny ,
534- logy = log_intensity , y_threshold = intensity_cutoff , y_asymptotic = 0. , extrapolation = extrapolation
535- )
536- elif method == 'stepfunction' :
529+ if method == 'stepfunction' :
537530 inten_stats [:,i ] = u_interp .stepfunction_ev (
538- 1 / np .array (return_periods ), frequency [::- 1 ], intensity [::- 1 ], y_threshold = intensity_cutoff ,
531+ 1 / np .array (return_periods ), frequency [::- 1 ], intensity [::- 1 ], y_threshold = min_intensity ,
539532 y_asymptotic = 0.
540533 )
534+ elif method == 'interpolate' or method == 'extrapolate' :
535+ extrapolation = (method == 'extrapolate' )
536+ inten_stats [:,i ] = u_interp .interpolate_ev (
537+ 1 / np .array (return_periods ), frequency [::- 1 ], intensity [::- 1 ], logx = log_frequeny ,
538+ logy = log_intensity , y_threshold = min_intensity , y_asymptotic = 0. , extrapolation = extrapolation
539+ )
541540 else :
542541 raise ValueError (f"Unknown method: { method } " )
543542
@@ -556,8 +555,11 @@ def local_exceedance_intensity(
556555#TODO: note different calculation in changelog
557556 def local_exceedance_inten (self , return_period = (25 , 50 , 100 , 250 )):
558557 """This function is deprecated, use Hazard.local_exceedance_intensity instead."""
559- LOGGER .warning ("The use of Hazard.local_exceedance_inten is deprecated."
560- "Use Hazard.local_exceedance_intensity instead." )
558+ LOGGER .warning (
559+ "The use of Hazard.local_exceedance_inten is deprecated. Use "
560+ "Hazard.local_exceedance_intensity instead. Some errors in the previous calculation "
561+ "in Hazard.local_exceedance_inten have been corrected. To reproduce data with the "
562+ "previous calculation, use CLIMADA v5.0.0 or less." )
561563 return self .local_exceedance_intensity (return_period )[0 ].values [:,1 :].T .astype (float )
562564
563565 def sanitize_event_ids (self ):
@@ -570,8 +572,7 @@ def local_return_period(
570572 self ,
571573 threshold_intensities = (10. , 20. ),
572574 method = 'interpolate' ,
573- intensity_cutoff = None ,
574- extrapolation = False ,
575+ min_intensity = None ,
575576 log_frequency = True ,
576577 log_intensity = True
577578 ):
@@ -585,10 +586,15 @@ def local_return_period(
585586 User-specified hazard intensities for which the return period should be calculated
586587 locally (at each centroid). Defaults to (10, 20)
587588 method : str
588- Method to interpolate to new intensity values. Currently available are "interpolate" and
589- "stepfunction". Defauls to "interpolate".
590- intensity_cutoff : float, optional
591- Minimal threshold to filter the hazard intensity. If set to None, self.intensity_thres
589+ Method to interpolate to new threshold intensities. Currently available are
590+ "interpolate", "extrapolate" and "stepfunction". If set to "interpolate" or
591+ "stepfunction", threshold intensities larger than the Hazard object's local
592+ intensities will be assigned NaN, and threshold intensities smaller than the Hazard
593+ object's local intensities will be assigned the smallest observed local return period.
594+ If set to "extrapolate", local return periods will be extrapolated (and interpolated).
595+ Defaults to "interpolate".
596+ min_intensity : float, optional
597+ Minimum threshold to filter the hazard intensity. If set to None, self.intensity_thres
592598 will be used. Defaults to None.
593599 log_frequency : bool, optional
594600 This parameter is only used if method is set to "interpolate". If set to True,
@@ -598,12 +604,6 @@ def local_return_period(
598604 This parameter is only used if method is set to "interpolate". If set to True,
599605 intensity values are converted to log scale before inter- and extrapolation.
600606 Defaults to True.
601- extrapolation : bool, optional
602- This parameter is only used if method is set to "interpolate". If set to True, local
603- return periods will be extrapolated. If set to False, threshold intensities larger than
604- the Hazard object's local intensities will be assigned NaN, and threshold intensities
605- smaller than the Hazard object's local intensities will be assigned the smallest
606- observed local return period. Defaults to False.
607607
608608 Returns
609609 -------
@@ -617,8 +617,8 @@ def local_return_period(
617617 column_label : function
618618 Column-label-generating function, for reporting and plotting
619619 """
620- if not intensity_cutoff and intensity_cutoff != 0 :
621- intensity_cutoff = self .intensity_thres
620+ if not min_intensity and min_intensity != 0 :
621+ min_intensity = self .intensity_thres
622622 #check frequency unit
623623 if self .frequency_unit in ['1/year' , 'annual' , '1/y' , '1/a' ]:
624624 return_period_unit = 'Years'
@@ -649,14 +649,15 @@ def local_return_period(
649649
650650 # fit intensities to cummulative frequencies
651651 frequency = np .cumsum (frequency [::- 1 ])[::- 1 ]
652- if method == 'interpolate' :
652+ if method == 'stepfunction' :
653+ return_periods [:,i ] = u_interp .stepfunction_ev (
654+ threshold_intensities , intensity , frequency , x_threshold = min_intensity
655+ )
656+ elif method == 'interpolate' or method == "extrapolate" :
657+ extrapolation = (method == "extrapolate" )
653658 return_periods [:,i ] = u_interp .interpolate_ev (
654659 threshold_intensities , intensity , frequency , logx = log_intensity ,
655- logy = log_frequency , x_threshold = intensity_cutoff , extrapolation = extrapolation , y_asymptotic = np .nan
656- )
657- elif method == 'stepfunction' :
658- return_periods [:,i ] = u_interp .stepfunction_ev (
659- threshold_intensities , intensity , frequency , x_threshold = intensity_cutoff
660+ logy = log_frequency , x_threshold = min_intensity , extrapolation = extrapolation , y_asymptotic = np .nan
660661 )
661662 else :
662663 raise ValueError (f"Unknown method: { method } " )
0 commit comments