Checking for missing content type metadata ...
This resource contains content types with missing metadata required to make it public or discoverable. Show missing content type metadata.
Click on the edit button ( ) below to edit this resource.
Checking for non-preferred file/folder path names (may take a long time depending on the number of files/folders) ...
This resource contains some files/folders that have non-preferred characters in their name. Show non-conforming files/folders.
This resource contains content types with files that need to be updated to match with metadata changes. Show content type files that need updating.
| Authors: |
|
|
|---|---|---|
| Owners: |
|
This resource does not have an owner who is an active HydroShare user. Contact CUAHSI (help@cuahsi.org) for information on this resource. |
| Type: | Resource | |
| Storage: | The size of this resource is 401.8 KB | |
| Created: | Oct 19, 2026 at 6:50 p.m. (UTC) | |
| Last updated: | Dec 02, 2026 at 2:22 a.m. (UTC) (Metadata update) | |
| Published date: | Dec 02, 2026 at 2:22 a.m. (UTC) | |
| DOI: | 10.4211/hs.ae624400ee364217a75a03c2ccd7f63d | |
| Citation: | See how to cite this resource |
| Sharing Status: | Published |
|---|---|
| Views: | 138 |
| Downloads: | 75 |
| +1 Votes: | 1 other +1 this |
| Comments: | No comments (yet) |
Abstract
This repository provides the code, configuration files, and documentation for a regime-aware hybrid machine-learning framework developed to correct spatially varying tidal-datum biases in NOAA Coastal Ocean Reanalysis (CORA) Gulf of America, Atlantic, and Caribbean. The framework uses CORA-derived tidal datums for the 1983–2001 National Tidal Datum Epoch and NOAA CO-OPS reference observations to characterize and correct biases in mean higher high water (MHHW), mean lower low water (MLLW), and great diurnal range (GT) along the U.S. Gulf and Atlantic coasts.
The methodology combines hierarchical clustering of coastal environments with XGBoost, spatial k-nearest-neighbor regression, and Gaussian process regression. Geographic, tidal, topobathymetric, and nearby observational information is used to estimate spatially varying biases and extend corrections to ungauged CORA locations. The workflow covers data preprocessing, coastal-regime assignment, model fitting, validation, and spatial inference. Independent held-out testing and spatially buffered validation are used to evaluate correction performance and spatial transferability.
This resource supports reproducibility of the correction methodology and its application to coastal reanalysis datasets. Application to other CORA releases, coastal reanalyses, or tidal-datum epochs requires recalibration and independent validation.
Subject Keywords
Coverage
Spatial
Content
README.md
Regime-Aware Hybrid Machine-Learning Bias Correction of NOAA Coastal Ocean Reanalysis Tidal Datums
by: Faezeh Maghsoodifar, The University of Alabama
A runnable Python workflow illustrating coastal tidal-datum bias correction, coastal-regime assignment, spatially buffered evaluation, and prediction at ungauged locations.
Workflow

