Bathymetry provider class
Objective: Implement classes to handle bathymetry data.
Proposed structure:
class BathymetryProvider():
""" Provide interpolated bathymetry data.
Args:
bathy_reader: BathyNetCDFReader or BathyMatlabReader
Bathymetry data file reader
"""
def __init__(self, bathy_reader):
self.reader = bathy_reader
def interpXY(self, ...):
""" Interpolate bathymetry grid in position coordinates (XY).
Returns:
bathy_field: Interpolation function
"""
lat, lon, bathy = self.reader.read()
...
return bathy_field
def interpLL(self, ...):
""" Interpolate bathymetry grid in latitude and longitude coordinates (LL).
Returns:
bathy_field: Interpolation function
"""
...
return bathy_field
LatLon = namedtuple('LatLon', ['latitude', 'longitude'])
""" Latitude and longitude coordinates for a given location.
Args:
latitude: float
Latitude in degrees from -90 (South Pole) to +90 (North Pole).
longitude: float
Longitude in degrees from -180 to +180 (West to East) with 0
corresponding to the Greenwich Meridian.
"""
class BathyNetCDFReader():
""" Extract bathymetry data from netCDF file.
Args:
path: str
File name including path.
lat_name: str
Name of the variable in the netCDF file that contains the latitue values.
lon_name: str
Name of the variable in the netCDF file that contains the longitude values.
bathy_name: str
Name of the variable in the netCDF file that contains the bathymetry values.
"""
def __init__(self, path, lat_name='lat', lon_name='lon', bathy_name='bathy'):
self.path = path
self.lat_name = lat_name
self.lon_name = lon_name
self.bathy_name = bathy_name
def read(latlon_NW=None, latlon_SE=None):
""" Read longitude, latitude, and bathymetry matrices from file.
Args:
latlon_NW: LatLon
North-western (NW) boundary of the region of interest.
latlon_SE: LatLon
South-eastern (SE) boundary of the region of interest.
Returns:
lat: 1d numpy array
Latitude values
lon: 1d numpy array
Longitude values
bathy: 2d numpy array
Bathymetry values
"""
...
return lat, lon, bathy
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information