GOT
Reads files for Richard Ray’s Global Ocean Tide (GOT) models
ascii format
netcdf format
Spatially interpolates tidal constituents to input coordinates
Calling Sequence
import pyTMD.io
amp,ph,c = pyTMD.io.GOT.extract_constants(ilon, ilat, model_files,
method='spline')
- pyTMD.io.GOT.extract_constants(ilon: ndarray, ilat: ndarray, model_files: str | Path | list | None = None, **kwargs)[source]
Reads files for Richard Ray’s Global Ocean Tide (GOT) models
Makes initial calculations to run the tide program
Spatially interpolates tidal constituents to input coordinates
- Parameters:
- ilon: np.ndarray
longitude to interpolate
- ilat: np.ndarray
latitude to interpolate
- model_files: str, list, pathlib.Path or NoneType, default None
list of model files for each constituent
- grid: str, default ‘ascii’
Tide model file type to read
'ascii'
: traditional GOT ascii format'netcdf'
: GOT netCDF4 format
- compressed: bool, default False
Input files are gzip compressed
- crop: bool, default False
Crop tide model data to (buffered) bounds
- bounds: list or NoneType, default None
Boundaries for cropping tide model data
- buffer: int or float, default None
Buffer angle for cropping tide model data
- method: str, default ‘spline’
Interpolation method
'bilinear'
: quick bilinear interpolation'spline'
: scipy bivariate spline interpolation'linear'
,'nearest'
: scipy regular grid interpolations
- extrapolate: bool, default False
Extrapolate model using nearest-neighbors
- cutoff: float, default 10.0
Extrapolation cutoff in kilometers
Set to
np.inf
to extrapolate for all points- scale: float, default 1.0
Scaling factor for converting to output units
- Returns:
- amplitude: np.ndarray
amplitudes of tidal constituents
- phase: np.ndarray
phases of tidal constituents
- constituents: np.ndarray
list of model constituents
- pyTMD.io.GOT.read_constants(model_files: str | Path | list | None = None, **kwargs)[source]
Reads files for Richard Ray’s Global Ocean Tide (GOT) models
- Parameters:
- model_files: str, list, pathlib.Path or NoneType, default None
list of model files for each constituent
- grid: str, default ‘ascii’
Tide model file type to read
'ascii'
: traditional GOT ascii format'netcdf'
: GOT netCDF4 format
- compressed: bool, default False
Input files are gzip compressed
- crop: bool, default False
Crop tide model data to (buffered) bounds
- bounds: list or NoneType, default None
Boundaries for cropping tide model data
- buffer: int or float, default 0
Buffer angle for cropping tide model data
- Returns:
- constituents: obj
complex form of tide model constituents
- pyTMD.io.GOT.interpolate_constants(ilon: ndarray, ilat: ndarray, constituents, **kwargs)[source]
Interpolate constants from GOT tidal models to input coordinates
Makes initial calculations to run the tide program
- Parameters:
- ilon: np.ndarray
longitude to interpolate
- ilat: np.ndarray
latitude to interpolate
- constituents: obj
Tide model constituents (complex form)
- method: str, default ‘spline’
Interpolation method
'bilinear'
: quick bilinear interpolation'spline'
: scipy bivariate spline interpolation'linear'
,'nearest'
: scipy regular grid interpolations
- extrapolate: bool, default False
Extrapolate model using nearest-neighbors
- cutoff: float, default 10.0
Extrapolation cutoff in kilometers
Set to
np.inf
to extrapolate for all points- scale: float, default 1.0
Scaling factor for converting to output units
- Returns:
- amplitude: np.ndarray
amplitudes of tidal constituents
- phase: np.ndarray
phases of tidal constituents
- pyTMD.io.GOT.read_ascii_file(input_file: str | Path, **kwargs)[source]
Read Richard Ray’s Global Ocean Tide (GOT) model file
- Parameters:
- input_file: str or pathlib.Path
Model file
- compressed: bool, default False
Input file is gzip compressed
- Returns:
- hc: np.ndarray
complex form of tidal constituent oscillation
- lon: np.ndarray
longitude of tidal model
- lat: np.ndarray
latitude of tidal model
- cons: str
tidal constituent ID
- pyTMD.io.GOT.read_netcdf_file(input_file: str | Path, **kwargs)[source]
Read Richard Ray’s Global Ocean Tide (GOT) netCDF4 model file
- Parameters:
- input_file: str or pathlib.Path
model file
- compressed: bool, default False
Input file is gzip compressed
- Returns:
- hc: np.ndarray
complex form of tidal constituent oscillation
- lon: np.ndarray
longitude of tidal model
- lat: np.ndarray
latitude of tidal model
- cons: str
tidal constituent ID
- pyTMD.io.GOT.output_netcdf_file(FILE: str | Path, hc: ndarray, lon: ndarray, lat: ndarray, constituent: str)[source]
Writes tidal constituents to netCDF4 files in GOT format
- Parameters:
- FILE: str or pathlib.Path
output GOT model file name
- hc: np.ndarray
Eulerian form of tidal constituent
- lon: np.ndarray
longitude coordinates
- lat: np.ndarray
latitude coordinates
- constituent: str
tidal constituent ID
- pyTMD.io.GOT._extend_array(input_array: ndarray, step_size: float)[source]
Extends a longitude array
- Parameters:
- input_array: np.ndarray
array to extend
- step_size: float
step size between elements of array
- Returns:
- temp: np.ndarray
extended array
- pyTMD.io.GOT._extend_matrix(input_matrix: ndarray)[source]
Extends a global matrix
- Parameters:
- input_matrix: np.ndarray
matrix to extend
- Returns:
- temp: np.ndarray
extended matrix
- pyTMD.io.GOT._crop(input_matrix: ndarray, ilon: ndarray, ilat: ndarray, bounds: list | tuple, buffer: int | float = 0)[source]
Crop tide model data to bounds
- Parameters:
- input_matrix: np.ndarray
matrix to crop
- ilon: np.ndarray
longitude of tidal model
- ilat: np.ndarray
latitude of tidal model
- bounds: list, tuple
bounding box:
[xmin, xmax, ymin, ymax]
- buffer: int or float, default 0
buffer to add to bounds for cropping
- Returns:
- temp: np.ndarray
cropped matrix
- lon: np.ndarray
cropped longitude
- lat: np.ndarray
cropped latitude
- pyTMD.io.GOT._shift(input_matrix: ndarray, ilon: ndarray, lon0: int | float = 180, cyclic: int | float = 360, direction: str = 'west')[source]
Shift global grid east or west to a new base longitude
- Parameters:
- input_matrix: np.ndarray
input matrix to shift
- ilon: np.ndarray
longitude of tidal model
- lon0: int or float, default 180
Starting longitude for shifted grid
- cyclic: int or float, default 360
width of periodic domain
- direction: str, default ‘west’
Direction to shift grid
'west'
'east'
- Returns:
- temp: np.ndarray
shifted matrix
- lon: np.ndarray
shifted longitude