Skip to content

Commit

Permalink
FIX: Grid attrs and pre-commit hooks
Browse files Browse the repository at this point in the history
  • Loading branch information
rcjackson committed Sep 8, 2024
1 parent bc863d0 commit c7ddacd
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 32 deletions.
5 changes: 4 additions & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ repos:
- id: black
- repo: https://github.com/astral-sh/ruff-pre-commit
# Ruff version.
rev: v0.0.286
rev: v0.6.4
hooks:
# Run the linter.
- id: ruff
# Run the formatter.
- id: ruff-format
32 changes: 16 additions & 16 deletions pydda/io/read_grid.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,19 +42,19 @@ def read_grid(file_name, level_name="parent", **kwargs):
raise IOError("NetCDF file does not contain any valid radar grid fields!")

root["point_x"] = xr.DataArray(_point_data_factory(root, "x"), dims=("z", "y", "x"))
root.attrs["units"] = root["x"].units
root.attrs["long_name"] = "Point x location"
root["point_x"].attrs["units"] = root["x"].attrs["units"]
root["point_x"].attrs["long_name"] = "Point x location"
root["point_y"] = xr.DataArray(_point_data_factory(root, "y"), dims=("z", "y", "x"))
root.attrs["units"] = root["y"].units
root.attrs["long_name"] = "Point y location"
root["point_y"].attrs["units"] = root["y"].attrs["units"]
root["point_y"].attrs["long_name"] = "Point y location"
root["point_z"] = xr.DataArray(_point_data_factory(root, "z"), dims=("z", "y", "x"))
root.attrs["units"] = root["z"].units
root.attrs["long_name"] = "Point z location"
root["point_z"].attrs["units"] = root["z"].attrs["units"]
root["point_z"].attrs["long_name"] = "Point z location"
root["point_altitude"] = xr.DataArray(
_point_altitude_data_factory(root), dims=("z", "y", "x")
)
root.attrs["units"] = root["z"].units
root.attrs["long_name"] = "Point altitude"
root["point_z"].attrs["units"] = root["z"].attrs["units"]
root["point_z"].attrs["long_name"] = "Point altitude"
lon = _point_lon_lat_data_factory(root, 0)
lat = _point_lon_lat_data_factory(root, 1)
root["point_longitude"] = xr.DataArray(lon, dims=("z", "y", "x"))
Expand Down Expand Up @@ -139,23 +139,23 @@ def read_from_pyart_grid(Grid):
new_grid["point_x"] = xr.DataArray(
_point_data_factory(new_grid, "x"), dims=("z", "y", "x")
)
new_grid.attrs["units"] = new_grid["x"].units
new_grid.attrs["long_name"] = "Point x location"
new_grid["point_x"].attrs["units"] = Grid.x["units"]
new_grid["point_x"].attrs["long_name"] = "Point x location"
new_grid["point_y"] = xr.DataArray(
_point_data_factory(new_grid, "y"), dims=("z", "y", "x")
)
new_grid.attrs["units"] = new_grid["y"].units
new_grid.attrs["long_name"] = "Point y location"
new_grid["point_y"].attrs["units"] = Grid.y["units"]
new_grid["point_y"].attrs["long_name"] = "Point y location"
new_grid["point_z"] = xr.DataArray(
_point_data_factory(new_grid, "z"), dims=("z", "y", "x")
)
new_grid.attrs["units"] = new_grid["z"].units
new_grid.attrs["long_name"] = "Point z location"
new_grid["point_z"].attrs["units"] = Grid.z["units"]
new_grid["point_z"].attrs["long_name"] = "Point z location"
new_grid["point_altitude"] = xr.DataArray(
_point_altitude_data_factory(new_grid), dims=("z", "y", "x")
)
new_grid.attrs["units"] = new_grid["z"].units
new_grid.attrs["long_name"] = "Point altitude"
new_grid["point_altitude"].attrs["units"] = Grid.z["units"]
new_grid["point_altitude"].attrs["long_name"] = "Point altitude"
lon = _point_lon_lat_data_factory(new_grid, 0)
lat = _point_lon_lat_data_factory(new_grid, 1)
new_grid["point_longitude"] = xr.DataArray(
Expand Down
27 changes: 14 additions & 13 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,14 +1,3 @@
[tool.ruff]
# Enable the pycodestyle (`E`) and Pyflakes (`F`) rules by default.
# Unlike Flake8, Ruff doesn't enable pycodestyle warnings (`W`) or
# McCabe complexity (`C901`) by default.
select = ["E", "F"]
ignore = ["E402", "F401", "E731", "E501"]

# Allow autofix for all enabled rules (when `--fix`) is provided.
fixable = ["ALL"]
unfixable = []

# Exclude a variety of commonly ignored directories.
exclude = [
".bzr",
Expand All @@ -35,11 +24,23 @@ exclude = [
]
per-file-ignores = {}


# Same as Black.
line-length = 88

# Allow unused variables when underscore-prefixed.
dummy-variable-rgx = "^(_+|(_+[a-zA-Z0-9_]*[a-zA-Z0-9]+?))$"

# Assume Python 3.8
target-version = "py38"
# Assume Python 3.10
target-version = "py310"

[tool.ruff.lint]
# Enable the pycodestyle (`E`) and Pyflakes (`F`) rules by default.
# Unlike Flake8, Ruff doesn't enable pycodestyle warnings (`W`) or
# McCabe complexity (`C901`) by default.
select = ["E", "F"]
ignore = ["E402", "F401", "E731", "E501"]

# Allow autofix for all enabled rules (when `--fix`) is provided.
fixable = ["ALL"]
unfixable = []
3 changes: 1 addition & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
"""


DOCLINES = __doc__.split("\n")

import glob
Expand Down Expand Up @@ -43,7 +42,7 @@
PLATFORMS = "Linux, Windows, OSX"
MAJOR = 2
MINOR = 0
MICRO = 0
MICRO = 1

# SCRIPTS = glob.glob('scripts/*')
# TEST_SUITE = 'nose.collector'
Expand Down

0 comments on commit c7ddacd

Please sign in to comment.