From cf1ee144f0cde5ab8fbbeea93dbbc9fca729057f Mon Sep 17 00:00:00 2001 From: ajsmale Date: Sat, 11 Aug 2018 20:28:44 +0200 Subject: [PATCH] Updated parse_data to deal with more than 200 directional bins as well as spectra with all zeros --- oceanwaves/swan.py | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/oceanwaves/swan.py b/oceanwaves/swan.py index eb41e4c..482d428 100644 --- a/oceanwaves/swan.py +++ b/oceanwaves/swan.py @@ -501,8 +501,17 @@ def parse_data(self): else: f = 1. - n = len(self.frequencies) - q = np.asarray(self.lines.read_blockbody(n)) * f + if len(self.directions)<= 200: + n = len(self.frequencies) + q = np.asarray(self.lines.read_blockbody(n), dtype=np.float64) * f + else: + n = int(np.ceil(len(self.directions)/200))*len(self.frequencies) + temp = self.lines.read_blockbody(n) + temp_q=[] + for ii in range(len(self.frequencies)): + temp_q.append(temp[2*ii]+temp[2*ii+1]) + q = np.asarray(temp_q, dtype=np.float64) * f + if self.stationary: self.quantities.append(q) else: