-
Notifications
You must be signed in to change notification settings - Fork 45
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
Adding deep water approximations #95
Conversation
@b0ndman thank you for your contribution to MHKiT this looks like some really great functionality! I will be out of the office and unable to perform a formal review until later this month. The only thing currently missing is the tests for the new functions and possibly adding a test for deep=True in the current wave celerity test. If you are open to writing a couple of quick tests I could throw them into the test modules or we can work on them when I get back. @rpauly18 speaking of tests it looks like NREL-rex failed the CI test on this PR build. If you get a moment could you check that out? Thanks again @b0ndman great stuff! |
Apologies for kinda disappearing after doing the pull request (I'm on a bit of a tight work schedule, with the work on this stemming from that). I am open to helping out, at a limited capacity, and have noticed the NREL-rex failing also. |
@b0ndman thanks for offering to help. I have added a couple of tests for the depth_regime and wave_length functions, but if you have time and ability to review these tests and possibly add one for the deep water flag in energy flux it would be much appreciated. I am actively working on the NREL-rex issues that are being triggered by too many requests to the WPTO hindcast data server. |
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.
Hey, Rebecca apologizes for the delay of this review. Overall I had a couple of questions before we proceed. We can also schedule a chat to talk them over. Were you able to push directly to bondman's master branch to make changes?
.gitignore
Outdated
# scratch file | ||
scratch.py | ||
scratch_data.txt |
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.
I don't think we want to add these here right?
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.
removed in bc2720f
mhkit/wave/resource.py
Outdated
@@ -575,31 +577,43 @@ def energy_flux(S, h, rho=1025, g=9.80665): | |||
# TODO: Add deep water flag |
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.
We should remove this now.
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.
Removed in ac13e8e. Also switched logic for better readability.
mhkit/wave/resource.py
Outdated
# Eq 8 in IEC 62600-100, deep water simpilification | ||
Te = energy_period(S) | ||
Hm0 = significant_wave_height(S) | ||
# print(Hm_zero) |
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.
delete
mhkit/wave/resource.py
Outdated
|
||
Returns | ||
--------- | ||
l: pandas Dataframe |
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.
Rebecca right now the terminology page lists wave length as lambda
) to avoid confusion or be consistent?
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.
Variable can't be lamda
because it's a built-in function. I will stick with "l" I guess.
mhkit/wave/resource.py
Outdated
else: | ||
# check the depth for each of the frequencies using depth_regime() | ||
# get wavelength | ||
wl = wave_length(k) |
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.
This gets at my other comment but wave length should either be l
to be consistent with the other parts of the code as written or lambda
to be consistent with the terminology page.
mhkit/wave/resource.py
Outdated
by frequency | ||
''' | ||
|
||
assert isinstance(l, pd.DataFrame), "l must be of type pandas.DataFrame" |
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.
I think this function should work on numpy arrays too? We don't have to include it but is there a reason why we would only work on passed Dataframes and return a frequency indexed DataFrame?
mhkit/wave/resource.py
Outdated
l: pandas DataFrame | ||
wavelength [m] |
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.
Dateframe indexed by anything? I think this should say indexed by frequency because dep_reg
inherits its index from the wave length DataFrame here.
Do we have to do this? Would it be useful for this function to work on timeseries data? what about using it to check a particular wavelength like a float?
k: pandas Dataframe | ||
Wave number [1/m] indexed by frequency |
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.
WHy does this have to be DataFrame indexed by frequency? It seems like it would be useful on time series data or even an int or float as well...thoughts?
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.
Frequency is needed to calculate wave number, so when calculating it you get a k indexed by frequency. I suppose there could be use cases where a user would use a k not directly calculated from the MHKiT wave_number function that is a wave number for each time. So, for this particular function I suppose the index does not matter, I think he was just trying to be consistent with other functions that have k.
mhkit/wave/resource.py
Outdated
@@ -562,6 +562,8 @@ def energy_flux(S, h, rho=1025, g=9.80665): | |||
Spectral density [m^2/Hz] indexed by frequency [Hz] | |||
h: float | |||
Water depth [m] | |||
deep: bool (optional) | |||
Use deep water approximation |
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.
add default=False to docstring here
mhkit/wave/resource.py
Outdated
@@ -609,9 +623,11 @@ def wave_celerity(k, h, g=9.80665): | |||
Wave number [1/m] indexed by frequency [Hz] | |||
h: float | |||
Water depth [m] | |||
depth_check: bool (optional) | |||
If true check depth regime |
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.
Add 'default=False'
I have addressed all of my comments above. I think there are 2 issues outstanding after working with the code more.
Currently, depth_regime allows a user to specify a depth ratio for the depth regime. However, when using wave celerity there is no way to change the default value of 2. To address this I suggest instead of only a boolean for the parameter For point 2 I will add tests to check the other half of the |
Good catch on point 1. I think it would be better to add ratio as an optional parameter in wave_celerity with the default=2. We can in the doc string indicate that for the parameter to have any effect check_depth must equal True. I will add this. |
@rpauly18 I addressed the missing tests and coverage has been raised by 1%. I believe this is ready to go if you have a chance to look at it, |
Deep water approximations for wave celerity (so sinh doesn't blow up to infinity) using new functions wave_length() and depth_regime(). wave_length input is wave number array, output is array of wavelengths indexed by frequency. depth_regime inputs are wavelength array, water column depth, and optional defining ratio of water depth/wavelength.
Deep water approximation for energy_flux also implemented using IEC 62600-100 eq. 8, resolves TODO in that function