Command line reference
defair is the command line tool. It runs workflows, lists the
readers, checks a file’s metadata and produces data summaries.
defair --help and defair <command> --help print the same
information as this page.
Prerequisites
No. 1 A working DEFAIR command
Install DEFAIR as described in Install
DEFAIR, and check that defair version
prints the installed version. defair validate cf and
defair eda report need input files to read. defair run needs the
workflow file given with --config, and access to the inputs and
outputs that file names.
Global options
These go before the command name. Each can also be set with the environment variable shown.
Option |
Environment variable |
Default |
Effect |
|---|---|---|---|
--log-level TEXT |
DEFAIR_LOG_LEVEL |
INFO |
Log level: DEBUG, INFO, WARNING, ERROR or CRITICAL |
--log-json |
DEFAIR_LOG_JSON |
off |
Write log lines as JSON |
--log-module-level TEXT |
DEFAIR_LOG_MODULE_LEVEL |
none |
Per-module levels, as module:level,module:level |
--profile |
DEFAIR_PROFILE |
off |
Time the read, transform and write stages of defair run and write a report under .defair/reports/ |
defair --log-level DEBUG run --config workflow.yaml
The Configure logging page explains the levels.
Commands
defair run
Run a workflow from a YAML file.
defair run --config workflow.yaml
defair run --config workflow.yaml --dry-run
Option |
Effect |
|---|---|
--config PATH, -c PATH |
The workflow file (required) |
--dry-run, -n |
Print the planned inputs, transformations and outputs without reading any data |
Exit codes: 0 success, 1 the run failed, 2 the file is
invalid (bad YAML, an unknown plugin, or an option a plugin does not
accept).
defair readers
List every reader with the product it reads and the EUMETSAT collection ID.
defair readers
defair readers --format json
Option |
Effect |
|---|---|
--format TEXT |
table (default) or json |
defair validate cf
Check a file against the CF conventions (CF-1.13), the metadata rules
most Earth science tools expect. The reader is chosen from the file, as
it is for Dataset.from_source().
defair validate cf output/result.nc
defair validate cf output/result.nc --strict
Option |
Effect |
|---|---|
--strict |
Treat a missing required global attribute (Conventions, title, institution, source) as an error rather than a warning |
Exits with 0 when the file is valid and 1 otherwise. Errors and
warnings are printed one per line.
defair eda report
Produce summary statistics, histograms and correlations for a dataset, grouped by spatial grid, as a JSON or YAML report with optional PNG plots.
defair eda report data/*.nc --output output/eda
defair eda report s3://bucket/product.nc --reader mtg_fci_l1c_nc --variables vis_06,ir_105 --no-plots
Option |
Default |
Effect |
|---|---|---|
PATHS... |
required |
Input files, a glob pattern, or S3 URIs |
--reader TEXT |
auto |
Reader plugin name |
--source TEXT |
auto |
Source plugin name |
--output PATH, -o PATH |
output/eda |
Output directory |
--format TEXT |
json |
json or yaml |
--subsample INTEGER |
1 |
Spatial sub-sampling factor; 1 uses every pixel |
--bins INTEGER |
64 |
Histogram bin count |
--variables TEXT |
all |
Comma-separated variable names |
--max-pairs INTEGER |
15 |
Maximum variable pairs for 2D histograms and scatter plots; correlation always covers every pair |
--plots / --no-plots |
plots when matplotlib is installed |
Render PNG plots |
Exits with 2 when an option is unusable or a requested variable is
missing, and 1 when the analysis fails.
defair version
Print the installed version.
The workflow file
defair run reads a YAML file with four top-level keys:
name: "Workflow Name"
description: "Optional description"
inputs:
- id: "input_name"
reader:
name: "reader_plugin_name"
source:
fs_type: filesystem_type
path: /path/to/data
transformations:
- operation: "operation_name"
apply_to: "input_name"
parameter: value
outputs:
- writer: "writer_plugin_name"
path: /path/to/output
Field |
Required |
Meaning |
|---|---|---|
name |
yes |
A name for the workflow |
description |
no |
Free text |
inputs |
yes, at least one |
The products to read |
inputs[].id |
no |
Name used by the routing fields below; input_0, input_1, … when omitted |
inputs[].reader.name |
yes, inside a reader block |
Reader plugin; null lets DEFAIR choose from the path, and leaving the whole reader block out does the same |
inputs[].reader.chunks |
no |
Dask chunk sizes per dimension |
inputs[].reader.<option> |
no |
Any other option the reader accepts, under its Python name |
inputs[].source.fs_type |
no |
Source plugin (local, s3, s3boto or hda); chosen from the path when omitted |
inputs[].source.path |
yes |
One path, a glob pattern, or a list of paths |
inputs[].source.concat_dim |
no |
Dimension to join several files along (default time) |
inputs[].source.<option> |
no |
Any other option the source accepts, such as endpoint_url |
transformations |
no |
Run in order; each entry names an operation |
transformations[].apply_to |
in multi-input workflows |
Input id, or a list of ids, to apply the operation to one at a time |
transformations[].base_input |
for multi-source operations |
The base dataset of an operation such as alignment |
transformations[].align_inputs |
no |
The other inputs to align with base_input |
transformations[].reference_input |
no |
Input whose grid becomes the output grid |
transformations[].reference_grid_id |
no |
Which grid of a multi-grid reference_input to use, for example fci_2km |
transformations[].reference_grid |
no |
A fixed grid: crs, bounds, and resolution or width plus height |
transformations[].<option> |
no |
Any other option the operation accepts |
outputs |
yes, at least one |
Where to write |
outputs[].writer |
no |
Writer plugin; chosen from the path’s extension when omitted |
outputs[].path |
yes |
Local path, or an s3:// URI for the Zarr writers |
outputs[].<option> |
no |
Any other option the writer accepts, such as mode |
The rules that tie the routing fields together, and worked examples of each, are on the Run workflows page. Every option of a named plugin is checked against the plugin’s signature when the file is loaded, so a misspelt option fails before any data is read. When DEFAIR chooses the reader, source or writer itself, its options are checked once the plugin is chosen, at run time.
Example workflow
name: First workflow
description: One MSG SEVIRI channel over Iberia, written to Zarr
inputs:
- reader:
name: msg15nat
use_channel_names: true
source:
fs_type: local
path: MSG3-SEVI-MSG15-0100-NA-20251016172744.081000000Z-NA.nat
transformations:
- operation: content_filter
include_vars: [IR_108]
- operation: spatial_filter
lat_min: 35
lat_max: 45
lon_min: -10
lon_max: 5
outputs:
- writer: zarrv2
path: output/first-workflow.zarr
mode: w
Dry-run output:
$ defair run --dry-run --config first-workflow.yaml
First workflow
One MSG SEVIRI channel over Iberia, written to Zarr
1. Input Stage
┏━━━━━┳━━━━━━━━━┳━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
┃ # ┃ ID ┃ Reader ┃ Source ┃ Configuration ┃
┡━━━━━╇━━━━━━━━━╇━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┩
│ 1 │ input_0 │ msg15nat │ local://MSG3-SEVI-MSG15-0100-NA-20251016172744.081000000Z-NA.nat │ Reader: use_channel_names=True │
└─────┴─────────┴──────────┴──────────────────────────────────────────────────────────────────┴────────────────────────────────┘
2. Transformation Stage
┏━━━━━┳━━━━━━━━━━━━━━━━┳━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
┃ # ┃ Operation ┃ Routing ┃ Parameters ┃
┡━━━━━╇━━━━━━━━━━━━━━━━╇━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┩
│ 1 │ content_filter │ - │ include_vars=['IR_108'] │
│ 2 │ spatial_filter │ - │ lat_min=35, lat_max=45, lon_min=-10, lon_max=5 │
└─────┴────────────────┴─────────┴────────────────────────────────────────────────┘
3. Output Stage
┏━━━━━┳━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━┓
┃ # ┃ Writer ┃ Destination ┃ Configuration ┃
┡━━━━━╇━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━┩
│ 1 │ zarrv2 │ output/first-workflow.zarr │ Writer: mode=w │
└─────┴────────┴────────────────────────────┴────────────────┘
What to do next
For a complete example using the workflow commands, follow Run your first workflow. To control log levels, JSON output and messages from individual modules, use Configure logging.