Skip to content

Commit

Permalink
support for shapefile
Browse files Browse the repository at this point in the history
  • Loading branch information
malmans2 committed Nov 13, 2023
1 parent dc2243f commit 9da2712
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 13 deletions.
2 changes: 1 addition & 1 deletion .cruft.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"template": "https://github.com/ecmwf-projects/cookiecutter-conda-package",
"commit": "baa719b04376f091dee7b3f221d3b62eb29d2f95",
"commit": "77c7df5dde1ef90c38d872967939881aa2d7be71",
"checkout": null,
"context": {
"cookiecutter": {
Expand Down
6 changes: 5 additions & 1 deletion .github/workflows/on-push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,11 @@ jobs:
upload-to-pypi:
runs-on: ubuntu-latest
needs: distribution
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags')
if: |
always() &&
needs.distribution.result == 'success' &&
github.event_name == 'push' &&
startsWith(github.ref, 'refs/tags')
environment:
name: pypi
url: https://pypi.org/p/c3s-eqc-automatic-quality-control
Expand Down
9 changes: 3 additions & 6 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,20 +10,17 @@ repos:
- id: check-added-large-files
- id: debug-statements
- id: mixed-line-ending
- repo: https://github.com/psf/black
rev: 23.10.1
hooks:
- id: black
- repo: https://github.com/keewis/blackdoc
rev: v0.3.8
rev: v0.3.9
hooks:
- id: blackdoc
additional_dependencies: [black==22.3.0]
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.1.3
rev: v0.1.5
hooks:
- id: ruff
args: [--fix, --show-fixes]
- id: ruff-format
- repo: https://github.com/executablebooks/mdformat
rev: 0.7.17
hooks:
Expand Down
2 changes: 1 addition & 1 deletion c3s_eqc_automatic_quality_control/_regrid.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ def cached_regridder(
grid_in: xr.Dataset | xr.DataArray,
grid_out: xr.Dataset | xr.DataArray,
method: str,
**kwargs: Any
**kwargs: Any,
) -> xe.Regridder:
if isinstance(grid_in, xr.Dataset):
# Remove bounds attributes, they can generate conflicts
Expand Down
8 changes: 6 additions & 2 deletions c3s_eqc_automatic_quality_control/download.py
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,7 @@ def get_sources(
) -> list[str]:
source: set[str] = set()

for request in request_list if len(request_list) == 1 else tqdm.tqdm(request_list):
for request in tqdm.tqdm(request_list, disable=len(request_list) <= 1):
data = _cached_retrieve(collection_id, request)
if content := getattr(data, "_content", None):
source.update(map(str, content))
Expand Down Expand Up @@ -431,7 +431,11 @@ def _download_and_transform_requests(

if use_emohawk:
data = get_data(sources)
ds: xr.Dataset = data.to_xarray(
if isinstance(data, emohawk.readers.shapefile.ShapefileReader):
to_xarray = data.to_pandas().to_xarray
else:
to_xarray = data.to_xarray
ds: xr.Dataset = to_xarray(
xarray_open_mfdataset_kwargs=open_mfdataset_kwargs,
**TO_XARRAY_KWARGS,
)
Expand Down
8 changes: 6 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,9 @@ ignore = [
# pydocstyle: Missing Docstrings
"D1"
]
# Black line length is 88, but black does not format comments.
line-length = 110
# Same as Black.
indent-width = 4
line-length = 88
select = [
# pyflakes
"F",
Expand All @@ -66,6 +67,9 @@ select = [
]
target-version = "py310"

[tool.ruff.lint.pycodestyle]
max-line-length = 110

[tool.ruff.pydocstyle]
convention = "numpy"

Expand Down

0 comments on commit 9da2712

Please sign in to comment.