betaFeedback

WorksComputer Science

comfort-db: A Python toolkit to access, preprocess and explore the oceanographic COMFORT dataset

Abstract

comfort-db is a Python library that facilitates working with the COMFORT SQLite dataset, version 2. The dataset assembles global oceanographic measurements from ten datasets and contains a total of 458,724,734 in situ measurements from the years 1772 to 2020. comfort-db enables easy access to the database and provides preprocessing and exploratory analysis utilities. Preprocessing supports variable scaling and filtering by space, time and quality. Unit conversions can be applied during data loading or separately via a converter object. Gridding is supported and optionally works with bathymetry data to exclude grid cells on land. Moreover, the library supports general and field-specific exploratory data analysis through plotting functions, an interactive Dash app and functions to compute oceanographic profile and water mass statistics. comfort-db is open source (MIT license) and available from PyPI and GitHub.

Software: comfort-db v0.1.1, github.com/y-jenniges/comfort-db, archive doi:10.5281/zenodo.24001495. Prepared for submission to the Journal of Open Source Software.

Statement of need

Currently, a large preprocessing pipeline is required to work with the COMFORT dataset. Users must perform SQLite queries, interpret quality flags and convert units, which involves computing TEOS-10 variables and averaging temperature and salinity variables to get a unique match for an oxygen observation. Depending on the use case, users may also want to interpolate (depth) profiles, perform scaling and gridding. comfort-db integrates these tasks into one reproducible Python workflow and thus contributes to sustainable and transparent analyses built on the COMFORT dataset. It enables users of the COMFORT dataset, oceanographers without a strong software background and data scientists without a strong oceanographic background, to focus on scientific questions rather than repeated, error-prone data preprocessing and wrangling.

State of the field

A related library is argopy [7] that enables data access, manipulation and visualisation of Argo float data. However, the COMFORT dataset differs from Argo not only in file format (SQLite vs. NetCDF), but also in scope and structure: It merges ten datasets into a station/profile hierarchy with its own SQLite schema, quality flag conventions and unit definitions and intended conversions. A simple adapter to argopy would not cover this schema- and domain-specific functionality. To our knowledge, no existing package offers a comparable reproducible interface to the COMFORT dataset.

Software design

The organisation of the comfort-db library is driven by usability and the scale of the COMFORT dataset. Since the dataset is distributed as a single multi-gigabyte SQLite file, efficiency and low memory usage were key design goals. For example, space, time and quality filtering is applied at the SQL level rather than after loading potentially large data tables into memory. SQLite does not support spatial (polygon-based) filtering, e.g. to extract a specific ocean basin. Therefore, comfort-db first computes a broader bounding box, filters for it in the database and subsequently filters the data in-memory to the exact polygon shape. Moreover, distance_to_coast and classify_from_grid map coordinates to the unit sphere and build a k-d tree (scipy, [12]) to efficiently query the nearest coastline point or grid cell.

Quality flag interpretation and unit conversions are centralised in dedicated modules (comfort.qc, comfort.units) so that corrections and settings apply everywhere consistently. To cater to a diverse audience, more specialised functionality such as plotting, geospatial analysis, gridding, scaling and the dash app is available through optional installs (plot, geo, grid, scale, dash). Thus, the core package stays lightweight for users who only need database access and preprocessing.

Some processing steps require a single parameter value per spatio-temporal location, which is not guaranteed in the COMFORT dataset. For example, there can be different instruments and multiple bottles on a conductivity-temperature-depth (CTD) rosette at the same time, depth and coordinates. Also, there are measurements that were contributed by more than one of the merged source datasets under different station IDs. Therefore, average_duplicates_by_location averages the records of each parameter by longitude, latitude, depth and time, irrespective of station ID, profile, instrument or bottle number. Records that the dataset itself flagged as duplicates (PQF2=-1) can be removed by applying the QC_GOOD quality filter. When auxiliary temperature and salinity are added to another parameter table for unit conversions, they are first averaged by station and depth (in load_comfort), which likewise averages all profiles, instruments and bottles of a station into one representative value.

Figure 1 was generated by example 7 of the codebase, which illustrates quality filtering, TEOS-10 conversion and unit harmonisation. The data were then rendered as a global temperature-salinity diagram coloured by oxygen concentration.

Global temperature-salinity diagram

Figure 1. Global temperature-salinity diagram (comfort.plot) with isopycnals in kg m−3\mathrm{kg\,m^{-3}} (dashed lines, reference pressure 0 dbar, computed as density-anomaly) of oxygen measurements from the COMFORT dataset. Only quality-controlled (QC_GOOD) data are loaded, units are harmonised (comfort.units) and oxygen values that are identical to their co-located practical salinity are dropped (flag_salinity_like_oxygen). Duplicate spatio-temporal locations are averaged (average_duplicates_by_location) and temperature, salinity and oxygen inner-joined. Absolute Salinity (SAS_\mathrm{A}) and Conservative Temperature (Θ\Theta) are derived via TEOS-10 (comfort.physics). The remaining 40,434,271 data points (out of 67,085,418 oxygen observations in the dataset) are averaged into hexagonal bins and coloured by oxygen concentration. The three visible low-oxygen zones in the plot broadly correspond to known oxygen-depleted areas in the Baltic, Black and Arabian Sea [11].