View the workflow at full resolution
Quick start
Open a terminal in the folder containing these scripts. Use Python 3.10 or newer.
Create a virtual environment:
bash
python -m venv .venv
Activate it in Windows PowerShell:
powershell
.\.venv\Scripts\Activate.ps1
On macOS or Linux, use:
bash
source .venv/bin/activate
Install the dependencies:
bash
python -m pip install "numpy>=1.26,<3" "pandas>=2.1,<3" "scipy>=1.11,<2" "scikit-learn>=1.4,<2" "xgboost>=2,<4" "matplotlib>=3.8,<4" "joblib>=1.3,<2"
Run the demonstration:
bash
python run_example.py demo
The default demonstration creates 80 synthetic gauge locations and 180 synthetic prediction nodes. It reserves 16 gauges for evaluation, uses the remaining 64 for development, and evaluates spatial exclusions of 0, 50, and 200 km. It then fits development-only inference models and predicts the example nodes.
Running the demonstration creates data/example/ and outputs/ beside the scripts. These contain generated example inputs and outputs; no research datasets, figures, or personal machine directories are bundled with the code.
Files
| File | Purpose |
|---|---|
run_example.py |
Main entry point. Start here to run the commands below. |
cli.py |
Reads settings and inputs, connects the workflow stages, and saves models, predictions, metrics, and run information. |
settings.py |
Default predictors, model settings, random seed, sample sizes, and validation conditions. |
data.py |
Creates synthetic examples, validates input tables, and calculates geographic distances and spatial coordinates. |
model.py |
Defines the correction methods, training-only coastal regimes, ungauged assignment, and the corrected-datum equations. |
evaluation.py |
Applies spatial exclusions, records fold details, calculates performance metrics, and performs paired spatial-block bootstrap comparisons. |
plotting.py |
Creates error-distribution, distance-sensitivity, and example-location figures using a blue-and-gray palette. |
LICENSE |
Full GNU General Public License version 3 text. |
CITATION.cff |
Software author information and the preferred citation. |
Keep the Python files together in one folder so their imports work. The scripts use paths relative to their own folder rather than personal machine paths.
Commands
Show available options:
bash
python run_example.py --help
Generate synthetic inputs without fitting models:
bash
python run_example.py data
Run the complete demonstration and choose an output folder:
bash
python run_example.py demo --output outputs/demo
Evaluate existing input tables and predict their node locations:
bash
python run_example.py run --gauges inputs/gauges.csv --nodes inputs/nodes.csv --output outputs/run
Apply a saved model to a node table:
bash
python run_example.py predict --model outputs/run/development_models.joblib --nodes inputs/nodes.csv --output outputs/inference
The data and demo commands regenerate the synthetic example CSVs in data/example/. The run command uses the files supplied through --gauges and --nodes. The predict command uses the settings stored in the saved model. Load serialized model files only from a trusted source.
Input tables
Inputs are CSV files with a header row. Geographic coordinates use decimal degrees; datum values use meters. Required numeric values must be finite, and location identifiers must be present and unique within each table.
| Field | Gauge table | Node table | Description |
|---|---|---|---|
location_id |
Required | Required | Stable location identifier. |
latitude, longitude |
Required | Required | Geographic coordinates in degrees. |
raw_mhhw_m, raw_mllw_m, raw_gt_m |
Required | Required | Raw model datums in a consistent reference. |
form_factor |
Default predictor | Default predictor | Model-derived tidal form factor, dimensionless. |
depth_m |
Default predictor | Default predictor | Positive water depth in meters. |
slope |
Default predictor | Default predictor | Dimensionless local slope. |
reference_mhhw_m, reference_mllw_m, reference_gt_m |
Required | Unused | Reference datums at gauge locations; simulated in the demonstration. |
split |
Required | Unused | Either development or evaluation. |
spatial_block |
Required | Optional | Predefined group used for spatial-block resampling. |
data_kind |
Required | Required | Input description; generated examples use synthetic. |
Raw values must satisfy raw_mhhw_m - raw_mllw_m = raw_gt_m within numerical tolerance. Reference values must satisfy the corresponding identity. Reference epochs and vertical datums must be compatible before substituting measured data. This code does not perform vertical-datum conversion or harmonic analysis.
Predictors listed in settings.py must exist at both gauges and nodes. Observation, corrected-value, and target-bias fields are prohibited as model predictors. Missing required values produce an error rather than an automatic imputation.
Correction methods
| Method | Description |
|---|---|
raw |
Uncorrected model datums. |
mean_bias |
Subtracts the mean discrepancy of the eligible development gauges. |
idw5 |
Interpolates discrepancies from up to five nearest eligible gauges using inverse-distance-squared weights. |
global_hybrid |
Blends XGBoost and geographic kNN predictions, then adds a weighted GPR residual correction. |
regime_hybrid |
Fits hybrids within training-derived groups and assigns prediction locations using a logistic classifier. Uses the global hybrid when an assigned group has too few training gauges. |
Only MHHW and GT discrepancies are modeled. MLLW is derived:
text
bias = raw model datum - reference datum
corrected datum = raw model datum - predicted bias
corrected MLLW = corrected MHHW - corrected GT
Regimes are constructed using standardized predictors available throughout the prediction domain. Ward clustering and the logistic gate are fitted using the eligible development gauges. The example does not recreate observation-derived physical regimes from the manuscript. Cluster numbers are local to each fitted model and should not be treated as fixed physical labels across folds.
The hybrid's GPR residuals are calculated from internal K-fold base-model predictions, so each gauge's residual uses a base prediction fitted without that gauge. GPR uses Earth-centered Cartesian coordinates in kilometers and a fixed Matérn kernel. kNN and exclusion calculations use great-circle geometry.
Settings
Edit DEFAULT_CONFIG in settings.py to change the example settings. Alternatively, supply a complete JSON configuration with the same structure using --config settings.json.
| Setting | Default |
|---|---|
| Random seed | 42 |
| Coastal groups | 4 |
| Minimum gauges for a group-specific model | 10 |
| Geographic neighbors | 5 |
| XGBoost / kNN blend weights | Approximately 0.5714 / 0.4286; normalized before blending |
| GPR residual weight | 0.3 |
| Internal residual folds | 3 |
| GPR length scale | 200 km |
| XGBoost trees / maximum depth | 40 / 2 |
| Spatial exclusions | 0, 50, and 200 km |
| Minimum eligible development gauges per evaluation | 12 |
| Bootstrap replicates / minimum spatial blocks | 300 / 4 |
These are demonstration choices, not settings selected or validated for the manuscript. The workflow performs no automatic hyperparameter search or evaluation-score-based model selection.
Evaluation and interpretation
For each evaluation gauge and exclusion distance, development gauges closer than that distance are removed. Every correction method receives the same eligible development table. Regime-specific models partition that table internally. If the eligible sample is too small, the fold is recorded as skipped for all methods.
Evaluation reference values do not enter model fitting, regime construction, or final inference fitting. The final saved models use development gauges only. Exclusion distances describe validation conditions; they are not fixed correction radii. Actual neighbor distances vary by location.
The outputs report RMSE, MAE, mean bias, and paired RMSE differences. A negative delta_rmse_m means the named method has lower RMSE than its stated baseline. Positive RMSE reduction percentages indicate improvement.
Bootstrap intervals resample whole predefined spatial blocks, using the same resampled locations for both methods in a comparison. Intervals are omitted when too few blocks are available. The synthetic block definitions, small sample, and default bootstrap settings do not establish a publication-ready uncertainty design for real coastal data.
Outputs
| Output | Contents |
|---|---|
comparison.csv |
RMSE, MAE, and mean bias by datum, exclusion distance, and method. |
paired_comparisons.csv |
Paired RMSE differences, percentage changes, block counts, and bootstrap limits. |
fold_predictions.csv |
Individual evaluation predictions and reference values. |
fold_audit.csv |
Eligible training IDs and counts, nearest distances, group sizes, assignments, and fallback use. |
node_predictions.csv |
Raw and corrected node datums, assigned regimes, gate probabilities, and fallback flags. |
development_models.joblib |
Saved development-only correction models. |
configuration.json |
Configuration used for the run. |
run_manifest.json |
Input checksums, package versions, sample counts, and interpretation context. |
error_distributions.png |
Cumulative absolute errors for MHHW, MLLW, and GT. |
distance_sensitivity.png |
RMSE across exclusion distances. |
example_locations.png |
Development gauges, evaluation gauges, and prediction nodes. |
Plot titles currently identify the synthetic demonstration. Adapt the example generation, plotting labels, predictors, regimes, and validation design deliberately before using the workflow with study data. Running the example does not recreate or validate the manuscript figures.
Credit, citation, and license
by: Faezeh Maghsoodifar, The University of Alabama
The software license is GPL-3.0-only, as recorded in CITATION.cff. See LICENSE for the full terms. Each Python script includes the author credit and a reference to this license.
Use CITATION.cff for the software authors and preferred paper citation. The scholarly citation request is not an additional condition of the GPL license.
Related paper
Maghsoodifar, F., Moftakhari, H., Sweet, W., Callahan, J., & Luettich, R. A., Jr. (2026). Enhancement of Coastal Ocean Reanalysis Using Spatial Transfer of Sparse Observational Constraints [Preprint]. SSRN. https://doi.org/10.2139/ssrn.7499424
The reference uses the title registered for the preprint. The software title at the top of this README follows the title selected for this code release.
bibtex
@misc{maghsoodifar2026cora,
author = {Maghsoodifar, Faezeh and Moftakhari, Hamed and Sweet, William and Callahan, John and Luettich, Jr., Richard A.},
title = {Enhancement of Coastal Ocean Reanalysis Using Spatial Transfer of Sparse Observational Constraints},
year = {2026},
howpublished = {SSRN preprint},
doi = {10.2139/ssrn.7499424},
url = {https://doi.org/10.2139/ssrn.7499424}
}
Associated data resource
Maghsoodifar, F., & Moftakhari, H. (2026). High-Resolution Tidal Datums Along the U.S. Atlantic and Gulf Coasts. HydroShare. https://www.hydroshare.org/resource/ae624400ee364217a75a03c2ccd7f63d/
Credits
Funding Agencies
This resource was created using funding from the following sources:
| Agency Name | Award Title | Award Number |
|---|---|---|
| National Science Foundation (NSF), United States | Faculty Early Career Development Program (CAREER) | 2238000 |
Contributors
People or Organizations that contributed technically, materially, financially, or provided general support for the creation of the resource's content but are not considered authors.
| Name | Organization | Address | Phone | Author Identifiers |
|---|---|---|---|---|
| Hamed Moftakhari | The University of Alabama | ORCID |
How to Cite
This software is licensed under the GNU General Public License version 3.0 only (GPL-3.0-only). Users may use, modify, and redistribute the software in accordance with the license terms. Copyright and license notices must be preserved. Researchers who use or adapt this software are requested to cite the associated HydroShare resource.
https://www.gnu.org/licenses/gpl-3.0.html
Comments
There are currently no comments
New Comment