Skip to content

beachpeeps/spring_tide_datums

Repository files navigation

Tidal Spring Datums Calculator

A Python program for computing tidal spring datums (MHWS, MLWS) and related tidal statistics using harmonic analysis and NOAA CO-OPS data.

Overview

This program calculates Mean High Water Springs (MHWS) and Mean Low Water Springs (MLWS) along with other tidal statistics for any NOAA CO-OPS station. It uses harmonic analysis of tidal constituents to predict tides and identifies spring tide periods to compute the spring datums.

Features

🌊 Complete Tidal Analysis

  • MHWS: Mean High Water Springs (average of daily highs during spring tides)
  • MLWS: Mean Low Water Springs (average of daily lows during spring tides)
  • MHW: Mean High Water (average of all high tides)
  • MHHW: Mean Higher High Water (average of higher high tides only)
  • MLW: Mean Low Water (average of all low tides)
  • MLLW: Mean Lower Low Water (average of lower low tides only)

🎯 Scientific Accuracy

  • NOAA API Integration: Automatically fetches official tidal datums
  • Sub-centimeter Precision: Matches NOAA official values with <0.002m error
  • Generic Functionality: Works with any CO-OPS station without configuration
  • Multiple Datums: Supports both MLLW and NAVD88 datums
  • Multiple Epochs: Supports different tidal datum epochs (1983-2001, 2002-2020, etc.)

📊 Visualization

  • High-Quality Plots: 300 DPI publication-ready figures
  • Spring Tide Visualization: Shows spring highs (red) and lows (green)
  • Reference Lines: Displays MHWS and MLWS levels
  • Spring Windows: Marks spring tide periods

Installation

Requirements

pip install pandas numpy matplotlib requests

Files

  • compute_spring_datums.py - Main module
  • plot_example.py - Plotting examples
  • datum_example.py - Datum comparison examples
  • epoch_example.py - Epoch comparison examples

Quick Start

Basic Usage

from compute_spring_datums import compute_spring_datums

# Compute spring datums for La Jolla, CA
t, eta, springs, mask, highs_all, highs_spring, lows_all, lows_spring, summary, plot_month = compute_spring_datums(
    station_id='9410230',  # La Jolla, CA
    epoch='1983-2001',     # Tidal epoch
    datum='NAVD88'         # Vertical datum
)

print(f"MHWS: {summary['mhws']:.3f} m")
print(f"MLWS: {summary['mlws']:.3f} m")
print(f"MHW:  {summary['mhw']:.3f} m")
print(f"MHHW: {summary['mhhw_approx']:.3f} m")
print(f"MLW:  {summary['mlw']:.3f} m")
print(f"MLLW: {summary['mllw_approx']:.3f} m")

Generate Plots

from compute_spring_datums import generate_tidal_plot

# Generate and save a plot
filename, summary = generate_tidal_plot(
    station_id='9410230',
    epoch='1983-2001',
    datum='NAVD88'
)
print(f"Plot saved as: {filename}")

Run Examples

# Run the main program
python compute_spring_datums.py

# Run plotting examples
python plot_example.py

# Compare different datums
python datum_example.py

# Compare different epochs
python epoch_example.py

Configuration

Edit the configuration section in compute_spring_datums.py:

STATION_ID = "9410230"      # NOAA station ID
EPOCH = "1983-2001"         # Tidal epoch
DATUM = "NAVD88"            # Vertical datum (MLLW or NAVD88)
DT_HOURS = 1                # Time step for predictions
SPRING_WINDOW_HOURS = 36    # Spring tide window (±hours)

Supported Stations

Works with any NOAA CO-OPS station. Common examples:

Station ID Location State
9410230 La Jolla CA
9414290 San Francisco CA
9410170 San Diego CA
9411340 Los Angeles CA
9413450 Santa Barbara CA

Supported Epochs

  • 1983-2001: Current National Tidal Datum Epoch (NTDE)
  • 2002-2020: Previous NTDE
  • 1960-1978: Earlier epoch
  • 1978-1996: Earlier epoch
  • 1996-2014: Earlier epoch
  • Custom: Specify start/end dates

Supported Datums

  • MLLW: Mean Lower Low Water
  • NAVD88: North American Vertical Datum 1988

Accuracy

The program achieves excellent accuracy compared to NOAA official values:

Statistic Error Accuracy
MHW 0.001 m 99.9%
MHHW 0.002 m 99.9%
MLW 0.000 m 100%
MLLW 0.000 m 100%

How It Works

  1. Fetch Harmonic Constituents: Downloads tidal harmonic data from NOAA CO-OPS API
  2. Predict Tides: Uses harmonic analysis to predict water levels
  3. Identify Spring Tides: Finds spring tide periods using lunar phase calculations
  4. Find Daily Extremes: Identifies daily high and low tides
  5. Calculate Statistics: Computes MHWS, MLWS, and other tidal datums
  6. Apply Datum Offsets: Converts to target datum using NOAA official values
  7. Generate Visualizations: Creates plots showing tidal patterns

API Integration

The program automatically fetches official NOAA datums from:

https://api.tidesandcurrents.noaa.gov/mdapi/prod/webapi/stations/{station_id}/datums.json

This ensures accuracy by calibrating against official NOAA values.

Output Files

  • Plot Files: tidal_analysis_{station}_{datum}_{epoch}_{month}.png
  • High Resolution: 300 DPI for publication quality
  • Comprehensive: Shows tide curve, spring extremes, and reference lines

Example Results

La Jolla, CA (9410230) - NAVD88, 1983-2001

MHWS: 1.572 m
MLWS: -0.015 m
MHW:  1.343 m
MHHW: 1.564 m
MLW:  0.216 m
MLLW: -0.058 m

Technical Details

  • Harmonic Analysis: Uses 37+ tidal constituents
  • Spring Tide Detection: ±36 hour window around new/full moon
  • Datum Conversion: Automatic calibration to NOAA official values
  • Time Series: 1-hour resolution predictions
  • Epoch Coverage: Full 19-year tidal datum epochs

License

This program is provided as-is for scientific and educational use. Please cite NOAA CO-OPS data sources when using results.

References

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages