Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# XRLint Change History

## Version 0.5.0 (in development)
## Version 0.5.0 (from 2025-02-13)

### Adjustments and Enhancements

Expand Down
50 changes: 29 additions & 21 deletions docs/rule-ref.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,15 @@ A dataset should provide information about where the data came from and what has
- `no_vars`: do not check variables at all. Defaults to `False`.
- `ignored_vars`: list of ignored variables (regex patterns). Defaults to `['crs', 'spatial_ref']`.

[:material-information-variant:](https://cfconventions.org/cf-conventions/cf-conventions.html#description-of-file-contents)
[More...](https://cfconventions.org/cf-conventions/cf-conventions.html#description-of-file-contents)

Contained in: `all`-:material-lightning-bolt: `recommended`-:material-alert:

### :material-lightbulb: `conventions`

Datasets should identify the applicable conventions using the `Conventions` attribute.
The rule has an optional configuration parameter `match` which is a regex pattern that the value of the `Conventions` attribute must match, if any. If not provided, the rule just verifies that the attribute exists and whether it is a character string.
[:material-information-variant:](https://cfconventions.org/cf-conventions/cf-conventions.html#identification-of-conventions)
[More...](https://cfconventions.org/cf-conventions/cf-conventions.html#identification-of-conventions)

Contained in: `all`-:material-lightning-bolt: `recommended`-:material-alert:

Expand All @@ -41,20 +41,21 @@ Contained in: `all`-:material-lightning-bolt: `recommended`-:material-lightning
### :material-bug: `grid-mappings`

Grid mappings, if any, shall have valid grid mapping coordinate variables.
[More...](https://cfconventions.org/cf-conventions/cf-conventions.html#grid-mappings-and-projections)

Contained in: `all`-:material-lightning-bolt: `recommended`-:material-lightning-bolt:

### :material-bug: `lat-coordinate`

Latitude coordinate should have standard units and standard names.
[:material-information-variant:](https://cfconventions.org/cf-conventions/cf-conventions.html#latitude-coordinate)
[More...](https://cfconventions.org/cf-conventions/cf-conventions.html#latitude-coordinate)

Contained in: `all`-:material-lightning-bolt: `recommended`-:material-lightning-bolt:

### :material-bug: `lon-coordinate`

Longitude coordinate should have standard units and standard names.
[:material-information-variant:](https://cfconventions.org/cf-conventions/cf-conventions.html#longitude-coordinate)
[More...](https://cfconventions.org/cf-conventions/cf-conventions.html#longitude-coordinate)

Contained in: `all`-:material-lightning-bolt: `recommended`-:material-lightning-bolt:

Expand All @@ -67,35 +68,42 @@ Contained in: `all`-:material-lightning-bolt: `recommended`-:material-alert:
### :material-lightbulb: `no-empty-chunks`

Empty chunks should not be encoded and written. The rule currently applies to Zarr format only.
[:material-information-variant:](https://docs.xarray.dev/en/stable/generated/xarray.Dataset.to_zarr.html#xarray-dataset-to-zarr)
[More...](https://docs.xarray.dev/en/stable/generated/xarray.Dataset.to_zarr.html#xarray-dataset-to-zarr)

Contained in: `all`-:material-lightning-bolt: `recommended`-:material-circle-off-outline:

### :material-bug: `time-coordinate`

Time coordinates should have valid and unambiguous time units encoding.
[:material-information-variant:](https://cfconventions.org/cf-conventions/cf-conventions.html#time-coordinate)
[More...](https://cfconventions.org/cf-conventions/cf-conventions.html#time-coordinate)

Contained in: `all`-:material-lightning-bolt: `recommended`-:material-lightning-bolt:

### :material-lightbulb: `var-desc`

Check that each data variable provides an identification and description of the content. The rule can be configured by parameter `attrs` which is a list of names of attributes that provides descriptive information. It defaults to `['standard_name', 'long_name']`.
[:material-information-variant:](https://cfconventions.org/cf-conventions/cf-conventions.html#standard-name)
[More...](https://cfconventions.org/cf-conventions/cf-conventions.html#standard-name)

Contained in: `all`-:material-lightning-bolt: `recommended`-:material-alert:

### :material-lightbulb: `var-flags`

Validate attributes 'flag_values', 'flag_masks' and 'flag_meanings' that make variables that contain flag values self describing.
[:material-information-variant:](https://cfconventions.org/cf-conventions/cf-conventions.html#flags)
[More...](https://cfconventions.org/cf-conventions/cf-conventions.html#flags)

Contained in: `all`-:material-lightning-bolt: `recommended`-:material-lightning-bolt:

### :material-lightbulb: `var-missing-data`

Checks the recommended use of missing data, i.e., coordinate variables should not define missing data, but packed data should. Notifies about the use of valid ranges to indicate missing data, which is currently not supported by xarray.
[More...](https://cfconventions.org/cf-conventions/cf-conventions.html#units)

Contained in: `all`-:material-lightning-bolt: `recommended`-:material-alert:

### :material-lightbulb: `var-units`

Every variable should provide a description of its units.
[:material-information-variant:](https://cfconventions.org/cf-conventions/cf-conventions.html#units)
[More...](https://cfconventions.org/cf-conventions/cf-conventions.html#units)

Contained in: `all`-:material-lightning-bolt: `recommended`-:material-alert:

Expand All @@ -104,70 +112,70 @@ Contained in: `all`-:material-lightning-bolt: `recommended`-:material-alert:
### :material-bug: `any-spatial-data-var`

A datacube should have spatial data variables.
[:material-information-variant:](https://xcube.readthedocs.io/en/latest/cubespec.html#data-model-and-format)
[More...](https://xcube.readthedocs.io/en/latest/cubespec.html#data-model-and-format)

Contained in: `all`-:material-lightning-bolt: `recommended`-:material-lightning-bolt:

### :material-bug: `cube-dims-order`

Order of dimensions in spatio-temporal datacube variables should be [time, ..., y, x].
[:material-information-variant:](https://xcube.readthedocs.io/en/latest/cubespec.html#data-model-and-format)
[More...](https://xcube.readthedocs.io/en/latest/cubespec.html#data-model-and-format)

Contained in: `all`-:material-lightning-bolt: `recommended`-:material-lightning-bolt:

### :material-lightbulb: `data-var-colors`

Spatial data variables should encode xcube color mappings in their metadata.
[:material-information-variant:](https://xcube.readthedocs.io/en/latest/cubespec.html#encoding-of-colors)
[More...](https://xcube.readthedocs.io/en/latest/cubespec.html#encoding-of-colors)

Contained in: `all`-:material-lightning-bolt: `recommended`-:material-alert:

### :material-bug: `dataset-title`

Datasets should be given a non-empty title.
[:material-information-variant:](https://xcube.readthedocs.io/en/latest/cubespec.html#metadata)
[More...](https://xcube.readthedocs.io/en/latest/cubespec.html#metadata)

Contained in: `all`-:material-lightning-bolt: `recommended`-:material-lightning-bolt:

### :material-lightbulb: `grid-mapping-naming`

Grid mapping variables should be called 'spatial_ref' or 'crs' for compatibility with rioxarray and other packages.
[:material-information-variant:](https://xcube.readthedocs.io/en/latest/cubespec.html#spatial-reference)
[More...](https://xcube.readthedocs.io/en/latest/cubespec.html#spatial-reference)

Contained in: `all`-:material-lightning-bolt: `recommended`-:material-alert:

### :material-bug: `increasing-time`

Time coordinate labels should be monotonically increasing.
[:material-information-variant:](https://xcube.readthedocs.io/en/latest/cubespec.html#temporal-reference)
[More...](https://xcube.readthedocs.io/en/latest/cubespec.html#temporal-reference)

Contained in: `all`-:material-lightning-bolt: `recommended`-:material-lightning-bolt:

### :material-bug: `lat-lon-naming`

Latitude and longitude coordinates and dimensions should be called 'lat' and 'lon'.
[:material-information-variant:](https://xcube.readthedocs.io/en/latest/cubespec.html#spatial-reference)
[More...](https://xcube.readthedocs.io/en/latest/cubespec.html#spatial-reference)

Contained in: `all`-:material-lightning-bolt: `recommended`-:material-lightning-bolt:

### :material-lightbulb: `ml-dataset-meta`

Multi-level datasets should provide a '.zlevels' meta-info file, and if so, it should be consistent. Without the meta-info file the multi-level dataset cannot be reliably extended by new time slices as the aggregation method used for each variable must be specified.
[:material-information-variant:](https://xcube.readthedocs.io/en/latest/mldatasets.html#the-xcube-levels-format)
[More...](https://xcube.readthedocs.io/en/latest/mldatasets.html#the-xcube-levels-format)

Contained in: `all`-:material-lightning-bolt: `recommended`-:material-lightning-bolt:

### :material-bug: `ml-dataset-time`

The `time` dimension of multi-level datasets should use a chunk size of 1. This allows for faster image tile generation for visualisation.
[:material-information-variant:](https://xcube.readthedocs.io/en/latest/mldatasets.html#definition)
[More...](https://xcube.readthedocs.io/en/latest/mldatasets.html#definition)

Contained in: `all`-:material-lightning-bolt: `recommended`-:material-alert:

### :material-bug: `ml-dataset-xy`

Multi-level dataset levels should provide spatial resolutions decreasing by powers of two.
[:material-information-variant:](https://xcube.readthedocs.io/en/latest/mldatasets.html#definition)
[More...](https://xcube.readthedocs.io/en/latest/mldatasets.html#definition)

Contained in: `all`-:material-lightning-bolt: `recommended`-:material-lightning-bolt:

Expand All @@ -180,14 +188,14 @@ Contained in: `all`-:material-lightning-bolt: `recommended`-:material-alert:
### :material-bug: `single-grid-mapping`

A single grid mapping shall be used for all spatial data variables of a datacube.
[:material-information-variant:](https://xcube.readthedocs.io/en/latest/cubespec.html#spatial-reference)
[More...](https://xcube.readthedocs.io/en/latest/cubespec.html#spatial-reference)

Contained in: `all`-:material-lightning-bolt: `recommended`-:material-lightning-bolt:

### :material-bug: `time-naming`

Time coordinate and dimension should be called 'time'.
[:material-information-variant:](https://xcube.readthedocs.io/en/latest/cubespec.html#temporal-reference)
[More...](https://xcube.readthedocs.io/en/latest/cubespec.html#temporal-reference)

Contained in: `all`-:material-lightning-bolt: `recommended`-:material-lightning-bolt:

1 change: 1 addition & 0 deletions environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ dependencies:
- tabulate
- xarray
# Dev Dependencies
- isort
- mkdocs
- mkdocs-autorefs
- mkdocs-material
Expand Down
2 changes: 1 addition & 1 deletion mkruleref.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ def write_plugin_rules(stream, plugin: Plugin):
)
stream.write(rule_meta.description or "_No description._")
if rule_meta.docs_url:
stream.write("\n" + f"[:{read_more_icon}:]({rule_meta.docs_url})")
stream.write(f"\n[More...]({rule_meta.docs_url})")
stream.write("\n\n")
# List the predefined configurations that contain the rule
stream.write("Contained in: ")
Expand Down
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ dev = [
# Development tools
"build",
"hatch",
"isort",
"pytest",
"pytest-cov",
"ruff",
Expand Down
2 changes: 1 addition & 1 deletion tests/test_linter.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
from xrlint.config import Config, ConfigObject
from xrlint.constants import CORE_PLUGIN_NAME, DATASET_ROOT_NAME
from xrlint.linter import Linter, new_linter
from xrlint.node import AttrNode, AttrsNode, DatasetNode, VariableNode, DataTreeNode
from xrlint.node import AttrNode, AttrsNode, DatasetNode, DataTreeNode, VariableNode
from xrlint.plugin import new_plugin
from xrlint.processor import ProcessorOp
from xrlint.result import Message, Result
Expand Down
2 changes: 1 addition & 1 deletion xrlint/_linter/apply.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# This software is distributed under the terms and conditions of the
# MIT license (https://mit-license.org/).

from xrlint.node import AttrNode, AttrsNode, DataTreeNode, DatasetNode, VariableNode
from xrlint.node import AttrNode, AttrsNode, DatasetNode, DataTreeNode, VariableNode
from xrlint.rule import RuleConfig, RuleExit, RuleOp

from ..constants import DATASET_ROOT_NAME, DATATREE_ROOT_NAME
Expand Down
5 changes: 1 addition & 4 deletions xrlint/formatters/html.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,7 @@
import html
from collections.abc import Iterable

from xrlint.constants import (
SEVERITY_CODE_TO_COLOR,
SEVERITY_CODE_TO_NAME,
)
from xrlint.constants import SEVERITY_CODE_TO_COLOR, SEVERITY_CODE_TO_NAME
from xrlint.formatter import FormatterContext, FormatterOp
from xrlint.formatters import registry
from xrlint.result import Message, Result, get_rules_meta_for_results
Expand Down
5 changes: 1 addition & 4 deletions xrlint/formatters/simple.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,7 @@

from tabulate import tabulate

from xrlint.constants import (
SEVERITY_CODE_TO_COLOR,
SEVERITY_CODE_TO_NAME,
)
from xrlint.constants import SEVERITY_CODE_TO_COLOR, SEVERITY_CODE_TO_NAME
from xrlint.formatter import FormatterContext, FormatterOp
from xrlint.formatters import registry
from xrlint.result import Message, Result
Expand Down
4 changes: 4 additions & 0 deletions xrlint/plugins/core/rules/grid_mappings.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@
description=(
"Grid mappings, if any, shall have valid grid mapping coordinate variables."
),
docs_url=(
"https://cfconventions.org/cf-conventions/cf-conventions.html"
"#grid-mappings-and-projections"
),
)
class GridMappings(RuleOp):
def validate_dataset(self, ctx: RuleContext, node: DatasetNode):
Expand Down
4 changes: 2 additions & 2 deletions xrlint/result.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,8 +113,8 @@ def warning_count(self) -> int:
@cached_property
def error_count(self) -> int:
"""The number of errors. This includes fixable errors
and fatal errors.
"""
and fatal errors.
"""
return sum(1 if m.severity == SEVERITY_ERROR else 0 for m in self.messages)

@cached_property
Expand Down
2 changes: 1 addition & 1 deletion xrlint/rule.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
import xarray as xr

from xrlint.constants import SEVERITY_ENUM, SEVERITY_ENUM_TEXT
from xrlint.node import AttrNode, AttrsNode, DataTreeNode, DatasetNode, VariableNode
from xrlint.node import AttrNode, AttrsNode, DatasetNode, DataTreeNode, VariableNode
from xrlint.operation import Operation, OperationMeta
from xrlint.result import Suggestion
from xrlint.util.constructible import ValueConstructible
Expand Down
2 changes: 1 addition & 1 deletion xrlint/version.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
# This software is distributed under the terms and conditions of the
# MIT license (https://mit-license.org/).

version = "0.5.0.dev0"
version = "0.5.0"