diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 04689284..822cd9d1 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -3,14 +3,14 @@ ci: repos: - repo: https://github.com/asottile/pyupgrade - rev: v3.17.0 + rev: v3.19.1 hooks: - id: pyupgrade args: ["--py310-plus"] - repo: https://github.com/astral-sh/ruff-pre-commit # Ruff version. - rev: 'v0.6.9' + rev: 'v0.8.6' hooks: - id: ruff args: ["--show-fixes", "--fix"] @@ -28,7 +28,7 @@ repos: args: ['--config', 'pyproject.toml'] - repo: https://github.com/executablebooks/mdformat - rev: 0.7.17 + rev: 0.7.21 hooks: - id: mdformat additional_dependencies: @@ -36,7 +36,7 @@ repos: - mdformat-myst - repo: https://github.com/nbQA-dev/nbQA - rev: 1.8.7 + rev: 1.9.1 hooks: - id: nbqa-black - id: nbqa-ruff @@ -67,7 +67,7 @@ repos: - id: validate-cff - repo: https://github.com/abravalheri/validate-pyproject - rev: v0.20.2 + rev: v0.23 hooks: - id: validate-pyproject diff --git a/doc/bounds.md b/doc/bounds.md index 21d85fcd..fe39abf6 100644 --- a/doc/bounds.md +++ b/doc/bounds.md @@ -14,7 +14,7 @@ `cf_xarray` supports parsing [coordinate bounds](http://cfconventions.org/Data/cf-conventions/cf-conventions-1.10/cf-conventions.html#cell-boundaries) as encoded in the CF `bounds` attribute. A useful feature for incomplete dataset is also the automatic bounds estimation possible through `cf.add_bounds`. This method will estimate the missing bounds by finding the middle points between elements of the given coordinate, but also by extrapolating to find the outer bounds of the grid. This linear estimation works well with rectilinear grids, but it is only a coarse approximation for curvilinear and simple irregular grids. -As an example, we present a "rotated pole" grid. It is defined on a rotated rectilinear grid which uses the `rlat` and `rlon` 1D coordinates, over North America at a resolution of 0.44°. The datasets comes with 2D `lat` and `lon` coordinates. `cf_xarray` will estimate the bounds by linear interpolation (extrapolation at the edges) of the existing `lon` and `lat`, which yields good results on parts of the grid where the rotation is small. However the errors is larger in other places, as seen when visualizing the distance in degrees between the estimated bounds and the true bounds. +As an example, we present a "rotated pole" grid. It is defined on a rotated rectilinear grid which uses the `rlat` and `rlon` 1D coordinates, over North America at a resolution of 0.44°. The datasets comes with 2D `lat` and `lon` coordinates. `cf_xarray` will estimate the bounds by linear interpolation (extrapolation at the edges) of the existing `lon` and `lat`, which yields good results on parts of the grid where the rotation is small. However the errors is larger in other places, as seen when visualizing the distance in degrees between the estimated bounds and the true bounds. ![2d bounds error](2D_bounds_error.png) diff --git a/doc/coord_axes.md b/doc/coord_axes.md index 68665d82..f5fb07bc 100644 --- a/doc/coord_axes.md +++ b/doc/coord_axes.md @@ -55,7 +55,7 @@ This table lists these internal criteria :stub-columns: 1 ``` -Any DataArray that has `standard_name: "latitude"` or `_CoordinateAxisType: "Lat"` or `"units": "degrees_north"` in its `attrs` will be identified as the `"latitude"` variable by cf-xarray. Similarly for other coordinate names. +Any DataArray that has `standard_name: "latitude"` or `_CoordinateAxisType: "Lat"` or `"units": "degrees_north"` in its `attrs` will be identified as the `"latitude"` variable by cf-xarray. Similarly for other coordinate names. ## Axis Names @@ -68,7 +68,7 @@ Similar criteria exist for the concept of "axes". :stub-columns: 1 ``` -## `.axes` and `.coordinates` properties +## `.axes` and `.coordinates` properties Alternatively use the special properties {py:attr}`DataArray.cf.axes` or {py:attr}`DataArray.cf.coordinates` to access the variable names. These properties return dictionaries that map "CF names" to a list of variable names. Note that a list is always returned even if only one variable name matches the name `"latitude"` (for example). diff --git a/doc/custom-criteria.md b/doc/custom-criteria.md index f6daa08d..4faa8437 100644 --- a/doc/custom-criteria.md +++ b/doc/custom-criteria.md @@ -73,7 +73,7 @@ with cfxr.set_options(custom_criteria=salt_criteria): salty ``` -Note that `salty` contains both `salt1` and `salt2`. Without setting these criteria, we would only get `salt1` by default +Note that `salty` contains both `salt1` and `salt2`. Without setting these criteria, we would only get `salt1` by default ```{code-cell} ds.cf[["sea_water_salinity"]] diff --git a/doc/selecting.md b/doc/selecting.md index 0a06e25f..8be19c38 100644 --- a/doc/selecting.md +++ b/doc/selecting.md @@ -30,7 +30,7 @@ CF conventions on 1. [ancillary data](http://cfconventions.org/Data/cf-conventions/cf-conventions-1.8/cf-conventions.html#ancillary-data) ``` -A powerful feature of `cf_xarray` is the ability select DataArrays using special "CF names" like the "latitude", or "longitude" coordinate names, "X" or "Y" axes names, oreven using the `standard_name` attribute if present. +A powerful feature of `cf_xarray` is the ability select DataArrays using special "CF names" like the "latitude", or "longitude" coordinate names, "X" or "Y" axes names, oreven using the `standard_name` attribute if present. To demonstrate this, let's load a few datasets @@ -91,7 +91,7 @@ anc ## Selecting multiple variables -Sometimes a Dataset may contain multiple `X` or multiple `longitude` variables. In that case a simple `.cf["X"]` will raise an error. Instead follow Xarray convention and pass a list `.cf[["X"]]` to receive a Dataset with all available `"X"` variables +Sometimes a Dataset may contain multiple `X` or multiple `longitude` variables. In that case a simple `.cf["X"]` will raise an error. Instead follow Xarray convention and pass a list `.cf[["X"]]` to receive a Dataset with all available `"X"` variables ```{code-cell} multiple.cf[["X"]] @@ -103,7 +103,7 @@ pop.cf[["longitude"]] ## Mixing names -cf_xarray aims to be as friendly as possible, so it is possible to mix "CF names" and normal variable names. Here we select `UVEL` and `TEMP` by using the `standard_name` of `TEMP` (which is `sea_water_potential_temperature`) +cf_xarray aims to be as friendly as possible, so it is possible to mix "CF names" and normal variable names. Here we select `UVEL` and `TEMP` by using the `standard_name` of `TEMP` (which is `sea_water_potential_temperature`) ```{code-cell} pop.cf[["sea_water_potential_temperature", "UVEL"]] diff --git a/doc/sgrid_ugrid.md b/doc/sgrid_ugrid.md index 6e840048..313aee1b 100644 --- a/doc/sgrid_ugrid.md +++ b/doc/sgrid_ugrid.md @@ -65,7 +65,7 @@ variable `grid` list many more dimension names. ### Topology variable -`cf_xarray` supports identifying the `mesh_topology` variable using the `cf_role` attribute. +`cf_xarray` supports identifying the `mesh_topology` variable using the `cf_role` attribute. ## More? diff --git a/doc/units.md b/doc/units.md index 884828fd..67248cc5 100644 --- a/doc/units.md +++ b/doc/units.md @@ -14,9 +14,9 @@ hide-toc: true 1. [CF conventions on units](http://cfconventions.org/Data/cf-conventions/cf-conventions-1.8/cf-conventions.html#units) ``` -The xarray ecosystem supports unit-aware arrays using [pint](https://pint.readthedocs.io) and [pint-xarray](https://pint-xarray.readthedocs.io). Some changes are required to make these packages work well with [UDUNITS format recommended by the CF conventions](http://cfconventions.org/Data/cf-conventions/cf-conventions-1.8/cf-conventions.html#units). +The xarray ecosystem supports unit-aware arrays using [pint](https://pint.readthedocs.io) and [pint-xarray](https://pint-xarray.readthedocs.io). Some changes are required to make these packages work well with [UDUNITS format recommended by the CF conventions](http://cfconventions.org/Data/cf-conventions/cf-conventions-1.8/cf-conventions.html#units). -`cf_xarray` makes those recommended changes when you `import cf_xarray.units`. These changes allow pint to parse and format UDUNIT units strings, and add several custom units like `degrees_north` for latitude, `psu` for ocean salinity, etc. Be aware that pint supports some units that UDUNITS does not recognize but `cf-xarray` will not try to detect them and raise an error. For example, a temperature subtraction returns "delta_degC" units in pint, which does not exist in UDUNITS. +`cf_xarray` makes those recommended changes when you `import cf_xarray.units`. These changes allow pint to parse and format UDUNIT units strings, and add several custom units like `degrees_north` for latitude, `psu` for ocean salinity, etc. Be aware that pint supports some units that UDUNITS does not recognize but `cf-xarray` will not try to detect them and raise an error. For example, a temperature subtraction returns "delta_degC" units in pint, which does not exist in UDUNITS. ## Formatting units