validate_dims_coords#
- movement.validators.arrays.validate_dims_coords(data, required_dim_coords)[source]#
Validate dimensions and coordinates in a data array.
This function raises a ValueError if the specified dimensions and coordinates are not present in the input data array.
- Parameters:
data (xarray.DataArray) – The input data array to validate.
required_dim_coords (dict) – A dictionary of required dimensions and their corresponding coordinate values. If you don’t need to specify any coordinate values, you can pass an empty list.
- Return type:
None
Examples
Validate that a data array contains the dimension ‘time’. No specific coordinates are required.
>>> validate_dims_coords(data, {"time": []})
Validate that a data array contains the dimensions ‘time’ and ‘space’, and that the ‘space’ dimension contains the coordinates ‘x’ and ‘y’.
>>> validate_dims_coords(data, {"time": [], "space": ["x", "y"]})
- Raises:
ValueError – If the input data does not contain the required dimension(s) and/or the required coordinate(s).