Beispiel #1
0
def test_FUV():
    x = loadbunch(fname, masked=False)
    # Switch epoch from Matlab to Python
    x.t -= 366
    x.t0 -= 366

    for i, flag in enumerate(x.flags):
        F, U, V = FUV(x.t, x.t0, x.lind - 1, x.lat, flag)
        print(f"i: {i} ngflags: {flag}")

        # We use broadcasting instead of replication, so
        # we need to test only against the first row of
        # the octave output in such cases.
        if F.shape[0] == 1:
            sub = (i, slice(0, 1))
        else:
            sub = (i, )
        assert_array_almost_equal(F, x.Fo[sub])
        assert_array_almost_equal(U, x.Uo[sub])

        if V.shape[0] == 1:
            sub = (i, slice(0, 1))
        else:
            sub = (i, )
        assert_array_almost_equal(V, x.Vo[sub])
Beispiel #2
0
def test_FUV():
    x = loadbunch(fname, masked=False)
    # Switch epoch from Matlab to Python
    x.t -= 366
    x.t0 -= 366

    for i, flag in enumerate(x.flags):
        F, U, V = FUV(x.t, x.t0, x.lind-1, x.lat, flag)
        print('i: {} ngflags: {}'.format(i, flag))

        # We use broadcasting instead of replication, so
        # we need to test only against the first row of
        # the octave output in such cases.
        if F.shape[0] == 1:
            sub = (i, slice(0, 1))
        else:
            sub = (i,)
        assert_array_almost_equal(F, x.Fo[sub])
        assert_array_almost_equal(U, x.Uo[sub])

        if V.shape[0] == 1:
            sub = (i, slice(0, 1))
        else:
            sub = (i,)
        assert_array_almost_equal(V, x.Vo[sub])
Beispiel #3
0
def test_FUV():
    x = loadbunch(fname, masked=False)
    for i, flag in enumerate(x.flags):
        F, U, V = FUV(x.t, x.t0, x.lind - 1, x.lat, flag)
        print('i:', i, "ngflgs:", flag)

        # We use broadcasting instead of replication, so
        # we need to test only against the first row of
        # the octave output in such cases.
        if F.shape[0] == 1:
            sub = (i, slice(0, 1))
        else:
            sub = (i, )
        assert_array_almost_equal(F, x.Fo[sub])
        assert_array_almost_equal(U, x.Uo[sub])

        if V.shape[0] == 1:
            sub = (i, slice(0, 1))
        else:
            sub = (i, )
        assert_array_almost_equal(V, x.Vo[sub])
Beispiel #4
0
from __future__ import (absolute_import, division, print_function)

import os

from utide.utilities import loadbunch

__version__ = '0.1.0'


_base_dir = os.path.join(os.path.dirname(__file__), 'data')
_ut_constants_fname = os.path.join(_base_dir, 'ut_constants.npz')

# At least for now, use NaNs rather than masked arrays.
ut_constants = loadbunch(_ut_constants_fname, masked=False)

# A list of strings is much easier to work with.
constit_names = [n.strip() for n in ut_constants.const.name]

# Make a dictionary for index lookups.
constit_index_dict = dict([(name, i) for (i, name) in
                           enumerate(constit_names)])

from ._solve import solve  # noqa
from ._reconstruct import reconstruct  # noqa

__all__ = ['solve',
           'reconstruct']
print('Size of boundary: ', len(bnd))
seg_types = [0] * len(bnd)
adcirc.order_boundary(bnd,seg_types)

#adcirc.update(os.path.join(data_files_dir,'vdatum','vdatum_fl_sab_adcirc54.nc'))

def parse_string(name):
    lista = [e.decode().strip() for e in name.tolist()]
    return ''.join(lista)

names = []
const = adcirc.Dataset.variables['tidenames'][:]
for name in const:
    names.append(parse_string(name.data))

con_info = loadbunch(_ut_constants_fname)['const']
from utide import _ut_constants_fname
from utide.utilities import loadbunch

con_info = loadbunch(_ut_constants_fname)['const']

k = 0
ind_nc, ind_ttide = [], []

const_name = [e.strip() for e in con_info['name'].tolist()]

consts = ['STEADY', 'M2', 'S2', 'N2', 'K1', 'O1', 'P1', 'M4', 'M6']
for name in consts:
    try:
        if name == 'STEADY':
            indx = const_name.index('Z0')
Beispiel #6
0
print('Size of boundary: ', len(bnd))
seg_types = [0] * len(bnd)
adcirc.order_boundary(bnd, seg_types)


def parse_string(name):
    lista = [e.decode().strip() for e in name.tolist()]
    return ''.join(lista)


names = []
const = adcirc.Dataset.variables['tidenames'][:]
for name in const:
    names.append(parse_string(name))  #changed from name.data

con_info = loadbunch(_ut_constants_fname)['const']

k = 0
ind_nc, ind_ttide = [], []

const_name = [e.strip() for e in con_info['name'].tolist()]

consts = ['STEADY', 'M2', 'S2', 'N2', 'K1', 'O1', 'P1', 'M4', 'M6']
for name in consts:
    try:
        if name == 'STEADY':
            indx = const_name.index('Z0')
        else:
            indx = const_name.index(name)
        k += 1
        ind_ttide.append(indx)
Beispiel #7
0
from __future__ import (absolute_import, division, print_function)

import os
import numpy as np
from utide.utilities import loadbunch


datadir = os.path.join(os.path.dirname(__file__))

fname = 'ut_constants'
data = loadbunch(
    os.path.join(datadir, '{}.mat'.format(fname)), masked=False)
np.savez('{}.npz'.format(fname), **data)

fname = 'FUV0'
data = loadbunch(
    os.path.join(datadir, '{}.mat'.format(fname)), masked=False)
np.savez('{}.npz'.format(fname), **data)
Beispiel #8
0
def test_name_A_g(coef, matfile):
    coef_mat = loadbunch(os.path.join(datapath, matfile)).coef
    coef_mat = convert_unicode_arrays(coef_mat)
    assert_array_equal(coef.name, coef_mat.name)
    assert_array_almost_equal(coef.A, coef_mat.A)
    assert_array_almost_equal(coef.g, coef_mat.g)
Beispiel #9
0
import os

import numpy as np

from utide.utilities import loadbunch

datadir = os.path.join(os.path.dirname(__file__))

fname = "ut_constants"
data = loadbunch(os.path.join(datadir, f"{fname}.mat"), masked=False)
np.savez(f"{fname}.npz", **data)

fname = "FUV0"
data = loadbunch(os.path.join(datadir, f"{fname}.mat"), masked=False)
np.savez(f"{fname}.npz", **data)
Beispiel #10
0
def test_name_A_g(coef, matfile):
    coef_mat = loadbunch(os.path.join(datapath, matfile)).coef
    coef_mat = convert_unicode_arrays(coef_mat)
    assert_array_equal(coef.name, coef_mat.name)
    assert_array_almost_equal(coef.A, coef_mat.A)
    assert_array_almost_equal(coef.g, coef_mat.g)