In [1]:
import numpy as np, pandas as pd, os
from synthicity.utils import misc
from drcog.models import regression_model_estimation, choice_model_estimation, dataset
dset = dataset.DRCOGDataset(os.path.join(misc.data_dir(),'drcog.h5'))
In [2]:
import psycopg2
import pandas.io.sql as sql
conn_string = "host='paris.urbansim.org' port=5433 dbname='denver' user='drcog' password='M0untains#'"
conn = psycopg2.connect(conn_string)
cur = conn.cursor()
hh_buffer = sql.read_frame('select * from hh_buffer',conn)
hh_job_buffer = sql.read_frame('select * from hh_job_buffer',conn)
job_buffer = sql.read_frame('select * from job_buffer',conn)
job_hh_buffer = sql.read_frame('select * from job_hh_buffer',conn)
In [19]:
hh_buffer = hh_buffer.set_index('taz05_id')
hh_job_buffer = hh_job_buffer.set_index('taz05_id')
job_buffer = job_buffer.set_index('taz05_id')
job_hh_buffer = job_hh_buffer.set_index('taz05_id')
In [20]:
print hh_buffer
print hh_job_buffer
print job_buffer
print job_hh_buffer
In [7]:
fixed_vars = pd.read_csv('C:\\urbansim\\data\\travel_model\\fixed.csv')
In [13]:
taz = fixed_vars[['TAZ05_ID']]
taz.columns = ['taz05_id']
taz = taz.set_index('taz05_id')
In [23]:
for df in [hh_buffer, hh_job_buffer, job_buffer, job_hh_buffer]:
for column in df.columns:
taz[column] = df[column]
In [25]:
taz = taz.fillna(0)
In [30]:
taz.to_csv('c://users//janowicz//desktop//test_buffers.csv')
In [34]:
taz = taz.rename(columns={'hhvirhhbuffer': 'HouseholdsVirtualHHCentroidBuffer', 'hhvirempbuffer': 'HouseholdsEmpVirtualCentroidBuffer', 'empdensempcentroid': 'EmpDensEmpCentroid',
'eddensempcentroid': 'EdDensEmpCentroid', 'entdensempcentroid': 'EntDensEmpCentroid', 'servdensempcentroid': 'ServDensEmpCentroid',
'proddensempcentroid': 'ProdDensEmpCentroid', 'restaurantdensempcentroid': 'RestaurantDensEmpCentroid', 'retaildensempcentroid': 'RetailDensEmpCentroid',
'restaurantemploymenthouseholdbuffer': 'RestaurantEmploymentHouseholdBuffer', 'retailemploymenthouseholdbuffer': 'RetailEmploymentHouseholdBuffer',
'servdenshhcentroid': 'ServDensHHCentroid', })
In [35]:
taz
Out[35]:
In [38]:
taz['resden'] = taz.HouseholdsVirtualHHCentroidBuffer/1000.0
taz['retden'] = (taz.RestaurantEmploymentHouseholdBuffer + taz.RetailEmploymentHouseholdBuffer)/1000.0
taz['MixedUseDensityHouseholdCentroid'] = (taz.retden*taz.resden)/np.maximum(np.array([.0001]*2804),(taz.retden+taz.resden))
In [40]:
taz['resden'] = taz.HouseholdsEmpVirtualCentroidBuffer/1000.0
taz['retden'] = (taz.RestaurantDensEmpCentroid + taz.RetailDensEmpCentroid)/1000.0
taz['MixedUseDensityEmploymentCentroid'] = (taz.retden*taz.resden)/np.maximum(np.array([.0001]*2804),(taz.retden+taz.resden))
In [41]:
taz.MixedUseDensityEmploymentCentroid
Out[41]:
In [44]:
pc = dset.store.parcel_coords
In [46]:
pc.describe()
Out[46]: