@@ -146,6 +146,8 @@ def get_fert(
146
146
df = get_un_data (
147
147
"68" , country_id = country_id , start_year = start_year , end_year = end_year
148
148
)
149
+ if download_path :
150
+ df .to_csv (os .path .join (download_path , "raw_fert_data_UN.csv" ), index = False )
149
151
# CLean and rebin data
150
152
for y in range (start_year , end_year + 1 ):
151
153
df_y = df [(df .age >= min_age ) & (df .age <= max_age ) & (df .year == y )]
@@ -232,6 +234,8 @@ def get_mort(
232
234
df = get_un_data (
233
235
"80" , country_id = country_id , start_year = start_year , end_year = end_year
234
236
)
237
+ if download_path :
238
+ df .to_csv (os .path .join (download_path , "raw_mort_data_UN.csv" ), index = False )
235
239
# CLean and rebin data
236
240
for y in range (start_year , end_year + 1 ):
237
241
df_y = df [(df .age >= min_age ) & (df .age <= max_age ) & (df .year == y )]
@@ -345,6 +349,8 @@ def get_pop(
345
349
start_year = start_year - 1 ,
346
350
end_year = start_year - 1 ,
347
351
)
352
+ if download_path :
353
+ pre_pop_data .to_csv (os .path .join (download_path , "raw_pre_pop_data_UN.csv" ), index = False )
348
354
pre_pop_sample = pre_pop_data [
349
355
(pre_pop_data ["age" ] >= min_age )
350
356
& (pre_pop_data ["age" ] <= max_age )
@@ -397,6 +403,8 @@ def get_pop(
397
403
end_year = end_year
398
404
+ 2 , # note go to + 2 because needed to infer immigration for end_year
399
405
)
406
+ if download_path :
407
+ pop_data .to_csv (os .path .join (download_path , "raw_pop_data_UN.csv" ), index = False )
400
408
# CLean and rebin data
401
409
for y in range (start_year , end_year + 2 ):
402
410
pop_data_sample = pop_data [
@@ -663,7 +671,7 @@ def get_pop_objs(
663
671
pre_pop_dist = None ,
664
672
country_id = UN_COUNTRY_CODE ,
665
673
initial_data_year = START_YEAR - 1 ,
666
- final_data_year = START_YEAR + 2 , # as default data year goes until T1
674
+ final_data_year = START_YEAR + 2 ,
667
675
GraphDiag = True ,
668
676
download_path = None ,
669
677
):
@@ -733,8 +741,8 @@ def get_pop_objs(
733
741
final_data_year ,
734
742
)
735
743
assert E + S <= max_age - min_age + 1
736
- assert initial_data_year >= 2011 and initial_data_year <= 2100
737
- assert final_data_year >= 2011 and final_data_year <= 2100
744
+ assert initial_data_year >= 2011 and initial_data_year <= 2100 - 1
745
+ assert final_data_year >= 2011 and final_data_year <= 2100 - 1
738
746
# Ensure that the last year of data used is before SS transition assumed
739
747
# Really, it will need to be well before this
740
748
assert final_data_year > initial_data_year
0 commit comments