V1.0.1 - Added terminal info query functions
π Release v1.0.1 - Information Operators as Query Terminators
This release brings a major enhancement to the Query API: all CDO information operators are now available as terminating methods directly on CDOQuery. Extract metadata from processed data without intermediate files, making workflows more intuitive and efficient.
β¨ New Features
Information Operators as Terminating Query Methods
All 15 CDO information operators can now be called directly on query chains, executing immediately (like .compute()) but returning metadata instead of datasets:
Variable Information Methods:
.showname()- Get list of variable names.showcode()- Get list of variable codes.showunit()- Get list of variable units.showlevel()- Get list of vertical levels
Time Information Methods:
.showdate()- Get list of dates (YYYY-MM-DD format).showtime()- Get list of times (HH:MM:SS format).ntime()- Get number of timesteps (alias for.count())
Count Methods:
.nvar()- Get number of variables.nlevel()- Get number of vertical levels
Structured Dataset Information:
.sinfo()βSinfoResult- Comprehensive dataset summary.info()βInfoResult- Timestep-by-timestep statistics.vlist()βVlistResult- Variable list with metadata.partab()βPartabResult- Parameter table information
Grid Information:
.griddes()βGriddesResult- Grid description.zaxisdes()βZaxisdesResult- Vertical axis description
Key Benefits
- No intermediate files needed when inspecting processed data
- Chain processing and metadata extraction in a single pipeline
- Consistent Query API pattern following Django ORM conventions
- Works with or without operators in the pipeline
π Example Usage
from python_cdo_wrapper import CDO
cdo = CDO()
# Get variable names after processing - no intermediate file!
vars = cdo.query("data.nc").year_mean().showname()
# Returns: ['tas', 'pr', 'psl']
# Get number of timesteps after selection
n = cdo.query("data.nc").select_year(2020).ntime()
# Returns: 12
# Get dates after complex processing
dates = (
cdo.query("data.nc")
.select_var("tas")
.select_year(2020, 2021)
.showdate()
)
# Returns: ['2020-01-01', '2020-02-01', ..., '2021-12-01']
# Get comprehensive dataset info after processing
```python
# Get structured dataset info after processing
info = cdo.query("data.nc").year_mean().sinfo()
print(f"Variables: {info.var_names}")
print(f"Time range: {info.time_range}")
# Get grid info after remapping
grid = cdo.query("data.nc").remap_bil("r180x90").griddes()
print(f"Grid type: {grid.grids[0].gridtype}")
print(f"Grid size: {grid.grids[0].xsize} x {grid.grids[0].ysize}")π§ Improvements
-
Parser Enhancements: Improved
SinfoParserandPartabParserrobustness- Fixed variable name handling in
SinfoParser(sinfo only provides parameter IDs) - Enhanced regex patterns in
PartabParserfor better field extraction - Better error handling for optional fields and edge cases
- Fixed variable name handling in
-
Test Data Quality: Upgraded test fixtures to CF-1.8 compliant standards
- Changed
temperatureβtas(standard CF variable name) - Added proper GRIB parameter codes (tas=167, pr=228, psl=151)
- Improved NetCDF encoding and coordinate attributes
- Changed
-
Type Safety: Added proper type casting with
typing.castfor better IDE support -
Documentation: Added comprehensive example script
examples/info_operators_example.py -
Agent Configuration: Updated GitHub Copilot agent tool definitions
Backward Compatibility
Fully backward compatible - all existing code continues to work without changes. The new methods are additions to the Query API and don't affect existing functionality.
Recommended migration (optional):
# Old way (still works)
cdo.showname("data.nc")
# New way (recommended for processed data)
cdo.query("data.nc").year_mean().showname() # No intermediate file!Installation
pip install --upgrade python-cdo-wrapperFull Changelog: v1.0.0...v1.0.1