【发布时间】:2021-01-28 21:24:03
【问题描述】:
我正在为一个气象站项目工作,但我陷入了估计到达时间 (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 秒为单位
【问题讨论】:
-
澄清一下,因为里面有很多信息,你想计算一下云以 1.5-3.6m/s 的速度行进 1km 的距离需要多长时间。对吗?
-
@IsaacWP121 完全正确
-
帖子已更新。提供更多信息
-
我不知道这是否是您正在寻找的评论,但是,如果云覆盖率 >= 50%,您可以获得风速,然后执行 d/s 以获得秒数。当风速发生显着变化(取决于你有多显着)时(几乎充当缓冲区以阻止它不断吐出小的变化),你是否能够重新计算 d 并获得新的 eta?
-
@IsaacWP121 是的。
标签: python algorithm opencv raspberry-pi camera