Comodo Calculator

Version: 3.2.3 (Mercurial revision 5770:c90c3015e72d, 2026-05-22)


Description

comodo-calculator is a calculator, variable extractor, and compiler for scientific data. It supports input files in NetCDF, GRIB, GeoTIFF, and ASCII formats. The output format defaults to NetCDF but can be GeoTIFF if the last input file is in GeoTIFF format.

For ASCII inputs, specify column indices as variable names (e.g., time=col0).


Usage

comodo-calculator -i file1.nc [var1]=ncVarName1 [ncPhaseVarName1] [[AXES:n0,...]] [ [var2]=ncVarName2 ...] [-i file2.nc ...] [OPTIONS]

Options

Option

Description

-h, --help

Display help and exit.

-i <file>

Path to an input file (NetCDF, GRIB, GeoTIFF, or ASCII).

-o <file>

Path to the output file.

-f <formula>

Formula to apply. If it starts with /, ./, or ../, it is treated as a file path containing the formula. See below for valid function and variables.

-deflate <level>

Compression level for NetCDF output. Default is 4.

--create=no

Preserve the input file if it is identical to the output file.

--fixed-types

Enforce fixed data types.


Examples

Extract Variables from a File

comodo-calculator -i grid.nc =longitude =latitude =depth -o bathymetry.nc

Add Variables to an Existing File

comodo-calculator -i tugo.state-2018.01.nc =time =bathymetry =lon =lat =triangles =edges =elevation =ubar =vbar -o tugo.state-2018.01-reduced.nc

Extract Variables from Multiple Files into One

comodo-calculator -i grid.nc =longitude =latitude =depth -i modelOutput.nc =elevation -o extract.nc

Extract and Rename Variables from Multiple Files

comodo-calculator -i grid.nc =longitude =latitude depth1=depth -i modelOutput.nc depth2=depth -o compilation.nc

Compute a Water Index

comodo-calculator -i T30TXR_20181021T110101_B03_ROI.tiff c=1 -i T30TXR_20181021T110101_B11_ROI.tiff b=1 -f "a=c-b; d=b+c; c=a/d" -o MNDWI.tif

Produce NetCDF from ASCII

comodo-calculator -i test.dat time=col0 lat=col14 lon=col15 -f "time?atted({units},{days since 1950-01-01})" -o test.nc

Notes

  • If the output file path ends with .nc, it is treated as a NetCDF file.

  • If the last input file is a GeoTIFF, the output can also be saved as GeoTIFF.

  • Use --create=no to avoid overwriting existing files if the input and output are identical.


Valid operators, variables and function for formula

Operators

Name

Description

+, -, *, /, ^, %

Addition, difference, product, ratio, power, scalar product

Variables

Name

Description

d2r

Degree to radian (π/180)

r2d

Radian to degree (180/π)

pi

π

e

Exponential

nan

Not a number

Functions

Name

Description

abs()

Norm (real or complex)

arg()

Phase lag (complex)

exp()

Exponential

gradx()

Zonal point to point difference

grady()

Meridian point to point difference

cos()

Cosine

sin()

Sine

sinh()

Hyperbolic sine

dx()

Zonal difference to the neighbor pixel

dy()

Meridian difference to the neighbor pixel

fliph()

Flip along x-axis

flipv()

Flip along y-axis

nearest()

Interpolate the masked value with the nearest one

ellipseM(X,Y)

Norm of vector or maximum current of ellipse


See Also