Open mwandres opened 6 years ago
Hi,
Thanks for using the oceanwaves toolbox! I'm afraid both issues are bugs. And both scenarios are not tested. So, thanks for providing tests :-)
I will have to look deeper into these issues. This might take some time as I just switched jobs.
You can also look into these issues yourself and submit a pull request. I'm happy to guide you along. I agree with your patch regarding swan.py:563. I expect you to be able to solve the writing issues quite easy. The dimensionality issue might me tougher. Is the result of the as_spectral() method accurate?
Bas
Hi,
First of all thanks for this great Toolbox and sorry about the rather long message. I'm having issues trying to write nonstationary 2D spectra files for SWAN and I'm not sure if I'm doing something wrong or if there's a bug but also haven't dug into the code too much.
The first issues I'm having is to include nonstat directions into my spectra:
frequency = np.arange(0.03,1.,.01)
direction = np.arange(0,360,1)
time = [datetime(2013,12,1), datetime(2013,12,2)]
Hs = [3.,5.]
Tp = [11.,13.]
theta_p = [200,250]
ow = oceanwaves.OceanWaves(time = time)#, frequency = frequency, direction = direction)
ow['_energy'].values = Hs
ow_spc = ow.as_spectral(frequency,Tp = Tp)
ow_dir = ow_spc.as_directional(direction, theta_peak = theta_p)
Gives me the following error
Not sure why it won't allow me to enter 2 different values of theta_p?
Irrespective of that - if I leave theta_p alone and just do
ow_dir = ow_spc.as_directional(direction)
It works but if I go on to try to do
ow_dir.to_swan('TEST.SP2')
I get
I had a look at the source code
swan.py
as this is where the error appears to be and I think line 563 should bek = self.obj._key_lookup('_time')
rather thank = self._key_lookup('_time')
When changing that it actually writes out my .SP2 file however it splits them in TEST_000.SP2 and TEST_001.SP2. Both files have the long header with the direction and frequency information but without any time info. Any idea what's happening or any suggestions what I could do differently?
Any help is much appreciated.