Research impact statement

The COMFORT dataset provides a large compilation of oceanographic observations, including data from established resources such as the World Ocean Database ([1]) and the Global Ocean Data Analysis Project ([9, 10]). Accessing, preprocessing and exploring this data can require substantial technical effort and comfort-db lowers the barrier to exploit this extensive resource to facilitate future analyses and reproducible workflows.

To this point, [4] is the only published study using the COMFORT dataset and investigated three-dimensional biogeochemical provinces in the North Atlantic. Future analyses ((Jenniges, in prep.)) will apply the data to spatio-temporal imputation. The preprocessing of both studies can be closely reproduced using comfort-db (examples 8 and 9, respectively), with minor numerical differences from refinements to the density conventions since the original analyses.

AI usage disclosure

Generative AI (Anthropic Claude Code, primarily Claude Sonnet 5) was used under direct supervision of the corresponding author (Y.J.) to restructure the author’s own pre-existing analysis scripts into an installable package, update accompanying documentation, draft the majority of the tests and assist in visualisations and identifying and fixing bugs. All code was reviewed by the corresponding author, who implemented the original scientific logic. Correctness was assessed via the tests, checks against manually computed unit conversions (CONVERSION_REFERENCE in test/test_units.py) and execution of all example scripts.

Acknowledgements

The first author (Y.J.) has been funded by the University of Bremen, the Helmholtz School for Marine Data Science (MarDATA) and the Alfred-Wegener-Institut, Helmholtz-Zentrum für Polar- und Meeresforschung, which also provided the computing infrastructure for this work.

References

  1. [1]Boyer, T. P., Baranova, O. K., Coleman, C., Garcia, H. E., Grodsky, A., Locarnini, R. A., Mishonov, A. V., Paver, C. R., Reagan, J. R., Seidov, D., Smolyar, I. V., Weathers, K., & Zweng, M. M. (2018). World Ocean Database 2018 (NOAA Atlas NESDIS 87). NOAA.
  2. [4]Jenniges, Y., Sonnewald, M., Maneth, S., Olsen, A., & Koch, B. P. (2025). Unveiling 3D ocean biogeochemical provinces in the North Atlantic: A systematic comparison and validation of clustering methods. Ecological Informatics, 91, 103390. https://doi.org/10.1016/j.ecoinf.2025.103390
  3. [7]Maze, G., & Balem, K. (2020). Argopy: A Python library for Argo ocean data analysis. Journal of Open Source Software, 5(53), 2425. https://doi.org/10.21105/joss.02425
  4. [9]Olsen, A., Key, R. M., Heuven, S. van, Lauvset, S. K., Velo, A., Lin, X., Schirnick, C., Kozyr, A., Tanhua, T., Hoppema, M., Jutterström, S., Steinfeldt, R., Jeansson, E., Ishii, M., Pérez, F. F., & Suzuki, T. (2016). The global ocean data analysis project version 2 (GLODAPv2) – an internally consistent data product for the world ocean. Earth System Science Data, 8, 297–323. https://doi.org/10.5194/essd-8-297-2016
  5. [10]Olsen, A., Lange, N., Key, R. M., Tanhua, T., Álvarez, M., Becker, S., Bittig, H. C., Carter, B. R., Cotrim da Cunha, L., Feely, R. A., Heuven, S. van, Hoppema, M., Ishii, M., Jeansson, E., Jones, S. D., Jutterström, S., Karlsen, M. K., Kozyr, A., Lauvset, S. K., … Wanninkhof, R. (2019). GLODAPv2.2019 – an update of GLODAPv2. Earth System Science Data, 11, 1437–1461. https://doi.org/10.5194/essd-11-1437-2019
  6. [11]Paulmier, A., & Ruiz-Pino, D. (2009). Oxygen minimum zones (OMZs) in the modern ocean. Progress in Oceanography, 80(3), 113–128. https://doi.org/10.1016/j.pocean.2008.08.001
  7. [12]Virtanen, P., Gommers, R., Oliphant, T. E., Haberland, M., Reddy, T., Cournapeau, D., Burovski, E., Peterson, P., Weckesser, W., Bright, J., van der Walt, S. J., Brett, M., Wilson, J., Millman, K. J., Mayorov, N., Nelson, A. R. J., Jones, E., Kern, R., Larson, E., … SciPy 1.0 Contributors. (2020). SciPy 1.0: Fundamental Algorithms for Scientific Computing in Python. Nature Methods, 17, 261–272. https://doi.org/10.1038/s41592-019-0686-2

Paper details

vlnc:W_cnrkng3x
Version
v1 · latest
Published
Fresh — added to the Hub within the last 30 days
Added
License
CC BY 4.0
Usage

views · 10

downloads · 0

A view counts once per browser per day, a download each time the PDF is requested.

  • Computer Science

Not recorded for this paper

View statement
Looking for related papers…
Contents