opendrift.readers.reader_tpxo

Reader for barotropic tidal currents from the TPXO9 global tide model, e.g. to add tides to an ocean model without tides (such as TOPAZ5) with reader arithmetic:

tides = reader_tpxo.Reader('/path/to/tpxo9', corners=[-15, 40, 55, 86])
o.add_reader([topaz + tides, topaz])

topaz + tides provides only the variables both readers have (the currents), so topaz is added again for its other variables. TPXO currents are depth-averaged, so the same tidal current is returned at all depths.

The harmonic synthesis follows the OTIS/TMD convention TPXO is distributed for (as pyTMD with corrections=’OTIS’): constituent phase is omega * (t - 1992-01-01) + phase0 + u, with nodal factors f and angles u from the lunar node only, computed with pyTMD (which must be installed).

Reads the OTIS netCDF velocity file of TPXO9.v1 (u_tpxo9.v1.nc: ua/up eastward and va/vp northward velocity amplitude (cm/s) and Greenwich phase lag (degrees) on a regular global lon/lat C-grid).

Attributes

logger

TPXO_UV_FILE

MAJOR_CONSTITUENTS

OTIS_EPOCH

MJD_OTIS_EPOCH

_cache

Classes

HarmonicGrid

Complex harmonic constants of one TPXO C-grid component on a regular

Reader

Eastward/northward TPXO barotropic tidal current (m/s).

Functions

tidal_phasors(time, constituents)

f * exp(i * (omega t + phase0 + u)) per constituent at time

_load(tpxo_dir, constituents, corners)

(constituents, u grid, v grid), loaded within corners and cached

Module Contents

opendrift.readers.reader_tpxo.logger
opendrift.readers.reader_tpxo.TPXO_UV_FILE = 'u_tpxo9.v1.nc'
opendrift.readers.reader_tpxo.MAJOR_CONSTITUENTS = ('m2', 's2', 'n2', 'k2', 'k1', 'o1', 'p1', 'q1')
opendrift.readers.reader_tpxo.OTIS_EPOCH
opendrift.readers.reader_tpxo.MJD_OTIS_EPOCH = 48622.0
opendrift.readers.reader_tpxo.tidal_phasors(time, constituents)[source]

f * exp(i * (omega t + phase0 + u)) per constituent at time (naive UTC datetime), as in pyTMD.predict.ocean_load.time_series with corrections=’OTIS’. Multiply by a complex harmonic constant (amp * exp(-i * phase_lag)) and take the real part to get the tide.

class opendrift.readers.reader_tpxo.HarmonicGrid(ds, amp_var, phase_var, lon_var, lat_var, con_index, corners=(-180, 180, -90, 90), amp_scale=0.01)[source]

Complex harmonic constants of one TPXO C-grid component on a regular lon/lat grid, bilinearly interpolated to arbitrary positions. Complex values (not amplitude/phase) are interpolated, so phase wrap-around doesn’t matter; land nodes are 0 in TPXO and stay 0.

dlon
dlat
periodic
values
interpolate(lon, lat)[source]

(nc, n) complex constants at lon/lat (degrees).

opendrift.readers.reader_tpxo._cache
opendrift.readers.reader_tpxo._load(tpxo_dir, constituents, corners)[source]

(constituents, u grid, v grid), loaded within corners and cached

class opendrift.readers.reader_tpxo.Reader(tpxo_dir, constituents=None, corners=(-180, 180, -90, 90))[source]

Bases: opendrift.readers.basereader.continuous.ContinuousReader

Eastward/northward TPXO barotropic tidal current (m/s).

Args:

tpxo_dir: folder with the TPXO OTIS netCDF velocity file (u_tpxo9.v1.nc). constituents: list of constituents, e.g. [‘m2’, ‘s2’]. Default: those

of the eight major ones (m2 s2 n2 k2 k1 o1 p1 q1) that the file has.

corners: [lonmin, lonmax, latmin, latmax] to load TPXO for, e.g. the

simulation domain. Default global (about 300 MB in memory).

Common constructor for all readers

variables = ['x_sea_water_velocity', 'y_sea_water_velocity']
proj4 = '+proj=latlong'
start_time = None
end_time = None
time_step = None
name = 'TPXO tides ()'
get_variables(requested_variables, time=None, x=None, y=None, z=None)[source]

Obtain and return values of the requested variables at all positions (x, y, z) closest to given time.

Returns:

Dictionary with arrays of length len(x) with values at exact positions x, y and z.