mirror of
https://github.com/Akkudoktor-EOS/EOS.git
synced 2025-06-28 00:46:53 +00:00
fix: BrightSky with None humidity data (#555)
Make the BrightSky weather forecast more robust for the case that BrightSky does not provide relative humidity data for a certain location. Signed-off-by: Bobby Noelte <b0661n0e17e@gmail.com>
This commit is contained in:
parent
ccd2f5307c
commit
9959cb14a4
@ -9,6 +9,7 @@ format, enabling consistent access to forecasted and historical weather attribut
|
|||||||
import json
|
import json
|
||||||
from typing import Dict, List, Optional, Tuple, Union
|
from typing import Dict, List, Optional, Tuple, Union
|
||||||
|
|
||||||
|
import numpy as np
|
||||||
import pandas as pd
|
import pandas as pd
|
||||||
import pvlib
|
import pvlib
|
||||||
import requests
|
import requests
|
||||||
@ -228,6 +229,11 @@ class WeatherBrightSky(WeatherProvider):
|
|||||||
end_datetime=self.end_datetime,
|
end_datetime=self.end_datetime,
|
||||||
interval=to_duration("1 hour"),
|
interval=to_duration("1 hour"),
|
||||||
)
|
)
|
||||||
|
if any(x is None or isinstance(x, float) and np.isnan(x) for x in temperature):
|
||||||
|
# We can not calculate PWAT
|
||||||
|
debug_msg = f"Innvalid temperature '{temperature}'"
|
||||||
|
logger.debug(debug_msg)
|
||||||
|
return
|
||||||
key = WeatherDataRecord.key_from_description("Relative Humidity (%)")
|
key = WeatherDataRecord.key_from_description("Relative Humidity (%)")
|
||||||
assert key
|
assert key
|
||||||
humidity = self.key_to_array(
|
humidity = self.key_to_array(
|
||||||
@ -236,6 +242,11 @@ class WeatherBrightSky(WeatherProvider):
|
|||||||
end_datetime=self.end_datetime,
|
end_datetime=self.end_datetime,
|
||||||
interval=to_duration("1 hour"),
|
interval=to_duration("1 hour"),
|
||||||
)
|
)
|
||||||
|
if any(x is None or isinstance(x, float) and np.isnan(x) for x in humidity):
|
||||||
|
# We can not calculate PWAT
|
||||||
|
debug_msg = f"Innvalid humidity '{humidity}'"
|
||||||
|
logger.debug(debug_msg)
|
||||||
|
return
|
||||||
data = pvlib.atmosphere.gueymard94_pw(temperature, humidity)
|
data = pvlib.atmosphere.gueymard94_pw(temperature, humidity)
|
||||||
pwat = pd.Series(
|
pwat = pd.Series(
|
||||||
data=data,
|
data=data,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user