1 Star 0 Fork 1

小栈/Detection

forked from yolo/Detection 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
detect_Interpolat.py 1.86 KB
一键复制 编辑 原始数据 按行查看 历史
yolo 提交于 2022-01-11 21:54 . 1.11
'''
插值
'''
import pandas as pd
pd.set_option('display.max_rows', None)
pd.set_option('display.max_columns', None)
pd.set_option('expand_frame_repr',False)
def interp(onetrajdata,threshold):
BEGINTIME = int(onetrajdata.iloc[0]["Unixtime"])
ENDINTIME = int(onetrajdata.iloc[-1]["Unixtime"])
TRAJ_SEGMENT = int(onetrajdata.iloc[0]["traj_segment"])
MMSI = int(onetrajdata.iloc[0]["mmsi"])
timelist = [BEGINTIME]
temp = BEGINTIME
while temp <= ENDINTIME:
temp = temp + threshold
timelist.append(temp)
newdata = pd.DataFrame(
{'Unixtime': timelist, 'mmsi': MMSI, 'longitude': None, 'latitude': None, 'cog': None, 'sog': None,
'shiptype': 0, 'shiplength': 0, 'shipwidth': 0, 'traj_segment': TRAJ_SEGMENT})
tmp = pd.concat([onetrajdata, newdata])
finaldata = tmp.set_index('Unixtime').interpolate(method='index').sort_values(by=['Unixtime']).reset_index()
finaldata = finaldata.drop_duplicates(subset=['mmsi', 'Unixtime']).reset_index(drop=True)
return finaldata
def getinterpdata(data,threshold):
newdata = pd.DataFrame(columns=(
'Unixtime', 'mmsi', 'longitude', 'latitude', 'cog', 'sog', 'shiptype', 'shiplength', 'shipwidth', 'traj_segment'))
MMSIDATA = data['mmsi']
SHIPSMMSI = list(set(MMSIDATA))
shipcount = len(SHIPSMMSI)
for i in range(shipcount):
mmsi = SHIPSMMSI[i]
ONESHIP = data.iloc[:, :][data[data.T.index[1]] == mmsi] # 找出这艘船
TRAJ_SEGMENT = list(set(ONESHIP["traj_segment"])) # 这艘船轨迹段的set集合
for j in (TRAJ_SEGMENT):
ONETRAJ = ONESHIP.iloc[:, :][ONESHIP[ONESHIP.T.index[9]] == j]
finaldata = interp(ONETRAJ, threshold)
tmp = pd.concat([newdata, finaldata])
newdata = tmp
newdata = newdata.sort_values(by=['mmsi', 'Unixtime']).reset_index(drop=True)
return newdata
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/xiaozhan/Detection.git
git@gitee.com:xiaozhan/Detection.git
xiaozhan
Detection
Detection
master

搜索帮助