Skip to content

stitchee, a python package for concatenating netCDF data along an existing dimension

Project Status: Active – The project has reached a stable, usable state and is being actively developed Documentation Status Mypy checked Python Versions Package version Code coverage

Overview


STITCHEE (STITCH by Extending a dimEnsion) is used for concatenating netCDF data along an existing dimension, and it is designed as both a standalone utility and for use as a service in Harmony.

Getting started, with uv

  1. Follow the instructions for installing uv here.
  2. Install stitchee, with its dependencies, by running the following from the repository directory:
uv sync

To install with optional dependencies:

uv sync --extra dev --extra harmony

How to test stitchee locally

uv run pytest tests/

Contributing

We welcome contributions! This project uses: - Git Flow branching strategy with automated semantic versioning - CI/CD for testing, security scanning, and deployment - Protected branches (main, develop, release/, hotfix/)

Quick workflow: 1. Create feature branch from develop: git checkout -b feature/your-feature 2. Write code, tests, and update CHANGELOG.md 3. Open PR to develop - CI runs tests and security scans 4. After approval and merge, CI handles versioning automatically

For developers: See docs/CI-CD-README.md for complete CI/CD workflows and branching strategy.

Usage

For example:

uv run stitchee /path/to/files/directory -o output.nc --concat_method xarray-combine

Command line options:

$ uv run stitchee --help
usage: stitchee [-h] -o PATH [--concat_method {xarray-concat,xarray-combine}] [--concat_dim DIM] [--sorting_variable VAR] [--xarray_arg_compat COMPAT]
                [--xarray_arg_combine_attrs ATTRS] [--xarray_arg_join JOIN] [-O] [-v]
                INPUT [INPUT ...]

Concatenate netCDF files along existing dimensions.

options:
  -h, --help            show this help message and exit
  -O, --overwrite       Overwrite output file if it exists
  -v, --verbose         Enable verbose output to stdout; useful for debugging

Required Arguments:
  INPUT                 Input specification: multiple file paths, directory path, text file with file list, or single file to copy
  -o PATH, --output_path PATH
                        Output file path for concatenated result

Concatenation Options:
  --concat_method {xarray-concat,xarray-combine}
                        Concatenation method (default: xarray-concat)
  --concat_dim DIM      Dimension to concatenate along (required for xarray-concat)
  --sorting_variable VAR
                        Name of a variable to use for sorting datasets before concatenation (e.g., 'time')

xarray Arguments:
  --xarray_arg_compat COMPAT
                        'compat' argument passed to xarray concatenation function
  --xarray_arg_combine_attrs ATTRS
                        'combine_attrs' argument passed to xarray concatenation function
  --xarray_arg_join JOIN
                        'join' argument passed to xarray concatenation function

Examples:
  stitchee file1.nc file2.nc -o output.nc --concat_dim time
  stitchee /path/to/files/directory -o output.nc --concat_method xarray-combine
  stitchee filelist.txt -o output.nc --concat_dim time --sorting_variable time


This package is NASA Software Release Authorization (SRA) # LAR-20433-1