Skip to content

Commit

Permalink
when converting to 2010 dollars, check to see if the data has already…
Browse files Browse the repository at this point in the history
… by factored once
  • Loading branch information
Ennazus committed Jun 22, 2015
1 parent c29335e commit a9127f0
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions scripts/utils/convert_hhinc_2000_2010.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,22 @@
hh_file_loc = 'inputs/hh_and_persons.h5'

if not os.path.exists(hh_file_loc):
print 'Oops you cannot convert the synthetic population income to 2010 dollars because you are missing the household file that should be at ' + hh_file_loc
print 'Oops you cannot convert the synthetic population income to 2010 dollars because you are missing the household file that should be at ' + hh_file_loc

hh_file=h5py.File(hh_file_loc, "r+")

hh_set = hh_file['Household']
hh_incomes = np.asarray(hh_set['hhincome'])
incomes_2010 = (hh_incomes * INCOME_FACTOR_00_10).astype(int)

# delete the income field so you can overwrite with new incomes
del hh_set['hhincome']
hh_file.create_dataset('Household/hhincome', data=incomes_2010, compression = 'gzip')
if('incomeconverted' in hh_set):
print 'The income has already been converted and will not be converted again'
else:
incomes_2010 = (hh_incomes * INCOME_FACTOR_00_10).astype(int)
# delete the income field so you can overwrite with new incomes
del hh_set['hhincome']
hh_file.create_dataset('Household/hhincome', data=incomes_2010, compression = 'gzip')
hh_file.create_dataset('Household/incomeconverted',(1,))
print 'incomes updated'

hh_file.close()

Expand Down

0 comments on commit a9127f0

Please sign in to comment.