From 0104e296114218044da100d33edae1cb3aee262d Mon Sep 17 00:00:00 2001 From: Tom Buckley Date: Wed, 13 Apr 2016 12:22:56 -0700 Subject: [PATCH 1/2] building summary based on cut+paste of parcel summ --- baus/summaries.py | 42 ++++++++++++++++++++++++++++++++++++++++++ run.py | 1 + 2 files changed, 43 insertions(+) diff --git a/baus/summaries.py b/baus/summaries.py index dee2b8f64..14e5f5489 100644 --- a/baus/summaries.py +++ b/baus/summaries.py @@ -402,6 +402,48 @@ def pda_output(parcels, households, jobs, buildings, taz_geography, format(run_number, year) df.to_csv(uf_summary_csv) +@orca.step() +def building_summary(parcels, run_number, year, + buildings, + initial_year, final_year): + + if year not in [initial_year, final_year]: + return + + df = orca.merge_tables( + 'buildings', + [parcels, buildings], + columns=['urban_footprint', 'year_built', + 'residential_units','unit_price', + 'zone_id','non_residential_sqft', + 'deed_restricted_units']) + + df2 = df[(df.urban_footprint==1)] + + df2.to_csv( + os.path.join("runs", "run%d_building_data_%d.csv" % + (run_number, year)) + ) + + if year == final_year: + + # do diff with initial year + + df2 = pd.read_csv( + os.path.join("runs", "run%d_building_data_%d.csv" % + (run_number, initial_year)), index_col="building") + + for col in df.columns: + + if col in ["x", "y", "first_building_type_id"]: + continue + + df[col] = df[col] - df2[col] + + df.to_csv( + os.path.join("runs", "run%d_building_data_diff.csv" % + run_number) + ) @orca.step() def parcel_summary(parcels, run_number, year, diff --git a/run.py b/run.py index 012517c5b..e5558665c 100644 --- a/run.py +++ b/run.py @@ -95,6 +95,7 @@ def get_simulation_models(SCENARIO): "topsheet", "parcel_summary", + "building_summary", "diagnostic_output", "geographic_summary", "travel_model_output" From 4a3ddd3a7cc195860a140a7b5b084e45c8c813a1 Mon Sep 17 00:00:00 2001 From: Tom Buckley Date: Thu, 14 Apr 2016 15:48:04 -0700 Subject: [PATCH 2/2] remove csv processing its complicated and we can do it after. not sure this would work --- baus/summaries.py | 20 -------------------- 1 file changed, 20 deletions(-) diff --git a/baus/summaries.py b/baus/summaries.py index 14e5f5489..9f761702f 100644 --- a/baus/summaries.py +++ b/baus/summaries.py @@ -425,26 +425,6 @@ def building_summary(parcels, run_number, year, (run_number, year)) ) - if year == final_year: - - # do diff with initial year - - df2 = pd.read_csv( - os.path.join("runs", "run%d_building_data_%d.csv" % - (run_number, initial_year)), index_col="building") - - for col in df.columns: - - if col in ["x", "y", "first_building_type_id"]: - continue - - df[col] = df[col] - df2[col] - - df.to_csv( - os.path.join("runs", "run%d_building_data_diff.csv" % - run_number) - ) - @orca.step() def parcel_summary(parcels, run_number, year, parcels_zoning_calculations,