Skip to content

Commit

Permalink
adopt ruff
Browse files Browse the repository at this point in the history
  • Loading branch information
blaylockbk committed Dec 24, 2023
1 parent 29d3d87 commit 4ddb5b0
Show file tree
Hide file tree
Showing 16 changed files with 389 additions and 339 deletions.
47 changes: 23 additions & 24 deletions .github/workflows/tests-python.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ name: Tests (Python)

on:
push:
branches: [ main ]
branches: [main]
pull_request:
branches: [ main ]
branches: [main]

# Allow job to be triggered manually.
workflow_dispatch:
Expand All @@ -21,7 +21,7 @@ jobs:
fail-fast: true
matrix:
os: ["ubuntu-latest"]
python-version: ["3.9", "3.10", "3.11"]
python-version: ["3.9", "3.10", "3.11", "3.12"]
# In order to save resources, only run particular
# matrix slots on other OS than Linux.
include:
Expand All @@ -40,27 +40,26 @@ jobs:

name: Python ${{ matrix.python-version }} on OS ${{ matrix.os }}
steps:
- name: Acquire sources
uses: actions/checkout@v4
with:
fetch-depth: 2

- name: Acquire sources
uses: actions/checkout@v3
with:
fetch-depth: 2
- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
architecture: x64
cache: "pip"
cache-dependency-path: "setup.cfg"

- name: Setup Python
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
architecture: x64
cache: 'pip'
cache-dependency-path: 'setup.cfg'
- name: Install project
run: |
pip3 install --requirement=requirements-test.txt
pip3 install --editable=.
- name: Install project
run: |
pip3 install --requirement=requirements-test.txt
pip3 install --editable=.
- name: Run tests
env:
TMPDIR: ${{ runner.temp }}
run: |
pytest
- name: Run tests
env:
TMPDIR: ${{ runner.temp }}
run: |
pytest
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ goes2go/_version.py

core.*

.ruff_cache

# Don't upload my sandbox notebooks
sandbox*.ipynb

Expand Down
9 changes: 5 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@
<!-- Badges -->

[![](https://img.shields.io/pypi/v/goes2go)](https://pypi.python.org/pypi/goes2go/)
[![Conda Version](https://img.shields.io/conda/vn/conda-forge/goes2go.svg)](https://anaconda.org/conda-forge/goes2go)
[![Conda Version](https://img.shields.io/conda/vn/conda-forge/goes2go.svg)](https://anaconday.org/conda-forge/goes2go)
[![DOI](https://zenodo.org/badge/296737878.svg)](https://zenodo.org/badge/latestdoi/296737878)

![](https://img.shields.io/github/license/blaylockbk/goes2go)
[![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black)
[![Tests (Python)](https://github.com/blaylockbk/goes2g0/actions/workflows/tests-python.yml/badge.svg)](https://github.com/blaylockbk/goes2g0/actions/workflows/tests-python.yml)
[![Ruff](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json)](https://github.com/astral-sh/ruff)
[![Tests (Python)](https://github.com/blaylockbk/goes2go/actions/workflows/tests-python.yml/badge.svg)](https://github.com/blaylockbk/goes2g0/actions/workflows/tests-python.yml)
[![Documentation Status](https://readthedocs.org/projects/goes2go/badge/?version=latest)](https://goes2go.readthedocs.io/?badge=latest)
[![Python](https://img.shields.io/pypi/pyversions/goes2go.svg)](https://pypi.org/project/goes2go/)
[![Conda Recipe](https://img.shields.io/badge/recipe-goes2go-green.svg)](https://anaconda.org/conda-forge/goes2go)
Expand Down Expand Up @@ -155,7 +155,7 @@ There are methods to do the following:

## RGB Recipes

The `rgb` xarray accessor computes various RGB products from a GOES ABI ***ABI-L2-MCMIP*** (multi-channel cloud and moisture imagry products) `xarray.Dataset`. See the [demo](https://goes2go.readthedocs.io/en/latest/user_guide/notebooks/DEMO_rgb_recipes.html#) for more examples of RGB products.
The `rgb` xarray accessor computes various RGB products from a GOES ABI **_ABI-L2-MCMIP_** (multi-channel cloud and moisture imagry products) `xarray.Dataset`. See the [demo](https://goes2go.readthedocs.io/en/latest/user_guide/notebooks/DEMO_rgb_recipes.html#) for more examples of RGB products.

```python
import matplotlib.pyplot as plt
Expand Down Expand Up @@ -215,6 +215,7 @@ I hope you find this makes GOES data easier to retrieve and display. Enjoy!
🌐 [Personal Webpage](http://home.chpc.utah.edu/~u0553130/Brian_Blaylock/home.html)

P.S. If you like GOES-2-go, check out my other python packages

- [🏁 Herbie](https://github.com/blaylockbk/Herbie): download numerical weather model data
- [🌡️ SynopticPy](https://github.com/blaylockbk/SynopticPy): retrieve mesonet data from the Synoptic API.
- [🌹 Pandas-rose](https://github.com/blaylockbk/pandas-rose): easly wind rose from Pandas dataframe.
Expand Down
227 changes: 113 additions & 114 deletions Untitled-1.ipynb

Large diffs are not rendered by default.

66 changes: 35 additions & 31 deletions docs/user_guide/notebooks/DEMO_rgb_Color-IR_Overlay.ipynb

Large diffs are not rendered by default.

Large diffs are not rendered by default.

9 changes: 4 additions & 5 deletions docs/user_guide/notebooks/DEMO_rgb_recipes.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -485,7 +485,6 @@
"rgb_products = [i for i in dir(G16.rgb) if i[0].isupper()]\n",
"\n",
"for product in rgb_products:\n",
"\n",
" fig = plt.figure(figsize=(15, 12))\n",
" ax17 = fig.add_subplot(1, 2, 1, projection=G17.rgb.crs)\n",
" ax16 = fig.add_subplot(1, 2, 2, projection=G16.rgb.crs)\n",
Expand Down Expand Up @@ -567,9 +566,9 @@
}
],
"source": [
"#%config InlineBackend.print_figure_kwargs = {'facecolor' : 'k'}\n",
"# %config InlineBackend.print_figure_kwargs = {'facecolor' : 'k'}\n",
"%config InlineBackend.print_figure_kwargs = {'facecolor' : 'none'}\n",
"#%config InlineBackend.print_figure_kwargs = {'facecolor' : 'w'}\n",
"# %config InlineBackend.print_figure_kwargs = {'facecolor' : 'w'}\n",
"\n",
"fig, (ax1, ax2) = plt.subplots(\n",
" 1, 2, figsize=[20, 10], subplot_kw=dict(projection=g.rgb.crs)\n",
Expand Down Expand Up @@ -599,8 +598,8 @@
"metadata": {},
"outputs": [],
"source": [
"#%config InlineBackend.print_figure_kwargs = {'facecolor' : 'k'}\n",
"#%config InlineBackend.print_figure_kwargs = {'facecolor' : 'none'}\n",
"# %config InlineBackend.print_figure_kwargs = {'facecolor' : 'k'}\n",
"# %config InlineBackend.print_figure_kwargs = {'facecolor' : 'none'}\n",
"%config InlineBackend.print_figure_kwargs = {'facecolor' : 'w'}"
]
},
Expand Down
12 changes: 8 additions & 4 deletions docs/user_guide/notebooks/DEMO_rgb_recipes_docs.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
"from toolbox import EasyMap, pc, ccrs\n",
"\n",
"import matplotlib as mpl\n",
"\n",
"mpl.rcParams[\"font.sans-serif\"] = \"Hubot-Sans\" # or \"Mona-Sans\"\n",
"mpl.rcParams[\"font.monospace\"] = \"Fira Code\""
]
Expand Down Expand Up @@ -847,18 +848,21 @@
"rgb_products = [i for i in dir(G16.rgb) if i[0].isupper()]\n",
"\n",
"for product in rgb_products:\n",
"\n",
" fig = plt.figure(figsize=(10, 6))\n",
" ax17 = fig.add_subplot(1, 2, 1, projection=G17.rgb.crs)\n",
" ax16 = fig.add_subplot(1, 2, 2, projection=G16.rgb.crs)\n",
"\n",
" for ax, G in zip([ax17, ax16], [G17, G16]):\n",
" RGB = getattr(G.rgb, product)()\n",
"\n",
" EasyMap(\"50m\",ax=ax).STATES()\n",
" EasyMap(\"50m\", ax=ax).STATES()\n",
" ax.imshow(RGB, **G.rgb.imshow_kwargs)\n",
" ax.set_title(f\"{G.orbital_slot} {product}\", loc=\"left\", fontweight=\"bold\", fontsize=9)\n",
" ax.set_title(f\"{G.t.dt.strftime('%H:%M UTC %d-%b-%Y').item()} \", loc=\"right\", fontsize=9)\n",
" ax.set_title(\n",
" f\"{G.orbital_slot} {product}\", loc=\"left\", fontweight=\"bold\", fontsize=9\n",
" )\n",
" ax.set_title(\n",
" f\"{G.t.dt.strftime('%H:%M UTC %d-%b-%Y').item()} \", loc=\"right\", fontsize=9\n",
" )\n",
" plt.subplots_adjust(wspace=0.01)\n",
" plt.savefig(f\"../../_static/{product}\", bbox_inches=\"tight\")"
]
Expand Down
6 changes: 3 additions & 3 deletions docs/user_guide/notebooks/field-of-view_GLM_Edges.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -510,7 +510,7 @@
" g.G17_fov_lon_inverted.thin(thin),\n",
" g.G17_fov_lat_inverted.thin(thin),\n",
" label=\"G17 inverted\",\n",
" **kwargs\n",
" **kwargs,\n",
")\n",
"plt.legend(fontsize=8, loc=4)"
]
Expand Down Expand Up @@ -751,15 +751,15 @@
" g.G17_fov_lat.thin(thin),\n",
" color=\"w\",\n",
" label=\"normal (summer)\",\n",
" **kwargs\n",
" **kwargs,\n",
")\n",
"\n",
"ax.scatter(\n",
" g.G17_fov_lon_inverted.thin(thin),\n",
" g.G17_fov_lat_inverted.thin(thin),\n",
" color=\".5\",\n",
" label=\"inverted (winter)\",\n",
" **kwargs\n",
" **kwargs,\n",
")\n",
"plt.legend(loc=4, fontsize=8)"
]
Expand Down
4 changes: 2 additions & 2 deletions docs/user_guide/notebooks/logo.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -100,9 +100,9 @@
}
],
"source": [
"#%config InlineBackend.print_figure_kwargs = {'facecolor' : 'k'}\n",
"# %config InlineBackend.print_figure_kwargs = {'facecolor' : 'k'}\n",
"%config InlineBackend.print_figure_kwargs = {'facecolor' : 'none'}\n",
"#%config InlineBackend.print_figure_kwargs = {'facecolor' : 'w'}\n",
"# %config InlineBackend.print_figure_kwargs = {'facecolor' : 'w'}\n",
"\n",
"\n",
"fig = plt.figure(figsize=(8, 5))\n",
Expand Down
16 changes: 8 additions & 8 deletions goes2go/NEW.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import itertools
import logging
import re
from pathlib import Path

import numpy as np
import pandas as pd
Expand All @@ -21,9 +22,6 @@

log = logging.getLogger(__name__)

# Location of tables directory
from pathlib import Path

tables_dir = Path(__file__).parent

# Connect to AWS public buckets
Expand All @@ -40,7 +38,7 @@


# Assume goes17 and goes18 have same products as goes16
_product = {i.split("/")[-1] for i in fs.ls(f"noaa-goes16")}
_product = {i.split("/")[-1] for i in fs.ls("noaa-goes16")}
_product = set(filter(lambda x: x.split(".")[-1] not in ["pdf", "html"], _product))
_product

Expand All @@ -50,6 +48,8 @@


class GOES:
"""The GOES satellite class."""

def __init__(
self,
satellite=config["timerange"].get("satellite"),
Expand Down Expand Up @@ -160,15 +160,15 @@ def _check_product(self):

def __repr__(self):
msg = [
f"╭───────────────────────────────╌┄┈",
f"│ 🌎 GOES Object ",
f"│ ───────────────",
"╭───────────────────────────────╌┄┈",
"│ 🌎 GOES Object ",
"│ ───────────────",
f"│ {self.satellite=}",
f"│ {self.product=}",
f"│ {self.domain=}",
f"│ {self.bands=}",
f"│ {self.description=}",
f"╰───────────────────────────────╌┄┈",
"╰───────────────────────────────╌┄┈",
]
return "\n".join(msg)

Expand Down
Loading

0 comments on commit 4ddb5b0

Please sign in to comment.