Skip to content

Commit bab679f

Browse files
Merge pull request #276 from PyPSA/extend-pre-commit
extend pre-commit yaml
2 parents 1d9f184 + 6272e64 commit bab679f

File tree

75 files changed

+1067
-738
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

75 files changed

+1067
-738
lines changed

.coveragerc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
[run]
66
branch = True
77
source = atlite
8-
omit =
8+
omit =
99
test/*
1010
setup.py
1111
atlite/datasets/ncep*
12-
atlite/datasets/cordex*
12+
atlite/datasets/cordex*

.github/ISSUE_TEMPLATE/bug_report.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,5 +39,3 @@ SPDX-License-Identifier: CC0-1.0
3939
<!-- output of `conda list` -->
4040
```
4141
</details>
42-
43-

.pre-commit-config.yaml

Lines changed: 44 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,58 @@ repos:
66
- repo: https://github.com/pre-commit/pre-commit-hooks
77
rev: v4.4.0
88
hooks:
9-
- id: check-yaml
9+
- id: check-merge-conflict
10+
- id: end-of-file-fixer
11+
- id: fix-encoding-pragma
12+
- id: mixed-line-ending
13+
- id: trailing-whitespace
14+
- id: check-added-large-files
15+
args: ['--maxkb=2000']
16+
17+
# Sort package imports alphabetically
18+
- repo: https://github.com/PyCQA/isort
19+
rev: 5.12.0
20+
hooks:
21+
- id: isort
22+
args: ["--profile", "black", "--filter-files"]
23+
24+
# Convert relative imports to absolute imports
25+
- repo: https://github.com/MarcoGorelli/absolufy-imports
26+
rev: v0.3.1
27+
hooks:
28+
- id: absolufy-imports
29+
30+
# Find common spelling mistakes in comments and docstrings
31+
- repo: https://github.com/codespell-project/codespell
32+
rev: v2.2.2
33+
hooks:
34+
- id: codespell
35+
args: ['--ignore-regex="(\b[A-Z]+\b)"'] # Ignore capital case words, e.g. country codes
36+
types_or: [python, rst, markdown]
37+
files: ^(scripts|doc)/
38+
39+
# Make docstrings PEP 257 compliant
40+
- repo: https://github.com/PyCQA/docformatter
41+
rev: v1.5.1
42+
hooks:
43+
- id: docformatter
44+
args: ['--in-place', '--make-summary-multi-line', '--pre-summary-newline']
45+
46+
# Formatting with "black" coding style
1047
- repo: https://github.com/psf/black
1148
rev: 23.1.0
1249
hooks:
50+
# Format Python files
1351
- id: black
52+
# Format Jupyter Python notebooks
53+
- id: black-jupyter
54+
1455
- repo: https://github.com/fsfe/reuse-tool
1556
rev: v1.1.2
1657
hooks:
1758
- id: reuse
59+
60+
# Do YAML formatting (before the linter checks it for misses)
1861
- repo: https://github.com/macisamuele/language-formatters-pre-commit-hooks
1962
rev: v2.7.0
2063
hooks:

.reuse/dep5

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,3 @@ License: CC-BY-4.0
1414
Files: doc/examples/*.nblink
1515
Copyright: 2020 - 2023 The Atlite Authors
1616
License: CC-BY-4.0
17-

CITATION.cff

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ repository: "https://github.com/PyPSA/atlite"
1111
version: "0.2.5"
1212
date-released: "2021-06-24"
1313
license: "MIT"
14-
authors:
14+
authors:
1515
- family-names: "Hofmann"
1616
given-names: "Fabian"
1717
orcid: "https://orcid.org/0000-0002-6604-5450"

CONTRIBUTING.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,4 @@ SPDX-FileCopyrightText: 2021 The Atlite Authors
44
SPDX-License-Identifier: CC0-1.0
55
--->
66

7-
Atlite's contributor guidelines can be found in the official [documentation](https://atlite.readthedocs.io/en/master/contributing.html).
7+
Atlite's contributor guidelines can be found in the official [documentation](https://atlite.readthedocs.io/en/master/contributing.html).

README.rst

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ It is designed to be lightweight, keeping computing resource requirements (CPU,
1414
It is therefore well suited to be used with big weather datasets.
1515

1616
.. Atlite is designed to be modular, so that it can work with any weather
17-
.. datasets. It currently has modules for the following datasets:
17+
.. datasets. It currently has modules for the following datasets:
1818
1919
.. * `NCEP Climate Forecast System <http://rda.ucar.edu/datasets/ds094.1/>`_ hourly
2020
.. historical reanalysis weather data available on a 0.2 x 0.2 degree global grid
@@ -38,7 +38,7 @@ Atlite can process the following weather data fields and can convert them into f
3838
.. * Temperature
3939
.. * Downward short-wave radiation
4040
.. * Upward short-wave radiation
41-
.. * Wind
41+
.. * Wind
4242
.. * Runoff
4343
.. * Surface roughness
4444
.. * Height maps
@@ -95,7 +95,7 @@ Documentation
9595
.. * Install atlite from conda-forge or pypi.
9696
.. * Download one of the weather datasets listed above (ERA5 is downloaded
9797
.. automatically on-demand after the ECMWF
98-
.. `cdsapi<https://cds.climate.copernicus.eu/api-how-to>` client is
98+
.. `cdsapi<https://cds.climate.copernicus.eu/api-how-to>` client is
9999
.. properly installed)
100100
.. * Create a cutout, i.e. a geographical rectangle and a selection of
101101
.. times, e.g. all hours in 2011 and 2012, to narrow down the scope -
@@ -111,7 +111,7 @@ Contributing
111111
============
112112

113113
If you have any ideas, suggestions or encounter problems, feel invited
114-
to file issues or make pull requests on GitHub.
114+
to file issues or make pull requests on GitHub.
115115
A `Discord server <https://discord.gg/AnuJBk23FU>`_ hosts every tool
116116
in the PyPSA ecosystem. We have there public voice and text channels
117117
that are suitable to organise projects, ask questions,
@@ -179,4 +179,4 @@ See the individual files for license details.
179179
.. |joss| image:: https://joss.theoj.org/papers/10.21105/joss.03294/status.svg
180180
:target: https://doi.org/10.21105/joss.03294
181181
.. |discord| image:: https://img.shields.io/discord/911692131440148490?logo=discord
182-
:target: https://discord.gg/AnuJBk23FU
182+
:target: https://discord.gg/AnuJBk23FU

RELEASE_NOTES.rst

Lines changed: 29 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ Upcoming Release
2020
Version 0.2.10
2121
==============
2222

23-
* atlite now supports shapely >= v2.0.
23+
* atlite now supports shapely >= v2.0.
2424
* Bugfix: For certain time spans, the ERA5 influx data would be incorrectly shifted by 12 hours.
2525
This is now fixed and influx data is **always** shifted by minus 30 minutes.
2626
See `#256 <https://github.com/PyPSA/atlite/issues/256#issuecomment-1271446531>`_ for details.
@@ -52,13 +52,13 @@ Version 0.2.8
5252
The returned object `masked` (numpy.array) is now dtype `bool` instead of `float64`. This can create broken workflows, if `masked` is not transformed ahead of certain operations (https://github.com/PyPSA/atlite/pull/243).
5353
* Bugfix: Avoid NaN values into the hydro inflows
5454

55-
Version 0.2.7
55+
Version 0.2.7
5656
==============
5757

58-
* The function `SolarPosition` does not return the atmospheric insolation anymore. This data variable was not used by any of the currently supported modules.
58+
* The function `SolarPosition` does not return the atmospheric insolation anymore. This data variable was not used by any of the currently supported modules.
5959

6060

61-
Version 0.2.6
61+
Version 0.2.6
6262
==============
6363

6464
* Atlite now supports calculating dynamic line ratings based on the IEEE-738 standard (https://github.com/PyPSA/atlite/pull/189).
@@ -68,65 +68,65 @@ Version 0.2.6
6868
* The solar position (azimuth and altitude) are now part of the cutout feature `influx`. Cutouts created with earlier versions will become incompatible with the next major.
6969
* Automated upload of code coverage reports via Codecov.
7070
* DataArrays returned by `.pv(...)` and `.wind(...)` now have a clearer name and 'units' attribute.
71-
* If the `matrix` argument in conversion functions (`.pv(...)`, `.wind(...)` etc.) is a `DataArray`, the alignment of the coordinate axis with the cutout grid is double-checked.
72-
* Due to ambiguity, conversion functions (`.pv(...)`, `.wind(...)` etc.) now raise an `ValueError` if shapes and matrix are given.
71+
* If the `matrix` argument in conversion functions (`.pv(...)`, `.wind(...)` etc.) is a `DataArray`, the alignment of the coordinate axis with the cutout grid is double-checked.
72+
* Due to ambiguity, conversion functions (`.pv(...)`, `.wind(...)` etc.) now raise an `ValueError` if shapes and matrix are given.
7373
* Atlite now supports calculating of heat pump coefficients of performance (https://github.com/PyPSA/atlite/pull/145).
7474
* Enabled the GitHub feature "Cite this repository" to generate a BibTeX file (Added a `CITATION.cff` file to the repository).
7575

7676
**Bug fixes**
7777
* The solar position for ERA5 cutouts is now calculated for half a time step earlier (time-shift by `cutout.dt/2`) to account for the aggregated nature of
7878
ERA5 variables (see https://github.com/PyPSA/atlite/issues/158). The fix is only applied to newly created cutouts. Previously created cutouts do not profit
7979
from this fix and need to be recreated `cutout.prepare(overwrite=True)`.
80-
* The functions `make_latitude` and `make_latitude_optimal` were not converting degrees to radian correctly. This resulted in a wrong calculation of the power output when using the orientation `latitude_optimal` or `latitude` in the `pv` conversion function. We are sorry for inconveniences.
80+
* The functions `make_latitude` and `make_latitude_optimal` were not converting degrees to radian correctly. This resulted in a wrong calculation of the power output when using the orientation `latitude_optimal` or `latitude` in the `pv` conversion function. We are sorry for inconveniences.
8181

8282

83-
Version 0.2.5
83+
Version 0.2.5
8484
==============
8585

8686
* Clarification for ``ExclusionContainer.add_raster(..)`` that ``codes=..`` does not accept ``lambda``-functions in combination with ``multiprocessing``.
8787
* Internal change: We are moving to `black` for internal code formatting.
8888
* Fix ignored keywords in convert_and_aggregate(...) for capacity_layout=True.
8989

90-
Version 0.2.4
90+
Version 0.2.4
9191
==============
9292

9393
* Fix cutout merge and update for xarray ``>=v0.18.0`` (https://github.com/PyPSA/atlite/issues/147)
94-
* Set multiprocessing context to ``spawn`` for ensuring equal computation across all platforms.
94+
* Set multiprocessing context to ``spawn`` for ensuring equal computation across all platforms.
9595

96-
Version 0.2.3
96+
Version 0.2.3
9797
==============
9898

9999
* The progressbar used in ``atlite.gis.availability_matrix`` is now a `tqdm` progressbar which displays better in parallel executions.
100-
* The function ``layout_from_capacity_list`` was added to the cutout class. It is a convenience function that calculates the aggregated capacities per cutout grid cells (layout) based on a list of capacities with coordinates, e.g. list of wind turbines.
100+
* The function ``layout_from_capacity_list`` was added to the cutout class. It is a convenience function that calculates the aggregated capacities per cutout grid cells (layout) based on a list of capacities with coordinates, e.g. list of wind turbines.
101101
* The dask version was fixed to a xarray-compatible versions (see https://github.com/dask/dask/issues/7583)
102102

103-
Version 0.2.2
103+
Version 0.2.2
104104
==============
105105

106-
This update is mainly due to fixes in the data handling of the SARAH module. If you work with the SARAH data, we encourage you to update.
106+
This update is mainly due to fixes in the data handling of the SARAH module. If you work with the SARAH data, we encourage you to update.
107107

108108
* Fixed compatibility with xarray v0.17.
109-
* Fixed sarah data for ``dx = dy = 0.05``. Due to the float32 dtype of the sarah coordinates, the cutout coordinates were corrupted when merging. This was fixed in the sarah module by converting the coordinates to float64. This also speeds up the cutout creation for more coarse grained cutouts.
109+
* Fixed sarah data for ``dx = dy = 0.05``. Due to the float32 dtype of the sarah coordinates, the cutout coordinates were corrupted when merging. This was fixed in the sarah module by converting the coordinates to float64. This also speeds up the cutout creation for more coarse grained cutouts.
110110
* Fixed sarah data for a time frequency of 30 minutes. This was raising an assertion error as the (new) pandas frequency string for 30 minutes is '30T' not '30min'.
111111
* Fix the ``regrid`` function in ``atlite.gis`` for target coords which are not having the same bounds as the original ``xarray.Dataset``. The previous implementation was leading to a small shift of coordinates in the preparation of SARAH data.
112112

113113

114114

115115
Version 0.2.1
116116
==============
117-
* The `regrid` function in `atlite.gis` was fixed. The previous implementation set an affine transform starting at the center of a cell at the origin. The corrected transform starts at the real origin (origin of the origin cell). Further a padding of the extent ensures that all values are taken into account in the target projection.
118-
* Exclusion Calculation is now possible with `atlite` (find an usage example at Examples -> Calculate Landuse Availability), Therefore
117+
* The `regrid` function in `atlite.gis` was fixed. The previous implementation set an affine transform starting at the center of a cell at the origin. The corrected transform starts at the real origin (origin of the origin cell). Further a padding of the extent ensures that all values are taken into account in the target projection.
118+
* Exclusion Calculation is now possible with `atlite` (find an usage example at Examples -> Calculate Landuse Availability), Therefore
119119

120-
- a new class `atlite.gis.ExclusionContainer` was added. It serves as a container of rasters and geometries which should be excluded from the landuse availability.
121-
- `Cutout` has a new `availabilitymatrix` function which calculates the overlap of weather cells with shapes while excluding areas based on an `ExclusionContainer`.
122-
- `Cutout` has now a affine transform property (`rasterio.Affine`).
120+
- a new class `atlite.gis.ExclusionContainer` was added. It serves as a container of rasters and geometries which should be excluded from the landuse availability.
121+
- `Cutout` has a new `availabilitymatrix` function which calculates the overlap of weather cells with shapes while excluding areas based on an `ExclusionContainer`.
122+
- `Cutout` has now a affine transform property (`rasterio.Affine`).
123123
* Fix resolution for dx and dy unequal to 0.25: Due to floating point precision errors, loading data with ERA5 corrupted the cutout coordinates. This was fixed by converting the dtype of era5 coordinates to float64 and rounding. Corresponding tests were added.
124-
* Round cutout.dx and cutout.dy in order to prevent precision errors.
125-
* Allow passing keyword arguments to `dask.compute` in `convert_and_aggregate` functions.
124+
* Round cutout.dx and cutout.dy in order to prevent precision errors.
125+
* Allow passing keyword arguments to `dask.compute` in `convert_and_aggregate` functions.
126126
* The Cutout class has a new property `bounds` (same as extent but in different order).
127127

128128
**Breaking Change**
129-
* `Cutout.extent` was adjusted to cover the whole cutout area. The extent is now a numpy array. Before, it indicated the coordinates of the centers of the corner cells.
129+
* `Cutout.extent` was adjusted to cover the whole cutout area. The extent is now a numpy array. Before, it indicated the coordinates of the centers of the corner cells.
130130

131131
Version 0.2
132132
===============
@@ -140,20 +140,20 @@ Version 0.2
140140
appropriate functions or (what we recommended) recreated.
141141
* The backend change also includes some changes to the API.
142142
Most notably:
143-
143+
144144
- The `xarray` for cutouts is now exposed as `Cutout.data`
145145
- The `Cutout.meta` attribute was deprecated in favour of
146146
`Cutout.data.attrs`
147147
- `xarray` and `dask` can now handle some data caching
148148
automatically.
149149
If you wish to preload some data before your calculation,
150150
you can now use `Cutout.data.load()` to load all of the
151-
cutouts data into memory.
151+
cutouts data into memory.
152152
*(Warning: Requires a large enough memory.)*
153-
- The `Cutout` class has a new property `grid`, a GeoPandas DataFrame
153+
- The `Cutout` class has a new property `grid`, a GeoPandas DataFrame
154154
which combines and deprecates `grid_cells()` and `grid_coordinates()`
155155
* The order of coordinates (indices) for `Cutouts` changed: `x` and `y` (e.g. longitude and latitude) are now both ascending (before: `x` ascending and `y` descending).
156-
* Following the lead of geopandas, pyproj, cartopy and rasterio, atlite now uses Coordinate Reference System (`CRS`) instead of the old fashioned projection strings.
156+
* Following the lead of geopandas, pyproj, cartopy and rasterio, atlite now uses Coordinate Reference System (`CRS`) instead of the old fashioned projection strings.
157157

158158
**New features**
159159

@@ -170,7 +170,7 @@ Version 0.2
170170

171171
**Breaking changes**
172172

173-
* The argument `show_progress` of function `atlite.convert.convert_and_aggregate` does not take strings anymore.
173+
* The argument `show_progress` of function `atlite.convert.convert_and_aggregate` does not take strings anymore.
174174
* The argument `layout` of function `atlite.convert.convert_and_aggregate` must be a `xarray.DataArray`.
175175
* Due to the change of the order of coordinates in cutouts the order of coordinates in `matrix` passed to `convert_*` functions
176176
changed likewise: `x` and `y` are both ascending now.
@@ -183,7 +183,7 @@ Version 0.0.4
183183

184184
* support negative latitudes to PV panel orientation
185185
* add support for ERA5 back extension to 1950
186-
* add PROJ>=7 valid 'aea' projection string
186+
* add PROJ>=7 valid 'aea' projection string
187187

188188

189189

atlite/__init__.py

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,17 +7,16 @@
77
"""
88
Atlite helps you to convert weather data into energy systems model data.
99
10-
Atlite is a free software, xarray-based Python library for converting weather data
11-
(like wind speeds) into energy systems data. It is designed to by lightweight and
12-
work with big weather datasets while keeping the resource requirements especially
13-
on CPU and RAM resources low.
10+
Atlite is a free software, xarray-based Python library for converting
11+
weather data (like wind speeds) into energy systems data. It is designed
12+
to by lightweight and work with big weather datasets while keeping the
13+
resource requirements especially on CPU and RAM resources low.
1414
"""
1515

16-
from .cutout import Cutout
17-
from .gis import compute_indicatormatrix, regrid, ExclusionContainer
18-
from .resource import windturbines, solarpanels, cspinstallations
19-
20-
from .version import version as __version__
16+
from atlite.cutout import Cutout
17+
from atlite.gis import ExclusionContainer, compute_indicatormatrix, regrid
18+
from atlite.resource import cspinstallations, solarpanels, windturbines
19+
from atlite.version import version as __version__
2120

2221
__author__ = (
2322
"The Atlite Authors: Gorm Andresen (Aarhus University), "

atlite/aggregate.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88
Functions for aggregating results.
99
"""
1010

11-
import xarray as xr
1211
import dask
12+
import xarray as xr
1313

1414

1515
def aggregate_matrix(da, matrix, index):

0 commit comments

Comments
 (0)