Forums » Operator News »
CDO query feature available since 2.6.1
Added by Uwe Schulzweida about 1 month ago
Query¶
CDO supports the NetCDF classic data model with attributes that conform to the CF conventions. The CDO I/O interface always reads in a complete horizontal field. If the dataset is chunked and the chunks extend beyond the horizontal field, the chunks are cached.
Using the query feature allows you to reduce the view to the dataset before CDO processes it. This can improve performance and reduce memory requirements – particularly for high-resolution, chunked and compressed datasets, especially when the data has to be loaded over the network. The size of the required cache is also affected by this.
The following keys are available for pre-selecting a subset of a dataset:
| Keyword | Description |
|---|---|
| group | Select group (group=groupName) |
| name | Variable names (name=var1,var2,...) |
| cell | Cell index range (cell=first/to/last) |
| layer | Layer index range (layer=first/to/last) |
| step | Time step index range (step=first/to/last) |
| startdate | Start date (format: YYYY-MM-DD[Thh:mm:ss]) |
| enddate | End date (format: YYYY-MM-DD[Thh:mm:ss]) |
The indices for keys cell, layer and step start at 1.
The cell key is only implemented for unstructured and HEALPix grids.
The keys can be defined for all input streams using the global CDO option --query. Here is an example to select the first 100 timesteps of the variable xxx:
cdo --query step=1/to/100,name=xxx copy infile outfile
Use the query: identifier for one specific input stream:
cdo copy query:path=infile,step=1/to/100,name=xxx outfile
Keyword: group¶
NetCDF-4 added support for hierarchical groups within NetCDF datasets. Groups are not compatible with the NetCDF classic data model. If the dataset contains more than one group, use the group key to select just one of them:
cdo --query group=groupName xsinfo infile
Keyword: cell¶
The CDO I/O interface always reads in a complete horizontal field. If the data is chunked and the number of grid points required is significantly smaller than the complete horizontal field, more data is read in than necessary.
Use the cell key to select a contiguous set of grid cells, so that only the required data chunks are read in. This can significantly speed up the processing of high resolution compressed datasets. Here is an example of selecting only the grid point with the index 1234:
cdo --query cell=1234 info infile
Use the CDO gridcellindex operator to find the cell index based on the longitude and latitude coordinates.