Skip to content

Commit

Permalink
Check if index of temp_amb and irradiance is equal
Browse files Browse the repository at this point in the history
  • Loading branch information
jnnr committed Apr 3, 2020
1 parent 7abb782 commit ae0f295
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/oemof/thermal/concentrating_solar_power.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,9 @@ def csp_precalc(lat, long, collector_tilt, collector_azimuth, cleanliness,

irradiance = (kwargs.get(irradiance_required))

if not temp_amb.index.equals(irradiance.index):
raise IndexError(f"Index of temp_amb and {irradiance_required} have to be the same.")

# Creation of a df with 2 columns
data = pd.DataFrame({'irradiance': irradiance,
't_amb': temp_amb})
Expand Down
16 changes: 16 additions & 0 deletions tests/test_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -326,6 +326,22 @@ def test_calculation_iam_for_a_series():
assert res.eq(result).all()


def test_csp_different_timeindex():
r"""
Test if differing time index raises error.
"""
E_dir_hor = pd.Series([30, 40], index=[1, 2])
t_amb = pd.Series([30, 40], index=[2, 3])
with pytest.raises(IndexError):
csp.csp_precalc(20, 60,
10, 180, 0.9,
0.78, 0.816, 0.0622,
235, 300, t_amb,
-8.65e-4, 8.87e-4,
loss_method='Janotte',
E_dir_hor=E_dir_hor)


def test_csp_wrong_loss_method():
with pytest.raises(ValueError):
df = pd.DataFrame(data={'date': [1, 2], 'E_dir_hor': [
Expand Down

0 comments on commit ae0f295

Please sign in to comment.