python - 使用Python计算云的估计到达时间(ETA)?

标签 python algorithm opencv raspberry-pi camera

我正在为一个气象站进行项目,但是我陷入了估计到达时间(ETA)的问题,因此,我还想应用一种方法来估计特定地点的云到达时间,例如,我将有一个太阳能站,然后会有云,但是在它们到达太阳能站之前,我想计算到达该站的预计时间?虽然不应该那么准确。
这是我目前拥有的数据。
从地点A到地点B >> 1公里
风速在>> 1.5-3.6 m / s之间变化
这是天气预报的代码:

import pyowm
import os
from datetime import datetime
import warnings

warnings.filterwarnings("ignore", category=DeprecationWarning) 
APIKEY=''
OpenWMap=pyowm.OWM(APIKEY)
Weather=OpenWMap.weather_at_place('Location')
Data=Weather.get_weather()
Weatherforecast = OpenWMap.three_hours_forecast('Location')

date_time = datetime.now().strftime("%d %b %Y | %I:%M:%S")

print ("-------------------------------------------------------------")
print ("Weather Status for - Location || {}".format(date_time))
print ("-------------------------------------------------------------")

temp = Data.get_temperature(unit='celsius')
print ("Average Temp. Currently ", temp['temp'] , '°C')
print ("Max Temp. Currently ", temp['temp_max'], '°C')
print ("Min Temp. Currently ", temp['temp_min'], '°C')


humidity = Data.get_humidity()
print ("Humidity : ",humidity, '%')


wind = Data.get_wind()
print ("Wind Speed : ",wind['speed'], 'm/s')
print ("Wind Direction in Deg : ",wind['deg'],'°')


cloud = Data.get_clouds()
print ("Cloud Coverage Percentage : ",cloud, '%')

weatherstatus = Data.get_status()
weatherstatusdetailed = Data.get_detailed_status()
print ("Weather status : ",weatherstatus)
print ("Weather status with details :",weatherstatusdetailed)

rain=Weatherforecast.will_have_rain()
sun=Weatherforecast.will_have_sun()
cloud=Weatherforecast.will_have_clouds() 

print("There will be rain :",rain)
print("There will be sun :",sun)
print("There will be clouds :",cloud) 
我还在OpenCV库中使用相机pi来遮盖云层,
这是云覆盖的一部分,它将指示必须开始进行ETA计算的时间,因此当云覆盖的百分比为50%或更高时,它将开始。码:
# determine the cloud coverage
    cloud_pixels   = np.count_nonzero(inverted == 255)
    total_pixels   = result.size
    cloud_coverage = cloud_pixels / total_pixels

    # create a mask of where the clouds are
    cloud_image_mask = np.zeros(mask.shape, dtype=np.uint8)
    cloud_image_mask[mask] = inverted.flatten()

    print('Coverage is {:.3f}%'.format(cloud_coverage*100))
    print(datetime.now() - startTime)

    last_dot  = imagepath.rindex('.')
    save_path = imagepath[:last_dot] + '-mask' + imagepath[last_dot:]
    cv2.imwrite(save_path, cloud_image_mask)

    return(cloud_coverage)
这是风速的代码,因此它每隔几分钟或几小时就会变化一次,当它变化时,我希望将其应用。码:
wind = Data.get_wind()
print ("Wind Speed : ",wind['speed'], 'm/s')
print ("Wind Direction in Deg : ",wind['deg'],'°')
这是计算数学:
简化的情况很明显:
  • 距离d为1000m
  • 速度s为3.6至1.5 m / s
  • ETA是d / s = 278至667秒
  • 最佳答案

    这只是我对您问题的解决方案,但是已简化。

    while True:
        If cloud_coverage >= 0.5: # if the cloud coverage is 50% or greater
            eta = d/wind["speed"] # calculate the eta
    
        if abs(wind["speed"] - Data.get_wind()["speed"]) > variance_tolerance: 
        #if the absolute value of the difference between wind["speed"] and an updated wind speed 
        #is greater then the tolerance
            wind = Data.get_wind() #reassign the wind variable
            #recalculate d
            eta = d/wind["speed] #recalculate the eta
    

    关于python - 使用Python计算云的估计到达时间(ETA)?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/64353850/

    相关文章:

    algorithm - 以最快的方式生成所有 n 位二进制数

    java - 使用 OpenCV 从 IP 摄像机流式传输

    我们可以使用 C 代码用 gcc 编译 OpenCv-3.3.0 和 GTK+3 吗?

    algorithm - 最多 3 种颜色算法

    c++ - 通配符字符串搜索算法

    python - 在执行下面的代码时,我得到了这个 'TypeError: img is not a numerical tuple'

    python - 从表单中检索数据?

    python - asyncio.iscoroutinefunction 为异步生成器返回 False

    python - 在Python中解析HTML数据

    python - base64 编码字节 v b64encode v 编码字符串