Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Aidan py tests for Xeff #93

Merged
merged 12 commits into from
Jun 4, 2024
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -105,3 +105,6 @@ TEMP/

# Slurm log files
slurm-*.out

# Run information
tests\data\h5_pytest.h5
24 changes: 11 additions & 13 deletions pvdeg/standards.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,27 +133,25 @@ def eff_gap(T_0, T_inf, T_measured, T_ambient, poa, x_0=6.5, poa_min=400, t_amb_

Parameters
----------
T_0 : float
T_0 : pd.series
An array of temperature values for a module with an insulated back or an
alternatively desired small or zero standoff. Used as the basis for the
maximum achievable temperature, [°C].
T_inf : float
T_inf : pd.series
An array of temperature values for a module that is rack mounted, [°C].
T_measured : float
T_measured : pd.series
An array of values for the measured module temperature, [°C].
T_ambient : float
T_ambient : pd.series
An array of values for the ambient temperature, [°C].
poa : float
An array of values for the plane of array irradiance, [W/m²].
poa : pd.series
An array of values for the plane of array irradiance, [W/m²]
x_0 : float, optional
Thermal decay constant [cm], [Kempe, PVSC Proceedings 2023].
According to edition 2 of IEC TS 63126 a value of 6.5 cm is recommended.
poa_min : float
The minimum value for which the data will be used, [W/m²].
400 W/m² is recommended.
t_amb_min : float
The minimum ambient temperature for which the calculation will be made, [°C].
A value of 0 °C is recommended to avoid data where snow might be present.
poa_min : float, optional
Minimum iradiance
t_ambient_min : floa, optional
Minimum am

Returns
-------
Expand All @@ -172,7 +170,7 @@ def eff_gap(T_0, T_inf, T_measured, T_ambient, poa, x_0=6.5, poa_min=400, t_amb_
summ = 0
for i in range(0, len(T_0)):
if T_ambient.iloc[i] > t_amb_min:
if poa.poa_global.iloc[i] > poa_min:
if poa.iloc[i] > poa_min:
n = n + 1
summ = summ + (T_0.iloc[i] - T_measured.iloc[i]) / (
T_0.iloc[i] - T_inf.iloc[i]
Expand Down
1 change: 1 addition & 0 deletions pvdeg/weather.py
Original file line number Diff line number Diff line change
Expand Up @@ -308,6 +308,7 @@ def map_weather(weather_df):
"Wind Direction": "wind_direction",
"Surface Albedo": "albedo",
"Precipitable Water": "precipitable_water",
"Module_Temperature": "module_temperature",
}

for column_name in weather_df.columns:
Expand Down
52,561 changes: 52,561 additions & 0 deletions tests/data/weather_year_T0Tinfx0_test.csv

Large diffs are not rendered by default.

8,763 changes: 8,763 additions & 0 deletions tests/data/xeff_test.csv

Large diffs are not rendered by default.

21 changes: 19 additions & 2 deletions tests/test_standards.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,10 +72,27 @@ def test_standoff():
expected_result_l2 = {"x": 0, "T98_0": 79.074638, "T98_inf": 53.982905}

df_expected_result_l2 = pd.DataFrame.from_dict(expected_result_l2, orient="index").T
print(result_l1)
print(result_l2)

pd.testing.assert_frame_equal(result_l1, df_expected_result_l1)
pd.testing.assert_frame_equal(result_l2, df_expected_result_l2)

def test_eff_gap():
weather_file = os.path.join(TEST_DATA_DIR,'xeff_test.csv')
xeff_weather, xeff_meta = pvdeg.weather.read(weather_file,'csv')
T_0, T_inf, xeff_poa = pvdeg.standards.eff_gap_parameters(
weather_df = xeff_weather,
meta = xeff_meta,
sky_model = "isotropic",
temp_model = "sapm",
conf_0 = "insulated_back_glass_polymer",
conf_inf = "open_rack_glass_polymer",
wind_factor = 0.33)
eff_gap = pvdeg.standards.eff_gap(T_0, T_inf, xeff_weather['module_temperature'], xeff_weather["temp_air"], xeff_poa["poa_global"], x_0=6.5, poa_min=400, t_amb_min=0)

assert eff_gap==pytest.approx(3.6767284845789825)




# assert expected_result_l1 == pytest.approx(result_l1)
# assert expected_result_l2 == pytest.approx(result_l2, abs=1e-5)
10 changes: 10 additions & 0 deletions tests/test_weather.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,16 @@
META_KEYS = [""]



def test_colum_name():
df, meta_data=pvdeg.weather.read(
os.path.join(TEST_DATA_DIR, "psm3_pytest.csv"),"csv"
)
assert "City" in meta_data.keys()
assert "tz" in meta_data.keys()
assert "Year" in df
assert "dew_point" in df

def test_get():
"""
Test with (lat,lon) and gid options
Expand Down