# Path: cotede/qctests/location_at_sea.py
#     OCEANSDB_AVAILABLE = True
#     OCEANSDB_AVAILABLE = False
#         ETOPO = oceansdb.ETOPO()
# def location_at_sea(data, cfg=None):
# def get_bathymetry(lat, lon, resolution="5min"):
#     def __init__(self, data, cfg=None, attrs=None):
#     def set_features(self):
#     def test(self):
# class LocationAtSea(QCCheck):
# 
# Path: tests/data.py
# class DummyData(object):
#     def __init__(self):
#         self.attrs = {
#                 'datetime': datetime(2016,6,4),
#                 'LATITUDE': 15, 'LONGITUDE': -38}
#         self.data = {
#                 'PRES': ma.fix_invalid(
#                     [2, 6, 10, 21, 44, 79, 100, 150,
#                         200, 400, 410, 650, 1000, 2000, 5000]),
#                 'TEMP': ma.fix_invalid(
#                     [25.32, 25.34, 25.34, 25.31, 24.99, 23.46, 21.85, 17.95,
#                         15.39, 11.08, 6.93, 7.93, 5.71, 3.58, np.nan]),
#                 'PSAL': ma.fix_invalid(
#                     [36.49, 36.51, 36.52, 36.53, 36.59, 36.76, 36.81, 36.39,
#                         35.98, 35.30, 35.28, 34.93, 34.86, np.nan, np.nan])}
# 
#     def __getitem__(self, key):
#         return self.data[key]
# 
#     def keys(self):
#         return self.data.keys()
# 
#     @property
#     def attributes(self):
#         print('attributes will be removed. Use attrs instead!')
#         return self.attrs


import numpy as np
    import pandas as pd
    import xarray as xr
    import oceansdb
from numpy import ma
from cotede.qctests.location_at_sea import (
    extract_coordinates,
    LocationAtSea,
    location_at_sea,
    get_bathymetry,
)
from ..data import DummyData
    lat2, lon2 = extract_coordinates(ds)
    assert np.allclose(lat, lat2, equal_nan=True)
    assert np.allclose(lon, lon2, equal_nan=True)


def test_bathymetry_point():
    """Check the elevation of single locations
    """
    if not OCEANSDB_AVAILABLE:
        return

    coords = [[10, 30, -366], [10, -30, 5192], [15, -38, 5036], [12, 222, 4995]]
    for lat, lon, z in coords:
        etopo = get_bathymetry(lat, lon, resolution="5min")

        assert "bathymetry" in etopo, "Missing bathymetry from get_bathymetry"
        assert ma.allclose(etopo["bathymetry"], [z]), "For ({},{}) expected {}".format(
            lat, lon, z
        )


def test_bathymetry_track():
    """Check the elevation for a track
    """
    if not OCEANSDB_AVAILABLE:
        return

    lat = [10, 10, 15, 12]
    lon = [30, -30, -38, 222]
    z = [-366, 5192, 5036, 4995]

# Path: cotede/qctests/location_at_sea.py
#     OCEANSDB_AVAILABLE = True
#     OCEANSDB_AVAILABLE = False
#         ETOPO = oceansdb.ETOPO()
# def location_at_sea(data, cfg=None):
# def get_bathymetry(lat, lon, resolution="5min"):
#     def __init__(self, data, cfg=None, attrs=None):
#     def set_features(self):
#     def test(self):
# class LocationAtSea(QCCheck):
# 
# Path: tests/data.py
# class DummyData(object):
#     def __init__(self):
#         self.attrs = {
#                 'datetime': datetime(2016,6,4),
#                 'LATITUDE': 15, 'LONGITUDE': -38}
#         self.data = {
#                 'PRES': ma.fix_invalid(
#                     [2, 6, 10, 21, 44, 79, 100, 150,
#                         200, 400, 410, 650, 1000, 2000, 5000]),
#                 'TEMP': ma.fix_invalid(
#                     [25.32, 25.34, 25.34, 25.31, 24.99, 23.46, 21.85, 17.95,
#                         15.39, 11.08, 6.93, 7.93, 5.71, 3.58, np.nan]),
#                 'PSAL': ma.fix_invalid(
#                     [36.49, 36.51, 36.52, 36.53, 36.59, 36.76, 36.81, 36.39,
#                         35.98, 35.30, 35.28, 34.93, 34.86, np.nan, np.nan])}
# 
#     def __getitem__(self, key):
#         return self.data[key]
# 
#     def keys(self):
#         return self.data.keys()
# 
#     @property
#     def attributes(self):
#         print('attributes will be removed. Use attrs instead!')
#         return self.attrs


# Path: tests/qctests/test_qc_location_at_sea.py
import numpy as np
    import pandas as pd
    import xarray as xr
    import oceansdb
from numpy import ma
from cotede.qctests.location_at_sea import (
    extract_coordinates,
    LocationAtSea,
    location_at_sea,
    get_bathymetry,
)
from ..data import DummyData

    lat2, lon2 = extract_coordinates(ds)
    assert np.allclose(lat, lat2, equal_nan=True)
    assert np.allclose(lon, lon2, equal_nan=True)


def test_bathymetry_point():
    """Check the elevation of single locations
    """
    if not OCEANSDB_AVAILABLE:
        return

    coords = [[10, 30, -366], [10, -30, 5192], [15, -38, 5036], [12, 222, 4995]]
    for lat, lon, z in coords:
        etopo = get_bathymetry(lat, lon, resolution="5min")

        assert "bathymetry" in etopo, "Missing bathymetry from get_bathymetry"
        assert ma.allclose(etopo["bathymetry"], [z]), "For ({},{}) expected {}".format(
            lat, lon, z
        )


def test_bathymetry_track():
    """Check the elevation for a track
    """
    if not OCEANSDB_AVAILABLE:
        return

    lat = [10, 10, 15, 12]
    lon = [30, -30, -38, 222]
    z = [-366, 5192, 5036, 4995]

    etopo = get_bathymetry(lat, lon, resolution="5min")