fix paths; fix query

This commit is contained in:
Andy Eschbacher
2016-11-28 20:10:51 +00:00
parent 6f400ee2b7
commit b399e883ad
3 changed files with 9 additions and 4 deletions

View File

@@ -4,8 +4,8 @@ CDB_GWR(subquery text, dep_var text, ind_vars text[],
RETURNS table(v1 numeric, v2 numeric, v3 numeric, v4 numeric, v5 numeric, v6 numeric, rowid bigint)
AS $$
from crankshaft.regression import gwr
from crankshaft.regression import gwr_cs
return gwr(subquery, dep_var, ind_vars, fixed, kernel)
return gwr_cs.gwr(subquery, dep_var, ind_vars, fixed, kernel)
$$ LANGUAGE plpythonu;

View File

@@ -202,7 +202,7 @@ def gwr_query(params):
array_agg(ST_X({geom_col})) As x,
array_agg(ST_Y({geom_col})) As y,
array_agg({dep_var}) As dep_var,
%(ind_vars_select)s,
%(ind_vars_select)s
array_agg({id_col}) As rowid
FROM ({subquery}) As q
WHERE

View File

@@ -1,6 +1,8 @@
import numpy as np
from gwr.base.gwr import GWR
from gwr.base.sel_bw import Sel_BW
import plpy
import crankshaft.pysal_utils as pu
def gwr(subquery, dep_var, ind_vars,
@@ -22,8 +24,11 @@ def gwr(subquery, dep_var, ind_vars,
'ind_vars': ind_vars}
try:
query_result = plpy.execute(pu.gwr_query(params))
query = pu.gwr_query(params)
plpy.notice(query)
query_result = plpy.execute(query)
except plpy.SPIError, err:
plpy.notice(query)
plpy.error('Analysis failed: %s' % err)
# TODO: should x, y be centroids? point on surface?