Skip to content

Commit

Permalink
Merge pull request #276 from PyPSA/extend-pre-commit
Browse files Browse the repository at this point in the history
extend pre-commit yaml
  • Loading branch information
FabianHofmann authored Feb 22, 2023
2 parents 1d9f184 + 6272e64 commit bab679f
Show file tree
Hide file tree
Showing 75 changed files with 1,067 additions and 738 deletions.
4 changes: 2 additions & 2 deletions .coveragerc
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
[run]
branch = True
source = atlite
omit =
omit =
test/*
setup.py
atlite/datasets/ncep*
atlite/datasets/cordex*
atlite/datasets/cordex*
2 changes: 0 additions & 2 deletions .github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,5 +39,3 @@ SPDX-License-Identifier: CC0-1.0
<!-- output of `conda list` -->
```
</details>


45 changes: 44 additions & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,58 @@ repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.4.0
hooks:
- id: check-yaml
- id: check-merge-conflict
- id: end-of-file-fixer
- id: fix-encoding-pragma
- id: mixed-line-ending
- id: trailing-whitespace
- id: check-added-large-files
args: ['--maxkb=2000']

# Sort package imports alphabetically
- repo: https://github.com/PyCQA/isort
rev: 5.12.0
hooks:
- id: isort
args: ["--profile", "black", "--filter-files"]

# Convert relative imports to absolute imports
- repo: https://github.com/MarcoGorelli/absolufy-imports
rev: v0.3.1
hooks:
- id: absolufy-imports

# Find common spelling mistakes in comments and docstrings
- repo: https://github.com/codespell-project/codespell
rev: v2.2.2
hooks:
- id: codespell
args: ['--ignore-regex="(\b[A-Z]+\b)"'] # Ignore capital case words, e.g. country codes
types_or: [python, rst, markdown]
files: ^(scripts|doc)/

# Make docstrings PEP 257 compliant
- repo: https://github.com/PyCQA/docformatter
rev: v1.5.1
hooks:
- id: docformatter
args: ['--in-place', '--make-summary-multi-line', '--pre-summary-newline']

# Formatting with "black" coding style
- repo: https://github.com/psf/black
rev: 23.1.0
hooks:
# Format Python files
- id: black
# Format Jupyter Python notebooks
- id: black-jupyter

- repo: https://github.com/fsfe/reuse-tool
rev: v1.1.2
hooks:
- id: reuse

# Do YAML formatting (before the linter checks it for misses)
- repo: https://github.com/macisamuele/language-formatters-pre-commit-hooks
rev: v2.7.0
hooks:
Expand Down
1 change: 0 additions & 1 deletion .reuse/dep5
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,3 @@ License: CC-BY-4.0
Files: doc/examples/*.nblink
Copyright: 2020 - 2023 The Atlite Authors
License: CC-BY-4.0

2 changes: 1 addition & 1 deletion CITATION.cff
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ repository: "https://github.com/PyPSA/atlite"
version: "0.2.5"
date-released: "2021-06-24"
license: "MIT"
authors:
authors:
- family-names: "Hofmann"
given-names: "Fabian"
orcid: "https://orcid.org/0000-0002-6604-5450"
Expand Down
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ SPDX-FileCopyrightText: 2021 The Atlite Authors
SPDX-License-Identifier: CC0-1.0
--->

Atlite's contributor guidelines can be found in the official [documentation](https://atlite.readthedocs.io/en/master/contributing.html).
Atlite's contributor guidelines can be found in the official [documentation](https://atlite.readthedocs.io/en/master/contributing.html).
10 changes: 5 additions & 5 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ It is designed to be lightweight, keeping computing resource requirements (CPU,
It is therefore well suited to be used with big weather datasets.

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

If you have any ideas, suggestions or encounter problems, feel invited
to file issues or make pull requests on GitHub.
to file issues or make pull requests on GitHub.
A `Discord server <https://discord.gg/AnuJBk23FU>`_ hosts every tool
in the PyPSA ecosystem. We have there public voice and text channels
that are suitable to organise projects, ask questions,
Expand Down Expand Up @@ -179,4 +179,4 @@ See the individual files for license details.
.. |joss| image:: https://joss.theoj.org/papers/10.21105/joss.03294/status.svg
:target: https://doi.org/10.21105/joss.03294
.. |discord| image:: https://img.shields.io/discord/911692131440148490?logo=discord
:target: https://discord.gg/AnuJBk23FU
:target: https://discord.gg/AnuJBk23FU
58 changes: 29 additions & 29 deletions RELEASE_NOTES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ Upcoming Release
Version 0.2.10
==============

* atlite now supports shapely >= v2.0.
* atlite now supports shapely >= v2.0.
* Bugfix: For certain time spans, the ERA5 influx data would be incorrectly shifted by 12 hours.
This is now fixed and influx data is **always** shifted by minus 30 minutes.
See `#256 <https://github.com/PyPSA/atlite/issues/256#issuecomment-1271446531>`_ for details.
Expand Down Expand Up @@ -52,13 +52,13 @@ Version 0.2.8
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).
* Bugfix: Avoid NaN values into the hydro inflows

Version 0.2.7
Version 0.2.7
==============

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


Version 0.2.6
Version 0.2.6
==============

* Atlite now supports calculating dynamic line ratings based on the IEEE-738 standard (https://github.com/PyPSA/atlite/pull/189).
Expand All @@ -68,65 +68,65 @@ Version 0.2.6
* 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.
* Automated upload of code coverage reports via Codecov.
* DataArrays returned by `.pv(...)` and `.wind(...)` now have a clearer name and 'units' attribute.
* 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.
* Due to ambiguity, conversion functions (`.pv(...)`, `.wind(...)` etc.) now raise an `ValueError` if shapes and matrix are given.
* 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.
* Due to ambiguity, conversion functions (`.pv(...)`, `.wind(...)` etc.) now raise an `ValueError` if shapes and matrix are given.
* Atlite now supports calculating of heat pump coefficients of performance (https://github.com/PyPSA/atlite/pull/145).
* Enabled the GitHub feature "Cite this repository" to generate a BibTeX file (Added a `CITATION.cff` file to the repository).

**Bug fixes**
* 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
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
from this fix and need to be recreated `cutout.prepare(overwrite=True)`.
* 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.
* 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.


Version 0.2.5
Version 0.2.5
==============

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

Version 0.2.4
Version 0.2.4
==============

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

Version 0.2.3
Version 0.2.3
==============

* The progressbar used in ``atlite.gis.availability_matrix`` is now a `tqdm` progressbar which displays better in parallel executions.
* 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.
* 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.
* The dask version was fixed to a xarray-compatible versions (see https://github.com/dask/dask/issues/7583)

Version 0.2.2
Version 0.2.2
==============

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.
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.

* Fixed compatibility with xarray v0.17.
* 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.
* 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.
* 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'.
* 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.



Version 0.2.1
==============
* 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.
* Exclusion Calculation is now possible with `atlite` (find an usage example at Examples -> Calculate Landuse Availability), Therefore
* 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.
* Exclusion Calculation is now possible with `atlite` (find an usage example at Examples -> Calculate Landuse Availability), Therefore

- 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.
- `Cutout` has a new `availabilitymatrix` function which calculates the overlap of weather cells with shapes while excluding areas based on an `ExclusionContainer`.
- `Cutout` has now a affine transform property (`rasterio.Affine`).
- 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.
- `Cutout` has a new `availabilitymatrix` function which calculates the overlap of weather cells with shapes while excluding areas based on an `ExclusionContainer`.
- `Cutout` has now a affine transform property (`rasterio.Affine`).
* 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.
* Round cutout.dx and cutout.dy in order to prevent precision errors.
* Allow passing keyword arguments to `dask.compute` in `convert_and_aggregate` functions.
* Round cutout.dx and cutout.dy in order to prevent precision errors.
* Allow passing keyword arguments to `dask.compute` in `convert_and_aggregate` functions.
* The Cutout class has a new property `bounds` (same as extent but in different order).

**Breaking Change**
* `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.
* `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.

Version 0.2
===============
Expand All @@ -140,20 +140,20 @@ Version 0.2
appropriate functions or (what we recommended) recreated.
* The backend change also includes some changes to the API.
Most notably:

- The `xarray` for cutouts is now exposed as `Cutout.data`
- The `Cutout.meta` attribute was deprecated in favour of
`Cutout.data.attrs`
- `xarray` and `dask` can now handle some data caching
automatically.
If you wish to preload some data before your calculation,
you can now use `Cutout.data.load()` to load all of the
cutouts data into memory.
cutouts data into memory.
*(Warning: Requires a large enough memory.)*
- The `Cutout` class has a new property `grid`, a GeoPandas DataFrame
- The `Cutout` class has a new property `grid`, a GeoPandas DataFrame
which combines and deprecates `grid_cells()` and `grid_coordinates()`
* 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).
* Following the lead of geopandas, pyproj, cartopy and rasterio, atlite now uses Coordinate Reference System (`CRS`) instead of the old fashioned projection strings.
* Following the lead of geopandas, pyproj, cartopy and rasterio, atlite now uses Coordinate Reference System (`CRS`) instead of the old fashioned projection strings.

**New features**

Expand All @@ -170,7 +170,7 @@ Version 0.2

**Breaking changes**

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

* support negative latitudes to PV panel orientation
* add support for ERA5 back extension to 1950
* add PROJ>=7 valid 'aea' projection string
* add PROJ>=7 valid 'aea' projection string



Expand Down
17 changes: 8 additions & 9 deletions atlite/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,16 @@
"""
Atlite helps you to convert weather data into energy systems model data.
Atlite is a free software, xarray-based Python library for converting weather data
(like wind speeds) into energy systems data. It is designed to by lightweight and
work with big weather datasets while keeping the resource requirements especially
on CPU and RAM resources low.
Atlite is a free software, xarray-based Python library for converting
weather data (like wind speeds) into energy systems data. It is designed
to by lightweight and work with big weather datasets while keeping the
resource requirements especially on CPU and RAM resources low.
"""

from .cutout import Cutout
from .gis import compute_indicatormatrix, regrid, ExclusionContainer
from .resource import windturbines, solarpanels, cspinstallations

from .version import version as __version__
from atlite.cutout import Cutout
from atlite.gis import ExclusionContainer, compute_indicatormatrix, regrid
from atlite.resource import cspinstallations, solarpanels, windturbines
from atlite.version import version as __version__

__author__ = (
"The Atlite Authors: Gorm Andresen (Aarhus University), "
Expand Down
2 changes: 1 addition & 1 deletion atlite/aggregate.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
Functions for aggregating results.
"""

import xarray as xr
import dask
import xarray as xr


def aggregate_matrix(da, matrix, index):
Expand Down
Loading

0 comments on commit bab679f

Please sign in to comment.