Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update soa readers and the trajectory locust demo. #27

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 7 additions & 6 deletions python/cuspatial/cuspatial/bindings/soa_readers.pyx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from cudf.core import Series
from cudf.core.column import Column
from cudf._lib.cudf import *
from libc.stdlib cimport calloc, malloc, free
Expand All @@ -11,9 +12,9 @@ cpdef cpp_read_uint_soa(soa_file_name):
with nogil:
c_id = read_uint32_soa(c_string)
id_data, id_mask = gdf_column_to_column_mem(&c_id)
id=Column.from_mem_views(id_data,id_mask)
ids=Column.from_mem_views(id_data,id_mask)

return id
return Series(ids)

cpdef cpp_read_ts_soa(soa_file_name):
# print("in cpp_read_ts_soa, reading ",soa_file_name)
Expand All @@ -25,7 +26,7 @@ cpdef cpp_read_ts_soa(soa_file_name):
ts_data, ts_mask = gdf_column_to_column_mem(&c_ts)
ts=Column.from_mem_views(ts_data,ts_mask)

return ts
return Series(ts).astype('datetime64[ms]')

cpdef cpp_read_pnt_lonlat_soa(soa_file_name):
# print("in cpp_read_pnt_lonlat_soa, reading ",soa_file_name)
Expand All @@ -39,7 +40,7 @@ cpdef cpp_read_pnt_lonlat_soa(soa_file_name):
lat_data, lat_mask = gdf_column_to_column_mem(&columns.second)
lat=Column.from_mem_views(lat_data,lat_mask)

return lon,lat
return Series(lon), Series(lat)

cpdef cpp_read_pnt_xy_soa(soa_file_name):
# print("in cpp_read_pnt_xy_soa, reading ",soa_file_name)
Expand All @@ -53,7 +54,7 @@ cpdef cpp_read_pnt_xy_soa(soa_file_name):
y_data, y_mask = gdf_column_to_column_mem(&columns.second)
y=Column.from_mem_views(y_data,y_mask)

return x,y
return Series(x), Series(y)

cpdef cpp_read_polygon_soa(soa_file_name):
# print("in cpp_read_polygon_soa, reading ",soa_file_name)
Expand All @@ -74,5 +75,5 @@ cpdef cpp_read_polygon_soa(soa_file_name):
y_data, y_mask = gdf_column_to_column_mem(c_ply_y)
y=Column.from_mem_views(y_data,y_mask)

return f_pos,r_pos,x,y
return Series(f_pos), Series(r_pos), Series(x), Series(y)

18 changes: 6 additions & 12 deletions python/cuspatial/cuspatial/demos/traj_test_soa_locust.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
import cuspatial.bindings.soa_readers as readers
import cuspatial.utils.traj_utils as tools

data_dir = "/home/jianting/cuspatial/data/"
data_dir = "./"
df = pd.read_csv(data_dir + "its_camera_2.csv")
this_cam = df.loc[df["cameraIdString"] == "HWY_20_AND_LOCUST"]
cam_lon = np.double(this_cam.iloc[0]["originLon"])
Expand All @@ -30,17 +30,11 @@
y, m, d, hh, mm, ss, wd, yd, ms, pid = tools.get_ts_struct(ts_0)

pnt_x, pnt_y = gis.cpp_lonlat2coord(cam_lon, cam_lat, pnt_lon, pnt_lat)
num_traj, tid, len, pos = traj.cpp_coord2traj(pnt_x, pnt_y, id, ts)

num_traj, trajectories = traj.cpp_derive_trajectories(pnt_x, pnt_y, id, ts)
thomcom marked this conversation as resolved.
Show resolved Hide resolved
# = num_traj, tid, len, pos =
y, m, d, hh, mm, ss, wd, yd, ms, pid = tools.get_ts_struct(ts_0)

dist, speed = traj.cpp_traj_distspeed(pnt_x, pnt_y, ts, len, pos)
dist, speed = traj.cpp_trajectory_distance_and_speed(pnt_x, pnt_y, ts, trajectories['length'], trajectories['position'])
print(dist.data.to_array()[0], speed.data.to_array()[0])

x1, y1, x2, y2 = traj.cpp_traj_sbbox(pnt_x, pnt_y, len, pos)
print(
x1.data.to_array()[0],
x2.data.to_array()[0],
y1.data.to_array()[0],
y2.data.to_array()[0],
)
boxes = traj.cpp_trajectory_spatial_bounds(pnt_x, pnt_y, trajectories['length'], trajectories['position'])
print(boxes.head())