draft at test, not yet run, not yet correct

this is a bit of an integrated test.  also need to test each part of the
sequence of actions, as noted in the fixme in lib/reduce.js

modified:   lib/reduce.js
modified:   test/test_limited_hpms.js
panic commit battery low

modified:   test/test_data_tasks.js
new file:   test/test_reduce_2.js
modified:   test/test_reduce_codes.js
modified sql query to get trucks, truck miles traveled

query pct daily single unit trucks, pct daily combination trucks,
multiply by aadt, etc.

modified:   sql/scratch.sql
added scratch work for the sql query

modified:   lib/query_postgres.js
added sql query

modified:   test/test_query_postgres.js
test passes, verifies that single unit miles traveled and combination
truck miles traveled is less than total vmt
in the middle of something

need to save and commit and push because my laptop is wildly unstable

In the middle of hacking a reduce summing function

need to create a function to properly define fractions (whether hpms or
detector fractions), then cross the fractions with the functional class
values (vmt, aadt, single_unit_mt, combination_mt) by hour

These then need to get stashed and summed by area, using the checkout
and done mechanisms I've set up in case the process crashes halfway
through (which it will, no doubt)
tests passing for reduce

I can reduce and merge hpms aadt and grid hourly fractions.  Apparently.

Haven't actually checked any values yet.
scale working properly, lane miles are right

corrected mistake in saving lane miles quite a bit redundant because it
is the same entry for all of the records, perhaps remove it.

modified:   lib/reduce.js

trimmed some tests so that a different grid cell can be run.  added
tests to verify that lane miles are always the same as initially grabbed
from database for grid, road class

modified:   test/test_reduce_sql_and_couchdb.js
doubled up on the tests, testing both grids

minor whitespace
modified:   lib/reduce.js

copied test, made one for detector grid, one for non-detector grid, and
removed commented code for the detector grid to double check that
getting what expected.
modified:   test/test_reduce_sql_and_couchdb.js
accumulate and reduce works.

testing on live data.  taking an age.  something might be awry?

modified:   lib/reduce.js
new file:   test/test_accumulate_grids.js
new file:   test/test_real_db.js
test is passing for running against live db

buncha bugs in couchdb access libs with setting couch url via the
options

some debug stuff if couch url is wrong
modified:   lib/couchdb_interactions.js

fixed use of node-postgres, call client done properly
modified:   lib/query_postgres.js

added diagnostic checks
modified:   test/test_real_db.js
big hack, unfinished, to save records and also oops fixing

forgot to add in the detector-based counts, etc

added code to do so, untested.

working on the flatten code to write a big data record to couchdb
something is wrong with reducing detector records,

pushing to test on remote machine
hunting the bug
hunting the bug, narrowing it down
remove detector data stuff from hpms _.each

also use record, not item.detector_data
big commit.  flatten sort of works, with issues

minor issues.  grid cells not in doc.  want to track removed from hpms data
hacking on tracking grid_Cells
that didn't work, go back to setting outside of loop

set grid_cells in result object outside of flatten and reduce loops
update query_postgres to limit by the length in grid cell

Before was using hpms length every time.  That resulted in multiple
counting, because roads cut across multiple grids. Now multiply the road
length inthe grid by fraction of the road in the grid
ignore temp files
dump a couchdb file to csv in order to compute the expected values