diff --git a/ttide/t_predic.py b/ttide/t_predic.py index fede2f8..17e9f9d 100644 --- a/ttide/t_predic.py +++ b/ttide/t_predic.py @@ -96,7 +96,11 @@ def t_predic(t_time, names, freq, tidecon, ju = np.zeros((len(freq),), dtype='int32') # Check to make sure names and frequencies match expected values. for k in range(0, (names.shape[0])): - ju[k] = np.argwhere(const['name'] == names[(k)]) + matches = np.flatnonzero(const['name'] == names[(k)]) + if matches.size == 0: + raise ValueError("Constituent name '%s' not found in constants" % + (names[(k)],)) + ju[k] = matches[0] # if any(freq~=const.freq(ju)), # error('Frequencies do not match names in input'); # end; diff --git a/ttide/t_tide.py b/ttide/t_tide.py index 130ccc2..7be9cf2 100644 --- a/ttide/t_tide.py +++ b/ttide/t_tide.py @@ -98,8 +98,8 @@ def t_tide(xin, dt=1, stime=None, lat=None, series will remain and mean/trend are included). lsq : string - 'direct' - use A\ x fit - 'normal' - use (A'A)\(A'x) (may be necessary for very large + 'direct' - use A\\ x fit + 'normal' - use (A'A)\\(A'x) (may be necessary for very large input vectors since A'A is much smaller than A) 'best' - automatically choose based on length of series (default). @@ -427,14 +427,14 @@ def t_tide(xin, dt=1, stime=None, lat=None, # would be to change the basis functions. #################################################################### ii = np.flatnonzero(np.isfinite(jref)) - if ii: + if ii.size > 0: print(' Do inference corrections\\n') snarg = nobsu * pi * dt * (fi[(ii - 1)] - fu[(jref[(ii - 1)] - 1)]) scarg = np.sin(snarg) / snarg if infamprat.shape[1] == 1: # For real time series - pearg = np.dot(2 * pi,ii - (vu[(mu + ii - 1)] - + pearg = np.dot(2 * pi, ii * ( + vu[(mu + ii - 1)] - vu[(jref[(ii - 1)] - 1)] + infph[(ii - 1)])) / 360 pcfac = infamprat[(ii - 1)] * f[(mu + ii - 1)] / \ diff --git a/ttide/tests/print_tests.py b/ttide/tests/print_tests.py index 71f06d9..cf6633c 100644 --- a/ttide/tests/print_tests.py +++ b/ttide/tests/print_tests.py @@ -1,6 +1,6 @@ from ttide.t_tide import t_tide import ttide.tests.base as bmod -from cStringIO import StringIO +from io import StringIO import sys import numpy as np