-
Notifications
You must be signed in to change notification settings - Fork 161
Remove intensity_thres attribute from Hazard class #1065
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 5 commits
08cfe7b
4f21ae0
658d5ec
6f0969d
c61b780
de7fc0d
b0189ba
cf1a5c4
3468a7e
2eb02af
9470b83
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -57,6 +57,12 @@ | |
| N_PROB_EVENTS = 5 * 6 | ||
| """Number of events per historic event in probabilistic dataset""" | ||
|
|
||
| DEF_INTENSITY_THRES = 14.7 | ||
| """ | ||
| Default value for the threshold below which wind speeds (in m/s) are stored as 0. | ||
| Same as used by WISC SSI calculations. | ||
| """ | ||
|
|
||
|
|
||
| class StormEurope(Hazard): | ||
| """A hazard set containing european winter storm events. Historic storm | ||
|
|
@@ -81,8 +87,8 @@ | |
| SSI as set by set_ssi; uses the Dawkins definition by default. | ||
| """ | ||
|
|
||
| intensity_thres = 14.7 | ||
| """Intensity threshold for storage in m/s; same as used by WISC SSI calculations.""" | ||
| intensity_thres = DEF_INTENSITY_THRES | ||
| """Intensity threshold for storage in m/s.""" | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sorry for the late extra comment, but is the class attribute then still needed? It looks like the intensity_thresh is now a parameter of all relevant methods no?
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, Does this make sense? If there is a smarter implementation, happy to change this.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It makes sense, although I am not sure the current implementation is doing what you want. The code now has an class attribute, but actually never uses it, since the value of this attribute is always passed as parameter to all relevant methods. Thus, the class attribute seems redundant to me. What do you think?
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, almost agree. There is one place in It looks to me as if we can remove these uses and then also remove the class attributes. I have to think about the
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. How about we add the parameter to the methods
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I removed the class attribute from Let me know what you think, for me this looks good. |
||
|
|
||
| vars_opt = Hazard.vars_opt.union({"ssi_wisc", "ssi", "ssi_full_area"}) | ||
| """Name of the variables that aren't need to compute the impact.""" | ||
|
|
@@ -139,7 +145,7 @@ | |
| centroids=None, | ||
| files_omit="fp_era20c_1990012515_701_0.nc", | ||
| combine_threshold=None, | ||
| intensity_thres=None, | ||
| intensity_thres=DEF_INTENSITY_THRES, | ||
| ): | ||
| """Create new StormEurope object from WISC footprints. | ||
|
|
||
|
|
@@ -171,18 +177,15 @@ | |
| events are combined into one. | ||
| Default is None, Advised for WISC is 2 | ||
| intensity_thres : float, optional | ||
| Intensity threshold for storage in m/s. Default: class attribute | ||
| StormEurope.intensity_thres (same as used by WISC SSI calculations) | ||
| Intensity threshold for storage in m/s. Default: 14.7 | ||
| (same as used by WISC SSI calculations) | ||
|
|
||
| Returns | ||
| ------- | ||
| haz : StormEurope | ||
| StormEurope object with data from WISC footprints. | ||
| """ | ||
| # pylint: disable=protected-access | ||
| intensity_thres = ( | ||
| cls.intensity_thres if intensity_thres is None else intensity_thres | ||
| ) | ||
| file_names = get_file_names(path) | ||
|
|
||
| if ref_raster is not None and centroids is not None: | ||
|
|
@@ -300,7 +303,7 @@ | |
| event_date=None, | ||
| model_name="COSMO-2E", | ||
| description=None, | ||
| intensity_thres=None, | ||
| intensity_thres=DEF_INTENSITY_THRES, | ||
| ): | ||
| """Create a new StormEurope object with gust footprint from weather forecast. | ||
|
|
||
|
|
@@ -331,17 +334,14 @@ | |
| description of the events, defaults | ||
| to a combination of model_name and run_datetime | ||
| intensity_thres : float, optional | ||
| Intensity threshold for storage in m/s. Default: class attribute | ||
| StormEurope.intensity_thres (same as used by WISC SSI calculations) | ||
| Intensity threshold for storage in m/s. Default: 14.7 | ||
| (same as used by WISC SSI calculations) | ||
|
|
||
| Returns | ||
| ------- | ||
| haz : StormEurope | ||
| StormEurope object with data from COSMO ensemble file. | ||
| """ | ||
| intensity_thres = ( | ||
| cls.intensity_thres if intensity_thres is None else intensity_thres | ||
| ) | ||
|
|
||
| # read intensity from file | ||
| with xr.open_dataset(fp_file) as ncdf: | ||
|
|
@@ -435,7 +435,7 @@ | |
| description=None, | ||
| grib_dir=None, | ||
| delete_raw_data=True, | ||
| intensity_thres=None, | ||
| intensity_thres=DEF_INTENSITY_THRES, | ||
| ): | ||
| """Create new StormEurope object from DWD icon weather forecast footprints. | ||
|
|
||
|
|
@@ -472,20 +472,17 @@ | |
| .grib.bz2 file format should be stored on the computer or | ||
| removed | ||
| intensity_thres : float, optional | ||
| Intensity threshold for storage in m/s. Default: class attribute | ||
| StormEurope.intensity_thres (same as used by WISC SSI calculations) | ||
| Intensity threshold for storage in m/s. Default: 14.7 | ||
| (same as used by WISC SSI calculations) | ||
|
|
||
| Returns | ||
| ------- | ||
| haz : StormEurope | ||
| StormEurope object with data from DWD icon weather forecast footprints. | ||
| """ | ||
| # pylint: disable=protected-access | ||
| intensity_thres = ( | ||
| cls.intensity_thres if intensity_thres is None else intensity_thres | ||
| ) | ||
|
|
||
| if not (run_datetime.hour == 0 or run_datetime.hour == 12): | ||
|
Check warning on line 485 in climada/hazard/storm_europe.py
|
||
| LOGGER.warning( | ||
| "The event definition is inaccuratly implemented " | ||
| "for starting times, which are not 00H or 12H." | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this mean that all sparse data is projected onto a dense matrix? This might lead to problems no?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The calculation of local exceedance intensity is centroid wise, so yes, the sparse matrix is converted to a dense matrix column by column. The min_intensity parameter being zero or positive does not change this.
It might be that a positive min_intensity parameter here would result in larger geodataframes (ie. centroids with only very small intensities would still lead to a computation and nonzero values, instead of faster handling if all intensities are considered zero). However, as we do not have a minimum intensity for a general hazard object, I think this should be set to zero per default, and can be adapted by the user if wanted.
Does this answer your question?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, thanks!