Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow download for get_pop_objs #50

Merged
merged 2 commits into from
Dec 11, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 11 additions & 5 deletions ogzaf/demographics.py
Original file line number Diff line number Diff line change
Expand Up @@ -790,7 +790,9 @@ def pop_rebin(curr_pop_dist, totpers_new):
return curr_pop_new


def get_imm_resid(totpers, start_year=2021, end_year=None, graph=False):
def get_imm_resid(
totpers, start_year=2021, end_year=None, download=False, graph=False
):
"""
Calculate immigration rates by age as a residual given population levels in
different periods, then output average calculated immigration rate. We have
Expand All @@ -808,7 +810,7 @@ def get_imm_resid(totpers, start_year=2021, end_year=None, graph=False):
each period of life, length E+S

"""
pop_df = get_un_pop_data(start_year=2019, end_year=2021, download=False)
pop_df = get_un_pop_data(start_year=2019, end_year=2021, download=download)
pop_2019 = (
pop_df["pop"][
(
Expand Down Expand Up @@ -846,9 +848,11 @@ def get_imm_resid(totpers, start_year=2021, end_year=None, graph=False):
pop_2020_EpS = pop_rebin(pop_2020, totpers)
pop_2021_EpS = pop_rebin(pop_2021, totpers)

fert_rates = get_fert(totpers, start_year=start_year, end_year=end_year)
fert_rates = get_fert(
totpers, start_year=start_year, end_year=end_year, download=download
)
mort_rates, infmort_rate = get_mort(
totpers, start_year=start_year, end_year=end_year
totpers, start_year=start_year, end_year=end_year, download=download
)

imm_rate_1_2020 = (
Expand Down Expand Up @@ -957,7 +961,9 @@ def get_pop_objs(E, S, T, curr_year, download=False, GraphDiag=False):
E + S, start_year=hardcode_start_year, download=download
)
mort_rates_S = mort_rates[-S:]
imm_rates_orig = get_imm_resid(E + S, start_year=hardcode_start_year)
imm_rates_orig = get_imm_resid(
E + S, start_year=hardcode_start_year, download=download
)
OMEGA_orig = np.zeros((E + S, E + S))
OMEGA_orig[0, :] = (1 - infmort_rate) * fert_rates
OMEGA_orig[1:, :-1] += np.diag(1 - mort_rates[:-1])
Expand Down
Loading