Skip to content

Update init method for storm_europe#562

Merged
emanuel-schmid merged 22 commits intodevelopfrom
feature/init_hazard_storm_europe
Dec 6, 2022
Merged

Update init method for storm_europe#562
emanuel-schmid merged 22 commits intodevelopfrom
feature/init_hazard_storm_europe

Conversation

@zeliest
Copy link
Copy Markdown
Collaborator

@zeliest zeliest commented Oct 26, 2022

Changes proposed in this PR:

  • Update init method for storm_europe

This PR fixes issue #

PR Author Checklist

PR Reviewer Checklist

@zeliest zeliest force-pushed the feature/init_hazard_storm_europe branch from 710278a to 236d533 Compare October 27, 2022 09:44
@chahank chahank requested a review from peanutfun October 28, 2022 11:47
ssi_full_area: Optional[np.ndarray] = None
):
"""Calls the Hazard init dunder. Sets unit to 'm/s'."""
Hazard.__init__(self, HAZ_TYPE)
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

parameter description is missing in pydoc string

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added a bit, but I need some help. I have no idea what the attributes mean and how they are supposed to be shaped 🙈 @chahank @tovogt, maybe you can help?

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't have any experience with this kind of Hazard. From what I see in the code, ssi and ssi_wisc seem to be one dimensional arrays with one entry for each event. But the ssi_full_area attribute seems to be exclusively used for probabilistic events (see my other comment), and I don't know what this has to do with a "full area".

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In order to finalize the docstrings, we will probably need input from somebody who is familiar with this hazard type...

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

True. I hope @mmyrte can help here. 🙏

Copy link
Copy Markdown
Collaborator

@mmyrte mmyrte left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was first going "oh my, this is fancy, passing references to output arrays", but when I saw what I had done further down, it made sense. I'm happy with the changes, thanks!

@tovogt
Copy link
Copy Markdown
Collaborator

tovogt commented Nov 15, 2022

@mmyrte Can you please have a look at the docstring of the __init__ above and suggest better descriptions for the parameters?

The Storm Severity Index (SSI) ???. Shape ``(?? x ??)``. Defaults to an empty
array.
"""
Hazard.__init__(self, haz_type=HAZ_TYPE, units=units, **kwargs)
Copy link
Copy Markdown
Collaborator

@bguillod bguillod Nov 15, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, why not super().__init__ here? There might be a good reason so I'm curious.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No particular reason I guess. super() would be cleaner: you could change the super class by changing the one line of code that declares the class. But I don't expect StormEurope to inherit from anything else then Hazard ever.

@mmyrte
Copy link
Copy Markdown
Collaborator

mmyrte commented Nov 21, 2022

@mmyrte Can you please have a look at the docstring of the __init__ above and suggest better descriptions for the parameters?

@tovogt Sorry, was otherwise occupied. The unit tests indicate that the SSI is a 1d vector of equal length as the number of events. I'll check out the branch and ammend those lines, just a moment.

1d vector, same length as number of storms. Defaults to an empty
array.
ssi_full_area : numpy.ndarray
FIXME need to recover rationale for this attribute; no substantive
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ThomasRoosli do you recall why we had this additional ssi_full_area thing in here? It's only ever used when computing a synthetic event set. I seem to remember that there was a good reason to not set the synthetic SSI to the same attribute name present in the reanalysis/WISC synthetic data. However, I don't remember, and we seem not to have documented it. I propose to simply drop this additional parameter. I would say this PR is as good an occasion as any.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would have to look closer into the code. From my memory: ssi_full_area is needed to conserve the index that is derived from the area and windspeed of the full geographic extend of a storm system. This is importent if a StormEurope object is cropped to a smaller region (e.g. a country).

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ThomasRoosli: thanks for chipping in! In this case I'd be fine to keep the attribute and write just that into the description:

   Used to conserve the the index that is derived from the area and windspeed 
   of the full geographic extend of a storm system. Needed for cropping the 
   `StormEurope` object into a smaller region`

emanuel-schmid and others added 2 commits November 22, 2022 16:41
* Instantiate StormEurope objects with full signature where possible.
* Promote StormEurope._read_one_nc to classmethod.
@peanutfun
Copy link
Copy Markdown
Member

peanutfun commented Nov 23, 2022

There were quite a few instances where the new init was not used. I fixed that in 3d5f54e. The rest looks fine to me, apart from the open discussions on the specific StormEurope attributes.

Comment on lines +187 to +189
LOGGER.info(
"Omitting files %s", [
file for file in file_names if file in files_omit])
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
LOGGER.info(
"Omitting files %s", [
file for file in file_names if file in files_omit])
if any(fo in file_name for fo in files_omit):
LOGGER.info("Omitting files %s", [
file for file in file_names if file in files_omit])

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very important suggestion, thank you! But I did not want to add yet another list comprehension. I found a different solution using sets, see 6f0acc1

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rather very unimportant, right? But yes, sets make more sense. 👍 (I was thinking along the same lines. Let's just hope the list was rather a bug than e feature, i.e., providing a path list with duplicates is not an intended valid use case. 🤞)

@emanuel-schmid
Copy link
Copy Markdown
Collaborator

@peanutfun Good catch! 🙌 Also nice, to leave the fraction as None while we're at it. 😀

@emanuel-schmid emanuel-schmid merged commit c51a6e8 into develop Dec 6, 2022
@emanuel-schmid emanuel-schmid deleted the feature/init_hazard_storm_europe branch December 6, 2022 15:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants