From 2e915764f58dc27bde6741a85cef2806585b280c Mon Sep 17 00:00:00 2001 From: Robert Jackson Date: Thu, 31 Aug 2023 09:31:32 -0500 Subject: [PATCH 1/2] ADD: Pre-commit hooks as actions --- .github/workflows/linting.yml | 31 ++++++++++++++++++++++++ pyproject.toml | 45 +++++++++++++++++++++++++++++++++++ 2 files changed, 76 insertions(+) create mode 100644 .github/workflows/linting.yml create mode 100644 pyproject.toml diff --git a/.github/workflows/linting.yml b/.github/workflows/linting.yml new file mode 100644 index 00000000..597d7569 --- /dev/null +++ b/.github/workflows/linting.yml @@ -0,0 +1,31 @@ +name: linting + +on: + push: + pull_request: + workflow_dispatch: + +jobs: + pre-job: + runs-on: ubuntu-latest + outputs: + should_skip: ${{ steps.skip_check.outputs.should_skip }} + steps: + - id: skip_check + uses: fkirc/skip-duplicate-actions@master + with: + concurrent_skipping: 'same_content' + skip_after_successful_duplicate: 'false' + do_not_skip: '["workflow_dispatch", "schedule"]' + linting: + needs: pre-job + runs-on: ubuntu-latest + if: ${{ needs.pre-job.outputs.should_skip != 'true' }} + steps: + - name: Cancel Previous Runs + uses: styfle/cancel-workflow-action@0.9.1 + with: + access_token: ${{ github.token }} + - uses: actions/checkout@v2 + - uses: actions/setup-python@v2 + - uses: pre-commit/action@v2.0.3 diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 00000000..e97ec826 --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,45 @@ +[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", + ".direnv", + ".eggs", + ".git", + ".git-rewrite", + ".hg", + ".mypy_cache", + ".nox", + ".pants.d", + ".pytype", + ".ruff_cache", + ".svn", + ".tox", + ".venv", + "__pypackages__", + "_build", + "buck-out", + "build", + "dist", + "node_modules", + "venv", +] +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" From 4adb6945e8523b54bdbd8c301817bf1d5ac0eccd Mon Sep 17 00:00:00 2001 From: Robert Jackson Date: Thu, 31 Aug 2023 09:35:37 -0500 Subject: [PATCH 2/2] FIX: Trailing whitespaces in .rst --- doc/source/user_guide/gridding.rst | 33 +++++++++++++----------------- 1 file changed, 14 insertions(+), 19 deletions(-) diff --git a/doc/source/user_guide/gridding.rst b/doc/source/user_guide/gridding.rst index b72bd4d9..4a0c6943 100644 --- a/doc/source/user_guide/gridding.rst +++ b/doc/source/user_guide/gridding.rst @@ -6,7 +6,7 @@ Converting the radar data to Cartesian coordinates with Py-ART PyDDA expects radar data to be in Cartesian coordinates before it retrieves the wind fields. Most radar data, however, is in the radar's native antenna coordinates. Therefore, the radar data needs to be converted to Cartesian -coordinates. Py-ART's mapping toolbox contains the necessary utilties +coordinates. Py-ART's mapping toolbox contains the necessary utilties We will assume that you have followed the steps outlined in :ref:`reading-radar-data` for reading the radar data in its native coordinates. PyDDA requires dealiased velocities @@ -45,14 +45,14 @@ limits of the grid in meters. The :code:`grid_shape` specifies the shape of the points. We then use PyART's `grid_from_radars `_ function to create the grids :code:`grid_sw` and :code:`grid_se`. -.. code-block:: python +.. code-block:: python - grid_sw = pyart.map.grid_from_radars([radar_sw], grid_limits=grid_limits, + grid_sw = pyart.map.grid_from_radars([radar_sw], grid_limits=grid_limits, grid_shape=grid_shape, gatefilter=gatefilter_sw) - grid_se = pyart.map.grid_from_radars([radar_se], grid_limits=grid_limits, + grid_se = pyart.map.grid_from_radars([radar_se], grid_limits=grid_limits, grid_shape=grid_shape, gatefilter=gatefilter_se) -Finally, we should visualize the output grids using Py-ART's +Finally, we should visualize the output grids using Py-ART's `GridMapDisplay `_. .. code-block:: python @@ -60,11 +60,11 @@ Finally, we should visualize the output grids using Py-ART's fig = plt.figure(figsize=(8, 12)) ax1 = plt.subplot(211) display1 = pyart.graph.GridMapDisplay(grid_sw) - display1.plot_latitude_slice('corrected_velocity', lat=36.5, + display1.plot_latitude_slice('corrected_velocity', lat=36.5, ax=ax1, fig=fig, vmin=-30, vmax=30) ax2 = plt.subplot(212) display2 = pyart.graph.GridMapDisplay(grid_se) - display2.plot_latitude_slice('corrected_velocity', lat=36.5, + display2.plot_latitude_slice('corrected_velocity', lat=36.5, ax=ax2, fig=fig, vmin=-30, vmax=30) .. plot:: @@ -129,9 +129,9 @@ Finally, we should visualize the output grids using Py-ART's grid_limits = ((0., 15000.), (-50000., 50000.), (-50000., 50000.)) grid_shape = (31, 201, 201) - grid_sw = pyart.map.grid_from_radars([radar_sw], grid_limits=grid_limits, + grid_sw = pyart.map.grid_from_radars([radar_sw], grid_limits=grid_limits, grid_shape=grid_shape, gatefilter=gatefilter_sw) - grid_se = pyart.map.grid_from_radars([radar_se], grid_limits=grid_limits, + grid_se = pyart.map.grid_from_radars([radar_se], grid_limits=grid_limits, grid_shape=grid_shape, gatefilter=gatefilter_se) fig = plt.figure(figsize=(8, 12)) @@ -141,7 +141,7 @@ Finally, we should visualize the output grids using Py-ART's ax2 = plt.subplot(212) display2 = pyart.graph.GridMapDisplay(grid_se) display2.plot_latitude_slice('corrected_velocity', lat=36.5, ax=ax2, fig=fig, vmin=-30, vmax=30) - + Note that, as the spacing between the sweeps increases with altitude that there can be gridding artifacts that can produce spurious air motion in the @@ -149,7 +149,7 @@ retrievals (Collis et al. 2010). To reduce these artifacts it's important that t field at higher altitudes be as continuous as possible. This requires a grid resolution that will you will need to balance with keeping important details of the feature of interest that you are trying to grid. You may have to adjust your grid resolution to balance these two -concerns in order to properly retrieve wind velocities. With the current grid spacing, +concerns in order to properly retrieve wind velocities. With the current grid spacing, it is apparent that there are discontinuities in the radial velocity field above 7.5 km altitude that could cause spurious noise in the retrieved vertical velocity field. Vertical velocities are likely to be most reliable about 20-40 km from either radar. @@ -163,13 +163,8 @@ https://doi.org/10.1175/2010JTECHA1402.1. Koch, S. E., M. desJardins, and P. J. Kocin, 1983: An Interactive Barnes Objective Map Analysis Scheme for Use with Satellite and Conventional Data. J. Appl. Meteor. Climatol., 22, 1487–1503, -https://doi.org/10.1175/1520-0450(1983)022<1487:AIBOMA>2.0.CO;2. +https://doi.org/10.1175/1520-0450(1983)022<1487:AIBOMA>2.0.CO;2. -Kosiba, K., J. Wurman, Y. Richardson, P. Markowski, P. Robinson, and J. Marquis, 2013: -Genesis of the Goshen County, Wyoming, Tornado on 5 June 2009 during VORTEX2. +Kosiba, K., J. Wurman, Y. Richardson, P. Markowski, P. Robinson, and J. Marquis, 2013: +Genesis of the Goshen County, Wyoming, Tornado on 5 June 2009 during VORTEX2. Mon. Wea. Rev., 141, 1157–1181, https://doi.org/10.1175/MWR-D-12-00056.1. - - - - -