Skip to main content

insitukit

Python License: MIT

Fetch, summarise and publish in situ ocean observations: NOAA CO-OPS and ERDDAP clients, record statistics, and a compact JSON time-series format.

forcingkit prepares what drives a coastal model and topobathykit builds the ground it runs on; insitukit handles what the instruments in the water actually measured. It reads tide gauges and buoys from NOAA CO-OPS and any ERDDAP server with care for the provider: requests are paced, budgeted and identified, and an empty window is an empty result, not an error. It reduces long records to the summaries people read: daily means only where a day is at least half covered, exceedance curves, joint histograms, and marine heatwave climatologies after Hobday et al. (2016). And it writes them as small JSON series behind a guard that refuses unexpected object names or sizes, so a web page can draw years of data from a few files.

Install

pip install insitukit            # CO-OPS, ERDDAP, statistics, the JSON form, local and Workers KV storage
pip install "insitukit[gcs]"     # also Google Cloud Storage

Use

from datetime import datetime, timezone

import insitukit
from insitukit import coops, series, stats
from insitukit.erddap import Erddap

insitukit.identify("my-site/1.0 (+https://example.org; data@example.org)", application="my-site")

start, end = datetime(2026, 10, 1, tzinfo=timezone.utc), datetime(2026, 11, 1, tzinfo=timezone.utc)

# Observed water level and the station's own predictions; their difference is the surge.
level = coops.fetch("water_level", "8419870", start, end).set_index("time")["water_level"]
surge = level - coops.predictions("8419870", start, end).reindex(level.index)

# A buoy's temperature from an ERDDAP server, at most 20 requests this run.
server = Erddap("https://data.neracoos.org/erddap", budget=20)
temp = server.fetch("UNH_CML", start, end, ["temperature"]).set_index("time")["temperature"]

# In a long-running service: one attempt, failures skipped for five minutes, datasets in parallel.
live = Erddap("https://data.neracoos.org/erddap", budget=None, retries=1, connect_timeout=5, timeout=30,
              failure_ttl=300, fmt="csvp")
dataset_ids = ["UNH_CML"]  # several in practice
frames, failed = live.fetch_many(dataset_ids, start, end, ["temperature"])  # {id: DataFrame}, {id: exception}

daily = stats.day_means(temp, per_day=24, digits=2, tz="America/New_York")
hourly = series.encode(surge.resample("h").mean(), unit="m", places=3)  # {"t0": ..., "step": 3600, ...}

Modules

Module Contents
insitukit.coops fetch (observations, including currents by bin; long windows split to the API's limits), predictions (6-minute or hourly tides), tide_events (highs and lows), current_predictions (speed along the flood axis, or MAX_SLACK events), and station metadata: metadata, datums, flood_levels, harcon, stations. fetch(..., quality=True) adds each reading's quality level (p preliminary, v verified). DatumUnavailable when a station lacks the datum asked for. Metric units (current speeds in m/s) and UTC, with English units where the API offers them.
insitukit.erddap Erddap(base_url, budget, min_interval, retries, timeout, connect_timeout, backoff, failure_ttl, failures, fmt): tabledap .csv or .csvp into a DataFrame (units in attrs, optional depth column and range), fetch_many for several datasets on parallel threads, variables of a dataset, and get for any other query. One instance serves several threads under one request budget (or none). Failed hosts (Unreachable) and, with a failure_ttl, failed datasets (DatasetUnavailable) are skipped until their entry expires; a FailureCache can be shared. DatasetMissing for a dataset the server does not have.
insitukit.ndbc NDBC buoys: fetch (standard meteorology or ADCP over a window, each month from the monthly, yearly historical or 45-day real-time file, each file downloaded once), year (one historical file), currents (first ADCP bin in m/s with east and north components), position, parse. Each column's own missing-value sentinel becomes NaN. Every function takes an optional get for offline tests.
insitukit.stats day_means (coverage rule), exceedance, joint (two series paired by nearest time), climatology (Hobday et al. 2016: 11-day window, 31-day smoothing, mean, SD, 90th percentile).
insitukit.series encode and decode for one series, encode_frame and decode_frame for several on one grid, iso.
insitukit.store Store(root, writable, max_bytes): JSON and bytes to a directory, kv://<account>/<namespace> (Cloudflare Workers KV, token in CLOUDFLARE_API_TOKEN) or gs://bucket/prefix, refusing names outside writable and objects over max_bytes.

Etiquette

CO-OPS requests are at least 1 s apart (across threads), and 403 and 429 answers are treated as throttling and retried with backoff. ERDDAP requests start at least min_interval apart (across threads) and stop at the instance's budget; a host or dataset that just failed is skipped instead of asked again. Both send the User-Agent given to identify; include a way for the provider to reach you.

Reference

Hobday, A. J., et al. (2016). A hierarchical approach to defining marine heatwaves. Progress in Oceanography, 141, 227-238. doi:10.1016/j.pocean.2015.12.014

License

MIT. Copyright (c) 2026 Long Horizon Observatory.

Metadata

Release files for insitukit 0.5.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for insitukit 0.5.0
File Size Uploaded Provenance Actions
insitukit-0.5.0.tar.gz 105.4 kB With provenance Details for insitukit-0.5.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for insitukit 0.5.0
File Interpreter ABI Platform Actions
insitukit-0.5.0-py3-none-any.whl Python 3 none any Details for insitukit-0.5.0-py3-none-any.whl

Total release size: 133.1 kB

Release files / insitukit-0.5.0.tar.gz

Download URL insitukit-0.5.0.tar.gz
Size 105.4 kB
Tags Source
SHA-256 checksum
How to use checksums
77e4ec1fabc170ee49fc4750839da3cdd8fe900ccdc9bffb2e9b4951114bdd4e
BLAKE2b-256 checksum
How to use checksums
7d78f978cdea497458927cec2cd2d49e9dda401780ce85063e156d889fe0b1f3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 6, 2026.

Transparency log

Release files / insitukit-0.5.0-py3-none-any.whl

Download URL insitukit-0.5.0-py3-none-any.whl
Size 27.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
8dbc7c279e841eb10de5ca6b6239389a8d896c7f7a1e8066522b2ebd35efa18e
BLAKE2b-256 checksum
How to use checksums
8ac89d0df8dded9c9b3962a66f2a6b7de0ddc20e43f7aad2c140c4886e9a65c4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 6, 2026.

Transparency log

Security for insitukit 0.5.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for insitukit-0.5.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 6, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page