gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-12-02 16:31:04 31 4
gpt4 key购买 nike

我正在为一个气象站进行项目,但是我陷入了估计到达时间(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/

    31 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com