Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions RELEASE_NOTES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,13 @@ Upcoming Release
To use the features already you have to install the ``master`` branch, e.g.
``pip install git+https://github.com/pypsa/atlite``.

**Bug fixes**

* Fill missing irradiation data with zero for ``trigon_model="other"``, as for
``trigon_model="simple"``. Before, cells without data, e.g. north of 65° N in SARAH
cutouts, returned NaN and made aggregated time series NaN
(https://github.com/PyPSA/atlite/pull/528).

`v0.7.0 <https://github.com/PyPSA/atlite/releases/tag/v0.7.0>`__ (3rd October 2026)
=======================================================================================

Expand Down
2 changes: 1 addition & 1 deletion atlite/pv/irradiation.py
Original file line number Diff line number Diff line change
Expand Up @@ -362,7 +362,7 @@ def clip(influx: xr.DataArray, influx_max: xr.DataArray) -> xr.DataArray:
ds, solar_position, surface_orientation, direct + diffuse
)

total_t = direct_t + diffuse_t + ground_t
total_t = direct_t.fillna(0.0) + diffuse_t.fillna(0.0) + ground_t.fillna(0.0)

result: xr.DataArray
if irradiation == "total":
Expand Down
42 changes: 42 additions & 0 deletions test/test_irradiation.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# SPDX-FileCopyrightText: Contributors to atlite <https://github.com/pypsa/atlite>
#
# SPDX-License-Identifier: MIT

"""Tests for the irradiation on tilted surfaces."""

import numpy as np
import pandas as pd
import pytest
import xarray as xr

from atlite.convert import convert_irradiation
from atlite.pv.orientation import get_orientation


@pytest.mark.parametrize("trigon_model", ["simple", "other"])
def test_total_irradiation_is_zero_where_data_is_missing(trigon_model):
time = pd.date_range("2013-06-01 10:00", periods=3, freq="h")
coords = {"time": time, "y": [50.0, 70.0], "x": [5.0]}

def var(values):
return (("time", "y", "x"), np.broadcast_to(values, (3, 2, 1)).copy())

missing = np.array([[1.0], [np.nan]])
ds = xr.Dataset(
{
"influx_toa": var(1000.0),
"influx_direct": var(300.0 * missing),
"influx_diffuse": var(100.0 * missing),
"albedo": var(0.2),
"solar_altitude": var(0.8 * missing),
"solar_azimuth": var(3.0 * missing),
},
coords=coords,
)
ds = ds.assign_coords(lon=("x", coords["x"]), lat=("y", coords["y"]))
orientation = get_orientation({"slope": 30.0, "azimuth": 180.0})

res = convert_irradiation(ds, orientation, trigon_model=trigon_model)

assert (res.sel(y=50.0) > 0).all()
assert (res.sel(y=70.0) == 0).all()
Loading