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
Classes
Complex harmonic constants of one TPXO C-grid component on a regular |
|
Eastward/northward TPXO barotropic tidal current (m/s). |
Functions
|
f * exp(i * (omega t + phase0 + u)) per constituent at |
|
(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
- 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.ContinuousReaderEastward/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 ()'