Created
December 3, 2012 06:30
-
-
Save rywall/4193156 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Calculate the intake fraction where iF = SUM(popDensN * DispN) | |
# where popDensN is the population density in an N meter buffer minus the previous buffer | |
def intake_fraction | |
fraction = 0 | |
inner_pop = 0 | |
inner_area = 0 | |
DISPERSION_FACTORS.each do |buffer, value| | |
pop_in_buffer = send("pop#{buffer}m").to_i | |
area_in_buffer = send("area#{buffer}m").to_i | |
fraction += value * (pop_in_buffer - inner_pop) / (area_in_buffer - inner_area) | |
# Save the population and area from this buffer to subtract from the next | |
inner_pop = pop_in_buffer | |
inner_area = area_in_buffer | |
end | |
return fraction | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment