使用Python计算云的预计到达时间(ETA)?
我在气象站的一个项目中工作,但我被困在了估计到达时间(ETA)的某个项目中,因此,我想应用一种方法来估计云到达某个地点的时间,例如,我将有一个太阳站,然后会有云,但在它们到达太阳站之前,我想计算到达太阳站的预计时间?但它不应该那么准确 这是我目前掌握的数据 从A点到B点>>1km 风速在>>1.5-3.6 m/s之间变化 以下是天气预报代码:使用Python计算云的预计到达时间(ETA)?,python,algorithm,opencv,raspberry-pi,camera,Python,Algorithm,Opencv,Raspberry Pi,Camera,我在气象站的一个项目中工作,但我被困在了估计到达时间(ETA)的某个项目中,因此,我想应用一种方法来估计云到达某个地点的时间,例如,我将有一个太阳站,然后会有云,但在它们到达太阳站之前,我想计算到达太阳站的预计时间?但它不应该那么准确 这是我目前掌握的数据 从A点到B点>>1km 风速在>>1.5-3.6 m/s之间变化 以下是天气预报代码: import pyowm import os from datetime import datetime import warnings warning
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)
我还使用摄影机pi和OpenCV库来遮罩云层
这是云覆盖率的一部分,它将指示何时必须开始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为1000米
- 速度s为3.6至1.5 m/s
- 预计到达时间为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
不过,这只是我对你问题的解决办法
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
只是想澄清一下,因为里面有很多信息,你需要计算一朵云以1.5-3.6米/秒的速度移动1公里需要多长时间。正确吗?@IsaacWP121准确发布更新。提供更多信息我不知道这是否是你想要的,因此发表评论,但是,如果云覆盖率>=50%,你可以得到风速,然后做d/s得到秒数。当风速发生重大变化(取决于你的影响)时(几乎起到缓冲作用,阻止它不断地发出微小变化),你能重新计算d并获得新的预计到达时间吗?@IsaacWP121是的。只是澄清一下,因为其中有很多信息,您需要计算一朵云以1.5-3.6m/s的速率移动1公里所需的时间。正确吗?@IsaacWP121准确发布更新。提供更多信息我不知道这是否是你想要的,因此发表评论,但是,如果云覆盖率>=50%,你可以得到风速,然后做d/s得到秒数。当风速发生重大变化(取决于你的影响程度)时(几乎起到缓冲作用,防止它不断地发出微小变化),你能重新计算d并获得新的预计到达时间吗?@IsaacWP121是。@Ruben helslot。。。。我得到了这个错误:NameError:name'variance\u tolerance'没有定义我也做了一些修改:
而True:if cloud\u coverage>=0.5:eta=1000/风[“speed”]如果abs(风[“speed”]-Data.get\u wind()[“speed”])>偏差公差:风=数据。获取风()#重新分配风变量#重新计算d eta=1000/风[“速度”]#重新计算eta打印('eta=',eta)
@ErrorPath方差_公差变量只是一个占位符变量,用于指示在计算新eta之前需要进行多大的更改。另外@ErrorPath您更改的代码(将d更改为1000)违背了我编写的代码的目的。你如何计算你的位置和云之间的距离?你想给它赋值,当它说#重新计算d时,你就用同样的距离公式来重新计算d@Ruben赫尔斯洛特。。。。我得到了这个错误:NameError:name'variance\u tolerance'没有定义我也做了一些修改:而True:if cloud\u coverage>=0.5:eta=1000/风[“speed”]如果abs(风[“speed”]-Data.get\u wind()[“speed”])>偏差公差:风=数据。获取风()#重新分配风变量#重新计算d eta=1000/风[“速度”]#重新计算eta打印('eta=',eta)
@ErrorPath方差_公差变量只是一个占位符变量,用于指示在计算新eta之前需要进行多大的更改。另外@ErrorPath您更改的代码(将d更改为1000)违背了我编写的代码的目的。你如何计算你的位置和云之间的距离?你想给它赋值,然后当它说#重新计算d时,你用同样的距离公式来重新计算d