使用 Python 计算云的预计到达时间 (ETA)?

Calculate the estimated time of arrival (ETA) of the clouds by using Python?

我正在一个气象站的项目中工作,但我被困在估计到达时间 (ETA) 中,所以,我还想应用一种估计云层到达时间的方法到某个地方,例如,我会有一个太阳能站,然后会有云,但是在它们到达太阳能站之前我想计算预计到达该站的时间?虽然它不应该那么准确。

这是我目前拥有的数据。

从A点到B点>> 1km

风速变化>> 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'],'°')

计算公式如下:

简化的情况很明显:

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

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