update signature used in plpython function
This commit is contained in:
parent
c5a58f97ec
commit
68e5e0892c
@ -16,7 +16,7 @@ CREATE OR REPLACE FUNCTION
|
|||||||
time_cols text[],
|
time_cols text[],
|
||||||
num_time_per_bin int DEFAULT 1,
|
num_time_per_bin int DEFAULT 1,
|
||||||
permutations INT DEFAULT 99,
|
permutations INT DEFAULT 99,
|
||||||
geom_column TEXT DEFAULT 'the_geom',
|
geom_col TEXT DEFAULT 'the_geom',
|
||||||
id_col TEXT DEFAULT 'cartodb_id',
|
id_col TEXT DEFAULT 'cartodb_id',
|
||||||
w_type TEXT DEFAULT 'knn',
|
w_type TEXT DEFAULT 'knn',
|
||||||
num_ngbrs int DEFAULT 5)
|
num_ngbrs int DEFAULT 5)
|
||||||
@ -25,7 +25,7 @@ AS $$
|
|||||||
plpy.execute('SELECT cdb_crankshaft._cdb_crankshaft_activate_py()')
|
plpy.execute('SELECT cdb_crankshaft._cdb_crankshaft_activate_py()')
|
||||||
from crankshaft.space_time_predictions import spatial_markov
|
from crankshaft.space_time_predictions import spatial_markov
|
||||||
# TODO: use named parameters or a dictionary
|
# TODO: use named parameters or a dictionary
|
||||||
return spatial_markov(subquery, time_cols, permutations, geom_column, id_col, w_type, num_ngbrs)
|
return def spatial_markov_trend(subquery, time_cols, num_time_per_bin, permutations, geom_col, id_col, w_type, num_ngbrs)
|
||||||
$$ LANGUAGE plpythonu;
|
$$ LANGUAGE plpythonu;
|
||||||
|
|
||||||
-- input table format: identical to above but in a predictable format
|
-- input table format: identical to above but in a predictable format
|
||||||
@ -34,48 +34,48 @@ $$ LANGUAGE plpythonu;
|
|||||||
-- 'date_1')
|
-- 'date_1')
|
||||||
|
|
||||||
|
|
||||||
CREATE OR REPLACE FUNCTION
|
-- CREATE OR REPLACE FUNCTION
|
||||||
cdb_spatial_markov (
|
-- cdb_spatial_markov (
|
||||||
subquery TEXT,
|
-- subquery TEXT,
|
||||||
time_col_min text,
|
-- time_col_min text,
|
||||||
time_col_max text,
|
-- time_col_max text,
|
||||||
date_format text, -- '_YYYY_MM_DD'
|
-- date_format text, -- '_YYYY_MM_DD'
|
||||||
num_time_per_bin INT DEFAULT 1,
|
-- num_time_per_bin INT DEFAULT 1,
|
||||||
permutations INT DEFAULT 99,
|
-- permutations INT DEFAULT 99,
|
||||||
geom_column TEXT DEFAULT 'the_geom',
|
-- geom_column TEXT DEFAULT 'the_geom',
|
||||||
id_col TEXT DEFAULT 'cartodb_id',
|
-- id_col TEXT DEFAULT 'cartodb_id',
|
||||||
w_type TEXT DEFAULT 'knn',
|
-- w_type TEXT DEFAULT 'knn',
|
||||||
num_ngbrs int DEFAULT 5)
|
-- num_ngbrs int DEFAULT 5)
|
||||||
RETURNS TABLE (moran FLOAT, quads TEXT, significance FLOAT, ids INT)
|
-- RETURNS TABLE (moran FLOAT, quads TEXT, significance FLOAT, ids INT)
|
||||||
AS $$
|
-- AS $$
|
||||||
plpy.execute('SELECT cdb_crankshaft._cdb_crankshaft_activate_py()')
|
-- plpy.execute('SELECT cdb_crankshaft._cdb_crankshaft_activate_py()')
|
||||||
from crankshaft.clustering import moran_local
|
-- from crankshaft.clustering import moran_local
|
||||||
# TODO: use named parameters or a dictionary
|
-- # TODO: use named parameters or a dictionary
|
||||||
return spatial_markov(subquery, time_cols, permutations, geom_column, id_col, w_type, num_ngbrs)
|
-- return spatial_markov(subquery, time_cols, permutations, geom_column, id_col, w_type, num_ngbrs)
|
||||||
$$ LANGUAGE plpythonu;
|
-- $$ LANGUAGE plpythonu;
|
||||||
|
--
|
||||||
-- input table format:
|
-- -- input table format:
|
||||||
-- id | geom | date | measurement
|
-- -- id | geom | date | measurement
|
||||||
-- 1 | Pt1 | 12/3 | 13.2
|
-- -- 1 | Pt1 | 12/3 | 13.2
|
||||||
-- 2 | Pt2 | 11/5 | 11.3
|
-- -- 2 | Pt2 | 11/5 | 11.3
|
||||||
-- 3 | Pt1 | 11/13 | 12.9
|
-- -- 3 | Pt1 | 11/13 | 12.9
|
||||||
-- 4 | Pt3 | 12/19 | 10.1
|
-- -- 4 | Pt3 | 12/19 | 10.1
|
||||||
-- ...
|
-- -- ...
|
||||||
|
--
|
||||||
CREATE OR REPLACE FUNCTION
|
-- CREATE OR REPLACE FUNCTION
|
||||||
cdb_spatial_markov (
|
-- cdb_spatial_markov (
|
||||||
subquery TEXT,
|
-- subquery TEXT,
|
||||||
time_col text,
|
-- time_col text,
|
||||||
num_time_per_bin INT DEFAULT 1,
|
-- num_time_per_bin INT DEFAULT 1,
|
||||||
permutations INT DEFAULT 99,
|
-- permutations INT DEFAULT 99,
|
||||||
geom_column TEXT DEFAULT 'the_geom',
|
-- geom_column TEXT DEFAULT 'the_geom',
|
||||||
id_col TEXT DEFAULT 'cartodb_id',
|
-- id_col TEXT DEFAULT 'cartodb_id',
|
||||||
w_type TEXT DEFAULT 'knn',
|
-- w_type TEXT DEFAULT 'knn',
|
||||||
num_ngbrs int DEFAULT 5)
|
-- num_ngbrs int DEFAULT 5)
|
||||||
RETURNS TABLE (moran FLOAT, quads TEXT, significance FLOAT, ids INT)
|
-- RETURNS TABLE (moran FLOAT, quads TEXT, significance FLOAT, ids INT)
|
||||||
AS $$
|
-- AS $$
|
||||||
plpy.execute('SELECT cdb_crankshaft._cdb_crankshaft_activate_py()')
|
-- plpy.execute('SELECT cdb_crankshaft._cdb_crankshaft_activate_py()')
|
||||||
from crankshaft.clustering import moran_local
|
-- from crankshaft.clustering import moran_local
|
||||||
# TODO: use named parameters or a dictionary
|
-- # TODO: use named parameters or a dictionary
|
||||||
return spatial_markov(subquery, time_cols, permutations, geom_column, id_col, w_type, num_ngbrs)
|
-- return spatial_markov(subquery, time_cols, permutations, geom_column, id_col, w_type, num_ngbrs)
|
||||||
$$ LANGUAGE plpythonu;
|
-- $$ LANGUAGE plpythonu;
|
||||||
|
Loading…
Reference in New Issue
Block a user