Skip to main content

comfort-db

License: MIT Python Documentation Status

Python library for working with the COMFORT[1] oceanographic SQLite dataset with code documentation.

comfort-db wraps database access, preprocessing and basic analysis utilities into one library. This includes filtering for quality and space-time ranges, unit conversions, spatiotemporal gridding, profile and water-mass analysis, geospatial utilities, scaling, plotting and visualisation using a dashboard.

The data structure broadly follows oceanographic ship measurement practice: At a latitude, longitude and time, a station defines where measurements were taken. At a station, profiles are measured, i.e. a parameter like temperature at different depths with a specific instrument. There can be multiple profiles at the same station, though in the COMFORT dataset, it is mostly one profile per station.

This library bases on and extends code developed in [2], including parts of the gridding, unit conversion, analysis and plotting routines.

[1] Korablev, A., Olsen, A., (2022) Geophysical Institute, University of Bergen, Bjerknes Centre for Climate Research. COMFORT Dataset [Data set]. NIRD RDA. https://doi.org/10.11582/2022.00039

[2] Jenniges, Y., Sonnewald, M., Maneth, S., Olsen, A., Koch, Boris P., (2025) Unveiling 3D ocean biogeochemical provinces in the North Atlantic: A systematic comparison and validation of clustering methods, Ecological Informatics, Volume 91, 103390, ISSN 1574-9541, https://doi.org/10.1016/j.ecoinf.2025.103390.


Installation

pip install comfort-db

Optional extras add more specialised functionality:

Extra Adds Enables
plot matplotlib, seaborn comfort.plot
geo shapely, geopandas, cartopy Water masses, Longhurst provinces, coastline distance (distance_to_coast)
grid xarray, netcdf4 Spatio-temporal gridding, bathymetry masking, biome classification (load_biomes), xarray output
scale scikit-learn ParamScaler
dash dash, plotly Interactive Dash explorer app
docs sphinx, sphinx-rtd-theme Building the documentation locally
all everything above

Install via e.g.

pip install "comfort-db[geo,plot]"

From source (editable, for development):

git clone https://github.com/y-jenniges/comfort-db.git
cd comfort-db
pip install -e ".[dev]"

To build the documentation locally:

sphinx-build documentation/source documentation/build/html

Requires Python 3.10 or newer.


Quick start

import comfort

# Overview of the database (no data loaded, takes some minutes)
comfort.info("/path/to/comfort.sqlite")

# Filter at SQL level, get back one DataFrame per parameter
# (output="xarray" returns an xarray Dataset and needs the `grid` extra)
data = comfort.load_comfort(
    "/path/to/comfort.sqlite",
    parameters=["NITRATE", "DIC"],
    quality_flags=comfort.QC_GOOD,  # quality filter
    lat_min=30, lat_max=70,  # latitude filter
    date_min="2000-01-01 00:00:00",  # date filter, format YYYY-MM-DD HH:MM:SS
    target_depths=[0, 50, 100, 200, 500, 1000],  # depth interpolation
    limit=500_000,  # first 500,000 rows per parameter (a warning is logged if rows are cut)
    output="dict",
)

# Table exploration
with comfort.connect("/path/to/comfort.sqlite") as conn:
    summary = comfort.describe_variables(conn, parameters=["NITRATE", "DIC"], quality_flags=comfort.QC_GOOD)

Testing

pip install -e ".[dev]"
pytest

# Include the bathymetry test (needs a GEBCO NetCDF file)
export BATHYMETRY_PATH=/path/to/gebco_bathymetry.nc
pytest

Citing

If you use comfort-db in published work, please cite the COMFORT dataset [1] and this library:

@article{jenniges_inprep,
    author = {Yvonne Jenniges and Are Olsen and Boris Peter Koch and Sebastian Maneth},
    title = {{comfort-db}: A Python toolkit to access, preprocess and explore the oceanographic COMFORT dataset},
    journal = {Journal of Open Source Software},
    year = {in prep.},
}

License

MIT

Metadata

Release files for comfort-db 0.1.1

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

Source distribution (sdist)

Source distribution for comfort-db 0.1.1
File Size Uploaded Provenance Actions
comfort_db-0.1.1.tar.gz 159.4 kB Without provenance Details for comfort_db-0.1.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for comfort-db 0.1.1
File Interpreter ABI Platform Actions
comfort_db-0.1.1-py3-none-any.whl Python 3 none any Details for comfort_db-0.1.1-py3-none-any.whl

Total release size: 261.4 kB

Release files / comfort_db-0.1.1.tar.gz

Download URL comfort_db-0.1.1.tar.gz
Size 159.4 kB
Tags Source
SHA-256 checksum
How to use checksums
fe7e23451e04170df72f4bfee5881cd2ed99849355e88ebeb52f889db0b95b6d
BLAKE2b-256 checksum
How to use checksums
75f494a3c4d86fffaa4fee2d6f7b1d81f0cfaa79083e60d06b940aafa28c2183
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.11.16

Release files / comfort_db-0.1.1-py3-none-any.whl

Download URL comfort_db-0.1.1-py3-none-any.whl
Size 102.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
00c40b1ab43c92cd71e1cc2149ec2b938d25ce07b8241fe0d948b429a5887902
BLAKE2b-256 checksum
How to use checksums
b763be99010bc5767dc956b38e82bd5c7da04fb13377862cfaf2f93cd47ad5e3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.11.16

Security for comfort-db 0.1.1

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.

No provenance found

None of the files in this release were uploaded with provenance metadata.

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.

Release history Release notifications | RSS feed

This release

0.1.1 This release

2 release files No provenance

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