ocean-data-parser - a Python package for parsing oceanographic proprietary data formats to xarray Datasets1.
First, install the uv package manager
pip install uvNext, clone the repository to your local machine, enter the project directory and use uv sync to setup the package.
git clone https://github.com/cioos-siooc/ocean-data-parser
cd ocean-data-parser
uv sync --python 3.9This process will create a Python 3.9 virtual environment in the a .venv directory and populate it with the packages described in the pyproject.toml and uv.lock files.
Activate the new environment:
source .venv/bin/activateTest the install:
odpy --versionOnce installed, the package is usable via the command line interface:
odpy --helpTo batch convert a series of files to NetCDF:
odpy convert -i '**/*.cnv' -p 'seabird.cnv'
Load a compatible file with the automated parser detection method:
import ocean_data_parser.read
# Load a file to an xarray object
ds = ocean_data_parser.read.file('Path to file')
# Save to netcdf
ds.to_netcdf('save-path.nc')!!!warning The parser detection method relies on the file extension and the first few lines present within the given file.
Or specify the specific parser to use for this file format:
from ocean_data_parser.parsers import seabird
# Load a seabird cnv file as an xarray dataset
ds = seabird.cnv('Path to seabird cnv file')
# Save to netcdf
ds.to_netcdf('save-path.nc')The ocean-data-parser can then be used within either a Python package, script or jupyter notebook. See the documentation Notebook section for examples of how to use the package within a jupyter notebook.
All contributions are welcome!
Please create a new discussion or issue within the GitHub repository for any questions, ideas and suggestions.

