【问题标题】:Calculate the estimated time of arrival (ETA) of the clouds by using Python?使用 Python 计算云的预计到达时间 (ETA)?
【发布时间】: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


【解决方案1】:

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

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

【讨论】:

  • @Ruben Helsloot .... 我收到此错误:NameError: name 'variance_tolerance' is not defined
  • 我也做了一些这样的改变:while True: if cloud_coverage >= 0.5: eta = 1000/wind["speed"] if abs(wind["speed"] - Data.get_wind()["speed"]) > variance_tolerance: wind = Data.get_wind() #reassign the wind variable #recalculate d eta = 1000/wind["speed"] #recalculate the eta print('ETA = ', eta)
  • @wrongpath variance_tolerance 变量只是一个占位符变量,用于指示在计算新 eta 之前需要进行多大的更改
  • 另外@wrongpath 您更改的代码(将 d 更改为 1000)违背了我编写的代码的目的。你如何计算你的位置和云之间的距离?您想将 d 分配给它,然后当它说 # recalculate d 时,您使用相同的距离公式重新计算 d
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2020-04-04
  • 1970-01-01
  • 2017-01-27
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多