There’s a package I learned about today from 1998 called XTide.

sudo apt-get install xtide
tide -l "Redwood City, Wharf 5, San Francisco Bay, California"

Here’s the output:

            XTide 2   Copyright (C) 1998 David Flater.

This software is provided under the terms of the GNU General Public
License, either version 3 of the License, or (at your option) any later

Although the package as a whole is GPL, some individual source files
are public domain.  Consult their header comments for details.

                        NOT FOR NAVIGATION

This program is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
assumes no liability for damages arising from use of this program OR
of any 'harmonics data' that might be distributed with it.  For details, see
the verbose documentation at

This obnoxious message will go away permanently if you click "Don't show
this again" in the disclaimer window of the X windows client (xtide), or
if you create a file in your home directory called ".disableXTidedisclaimer".

Indexing /usr/share/xtide/harmonics-dwf-20191229-free.tcd...
Redwood City, Wharf 5, San Francisco Bay, California
37.5067° N, 122.2100° W

2020-04-07 12:46 PM PDT   8.20 feet  High Tide
2020-04-07  7:01 PM PDT  -0.18 feet  Low Tide
2020-04-07  7:27 PM PDT   Moonrise
2020-04-07  7:35 PM PDT   Full Moon
2020-04-07  7:37 PM PDT   Sunset
2020-04-08  1:10 AM PDT   8.49 feet  High Tide
2020-04-08  6:43 AM PDT   Sunrise
2020-04-08  7:24 AM PDT   Moonset
2020-04-08  7:37 AM PDT  -0.63 feet  Low Tide
2020-04-08  1:42 PM PDT   8.03 feet  High Tide
2020-04-08  7:38 PM PDT   Sunset
2020-04-08  7:44 PM PDT   0.34 feet  Low Tide
2020-04-08  8:41 PM PDT   Moonrise
2020-04-09  1:46 AM PDT   8.68 feet  High Tide
2020-04-09  6:41 AM PDT   Sunrise
2020-04-09  8:00 AM PDT   Moonset
2020-04-09  8:27 AM PDT  -0.96 feet  Low Tide
2020-04-09  2:39 PM PDT   7.73 feet  High Tide
2020-04-09  7:39 PM PDT   Sunset
2020-04-09  8:27 PM PDT   0.99 feet  Low Tide
2020-04-09  9:56 PM PDT   Moonrise
2020-04-10  2:23 AM PDT   8.72 feet  High Tide
2020-04-10  6:40 AM PDT   Sunrise
2020-04-10  8:38 AM PDT   Moonset
2020-04-10  9:16 AM PDT  -1.04 feet  Low Tide
2020-04-10  3:37 PM PDT   7.35 feet  High Tide
2020-04-10  7:40 PM PDT   Sunset
2020-04-10  9:13 PM PDT   1.70 feet  Low Tide
2020-04-10 11:08 PM PDT   Moonrise
2020-04-11  3:02 AM PDT   8.57 feet  High Tide
2020-04-11  6:38 AM PDT   Sunrise

Tides are mostly caused the movement of the earth and celestial bodies like the sun and moon relative to one another. The Earth, Sun, and Moon’s orbits and rotations are periodic, so you can think of them as overlapping sine waves – their overlapping effect can be used to predict the tides.

If you know anything about the fourier transform, you know that it can be used to decompose any waveform as a weighted sum of sines and cosines. So if you measure the tidal height over time, you can discover the individual periodic signals by using discrete fourier transform! For each factor, you can also discover its weight / overall contribution to the whole signal. Once you have the factors, you can also calculate, for any future point in time, the actual tide height by doing an IFT after extrapolating the frequency domain.

The problem is, you have to observe things for a long enough time to capture the periodic signals at play. The sun and moon have the strongest effect on tides, and you can capture their curves pretty well with 30 days observation. But there are other factors that affect tides that require 1 year or even multiple years of observation to capture. For example, contours of the sea floor and land masses also contribute to tides! These things do not remain the same from year to year – they change, sometimes very slowly.

The result of this is: if you bake in the individual factors for tidal prediction, they will slowly become less accurate over time because they don’t perfectly model the factors contributing to the tides. You have to refresh them, and each refresh needs to be done with enough collected data. NOAA provides these factors, called harmonic constituents, by continually conducting tide measurements and using them to update the constituents.

You can get updated harmonics data that it uses here and the location names as well. Harmonics are updated once a year.

Most tidal data sites are using this in the backend and wrapping it with some pretty graphics. Don’t pay for tide data – it’s free (at least for the US).

My use case is basically to make it easier for myself to look at tidal information for my various ocean fishing spots. Normally I have to google it, and the sites are a bit spammy. I just care about roughly when high/low tide are going to be, what the moon phase is for the day, and what the weather is. Seems like it should be simple enough to make a barebones informational page for this. I already made one that has proven extremely useful for freshwater fishing – it basically just has humidity, temp, and wind speed.

The harmonics data is stored in a binary file format called TCD. libtcd is the C++ library to interface with it, and they provide a complete description of the format, but the easiest way I’ve found to look at the file is using a python wrapper someone wrote.

pip install libtcd
import libtcd.api

tcd =
for station in tcd:

Once you have the station names, you can use the tide tool to see the tide information for that station. You can also get the information using the python wrapper, but it’s not super easy to use and there’s no documentation. I read some of the code and it’s not fully implemented (and seems abandoned) – for example the findall method seems incomplete and doesn’t actually do a regex search, which is what you’d expect it to do. It seems safe to use however at least for the purposes of dumping all the station names, and given that xtide is from 1998 it’s probably going to be stable.

If I am bored enough one of these weekends I’ll dump all the data from xtide into a spanner table with S2 indices, then build a small page that lets you input a location and finds the geographically nearest station. It would be interesting to see how my data compares to major sites like tides4fishing – I bet some of the big ones don’t bother to update their harmonics files, haha.