def test_camera_corners(corner): x = [-180.0, 180.0, -180.0, 180.0] y = [-90.0, 90.0, 90.0, -90.0] result = cuspatial.lonlat_to_cartesian(x[corner], y[corner], cudf.Series(x[corner]), cudf.Series(y[corner])) assert_eq(result, cudf.DataFrame({"x": [0.0], "y": [0.0]}))
def test_zeros(): result = cuspatial.lonlat_to_cartesian( 0.0, 0.0, cudf.Series([0.0]), cudf.Series([0.0]) ) cudf.testing.assert_frame_equal( result, cudf.DataFrame({"x": [0.0], "y": [0.0]}) )
def test_half_distance(): result = cuspatial.lonlat_to_cartesian( -180.0, -90.0, cudf.Series([0.0]), cudf.Series([0.0]) ) cudf.testing.assert_frame_equal( result, cudf.DataFrame({"x": [-14142.135623730952], "y": [-10000.0]}) )
def test_longest_distance(): result = cuspatial.lonlat_to_cartesian( -180, -90, cudf.Series([180.0]), cudf.Series([90.0]) ) cudf.testing.assert_frame_equal( result, cudf.DataFrame({"x": [-40000.0], "y": [-20000.0]}) )
def test_values(): cam_lon = -90.66511046 cam_lat = 42.49197018 py_lon = cudf.Series([-90.66518941, -90.66540743, -90.66489239]) py_lat = cudf.Series([42.49207437, 42.49202408, 42.49266787]) # note: x/y coordinates in killometers -km result = cuspatial.lonlat_to_cartesian(cam_lon, cam_lat, py_lon, py_lat) assert_eq( result, cudf.DataFrame({ "x": [0.0064683857, 0.024330807, -0.0178664241], "y": [-0.0115766660, -0.005988880, -0.0775211111], }), )
def test_missing_coords(): with pytest.raises(RuntimeError): result = cuspatial.lonlat_to_cartesian( # noqa: F841 -180.0, -90.0, cudf.Series(), cudf.Series([0.0]))
def test_camera_oob_3(): with pytest.raises(RuntimeError): result = cuspatial.lonlat_to_cartesian( # noqa: F841 0, 100, cudf.Series([0]), cudf.Series([0]))
this_cam = df.loc[df["cameraIdString"] == "HWY_20_AND_LOCUST"] cam_lon = np.double(this_cam.iloc[0]["originLon"]) cam_lat = np.double(this_cam.iloc[0]["originLat"]) lonlats = cuspatial.read_points_lonlat(data_dir + "locust.location") ids = cuspatial.read_uint(data_dir + "locust.objectid") ts = cuspatial.read_its_timestamps(data_dir + "locust.time") # examine binary representatons ts_0 = ts.data.to_array()[0] out1 = format(ts_0, "016x") print(out1) out2 = format(ts_0, "064b") print(out2) y, m, d, hh, mm, ss, wd, yd, ms, pid = get_ts_struct(ts_0) xys = cuspatial.lonlat_to_cartesian(cam_lon, cam_lat, lonlats["lon"], lonlats["lat"]) num_traj, trajectories = cuspatial.derive(xys["x"], xys["y"], ids, ts) # = num_traj, tid, len, pos = y, m, d, hh, mm, ss, wd, yd, ms, pid = get_ts_struct(ts_0) distspeed = cuspatial.distance_and_speed(xys["x"], xys["y"], ts, trajectories["length"], trajectories["position"]) print(distspeed) boxes = cuspatial.spatial_bounds(xys["x"], xys["y"], trajectories["length"], trajectories["position"]) print(boxes.head())