mirror of
https://github.com/Akkudoktor-EOS/EOS.git
synced 2025-06-27 16:36: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
|
||||
from typing import Dict, List, Optional, Tuple, Union
|
||||
|
||||
import numpy as np
|
||||
import pandas as pd
|
||||
import pvlib
|
||||
import requests
|
||||
@ -228,6 +229,11 @@ class WeatherBrightSky(WeatherProvider):
|
||||
end_datetime=self.end_datetime,
|
||||
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 (%)")
|
||||
assert key
|
||||
humidity = self.key_to_array(
|
||||
@ -236,6 +242,11 @@ class WeatherBrightSky(WeatherProvider):
|
||||
end_datetime=self.end_datetime,
|
||||
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)
|
||||
pwat = pd.Series(
|
||||
data=data,
|
||||
|
Loading…
x
Reference in New Issue
Block a user