|
1 | 1 | from importlib.resources import files |
2 | 2 | from policyengine_core.data import Dataset |
3 | | -from policyengine_us_data.storage import STORAGE_FOLDER |
| 3 | +from policyengine_us_data.storage import STORAGE_FOLDER, DOCS_FOLDER |
4 | 4 | import h5py |
5 | 5 | from policyengine_us_data.datasets.cps.census_cps import * |
6 | 6 | from pandas import DataFrame, Series |
@@ -38,11 +38,16 @@ def generate(self): |
38 | 38 | """ |
39 | 39 |
|
40 | 40 | if self.raw_cps is None: |
41 | | - # Extrapolate from CPS 2023 |
42 | | - |
43 | | - cps_2023 = CPS_2023(require=True) |
44 | | - arrays = cps_2023.load_dataset() |
45 | | - arrays = uprate_cps_data(arrays, 2023, self.time_period) |
| 41 | + # Extrapolate from previous year |
| 42 | + if self.time_period == 2025: |
| 43 | + cps_2024 = CPS_2024(require=True) |
| 44 | + arrays = cps_2024.load_dataset() |
| 45 | + arrays = uprate_cps_data(arrays, 2024, self.time_period) |
| 46 | + else: |
| 47 | + # Default to CPS 2023 for backward compatibility |
| 48 | + cps_2023 = CPS_2023(require=True) |
| 49 | + arrays = cps_2023.load_dataset() |
| 50 | + arrays = uprate_cps_data(arrays, 2023, self.time_period) |
46 | 51 | self.save_dataset(arrays) |
47 | 52 | return |
48 | 53 |
|
@@ -1503,31 +1508,21 @@ def get_arrival_year_midpoint(peinusyr): |
1503 | 1508 | ) |
1504 | 1509 |
|
1505 | 1510 | # Save population log to CSV |
1506 | | - import os |
1507 | | - |
1508 | 1511 | log_df = pd.DataFrame(population_log) |
1509 | | - csv_path = os.path.join( |
1510 | | - os.path.dirname(__file__), |
1511 | | - "..", |
1512 | | - "..", |
1513 | | - "..", |
1514 | | - "docs", |
1515 | | - "asec_population_log.csv", |
1516 | | - ) |
| 1512 | + csv_path = DOCS_FOLDER / "asec_population_log.csv" |
| 1513 | + DOCS_FOLDER.mkdir(exist_ok=True) |
1517 | 1514 | log_df.to_csv(csv_path, index=False) |
1518 | 1515 | print(f"Population log saved to: {csv_path}") |
1519 | 1516 |
|
1520 | 1517 | # Update documentation with actual numbers |
1521 | | - _update_documentation_with_numbers(log_df, os.path.dirname(csv_path)) |
| 1518 | + _update_documentation_with_numbers(log_df, DOCS_FOLDER) |
1522 | 1519 |
|
1523 | 1520 |
|
1524 | 1521 | def _update_documentation_with_numbers(log_df, docs_dir): |
1525 | 1522 | """Update the documentation file with actual population numbers from CSV""" |
1526 | | - import os |
| 1523 | + doc_path = docs_dir / "SSN_statuses_imputation.ipynb" |
1527 | 1524 |
|
1528 | | - doc_path = os.path.join(docs_dir, "SSN_statuses_imputation.ipynb") |
1529 | | - |
1530 | | - if not os.path.exists(doc_path): |
| 1525 | + if not doc_path.exists(): |
1531 | 1526 | print(f"Documentation file not found at: {doc_path}") |
1532 | 1527 | return |
1533 | 1528 |
|
@@ -2017,10 +2012,19 @@ class CPS_2023(CPS): |
2017 | 2012 |
|
2018 | 2013 | class CPS_2024(CPS): |
2019 | 2014 | name = "cps_2024" |
2020 | | - label = "CPS 2024 (2022-based)" |
| 2015 | + label = "CPS 2024" |
| 2016 | + raw_cps = CensusCPS_2024 |
| 2017 | + previous_year_raw_cps = CensusCPS_2023 |
2021 | 2018 | file_path = STORAGE_FOLDER / "cps_2024.h5" |
2022 | 2019 | time_period = 2024 |
2023 | | - url = "release://policyengine/policyengine-us-data/1.13.0/cps_2024.h5" |
| 2020 | + frac = 0.5 |
| 2021 | + |
| 2022 | + |
| 2023 | +class CPS_2025(CPS): |
| 2024 | + name = "cps_2025" |
| 2025 | + label = "CPS 2025 (2024-based)" |
| 2026 | + file_path = STORAGE_FOLDER / "cps_2025.h5" |
| 2027 | + time_period = 2025 |
2024 | 2028 | frac = 1 |
2025 | 2029 |
|
2026 | 2030 |
|
@@ -2115,13 +2119,14 @@ class Pooled_3_Year_CPS_2023(PooledCPS): |
2115 | 2119 |
|
2116 | 2120 | if __name__ == "__main__": |
2117 | 2121 | if test_lite: |
2118 | | - CPS_2023().generate() |
2119 | 2122 | CPS_2024().generate() |
| 2123 | + CPS_2025().generate() |
2120 | 2124 | else: |
2121 | 2125 | CPS_2021().generate() |
2122 | 2126 | CPS_2022().generate() |
2123 | 2127 | CPS_2023().generate() |
2124 | 2128 | CPS_2024().generate() |
| 2129 | + CPS_2025().generate() |
2125 | 2130 | CPS_2021_Full().generate() |
2126 | 2131 | CPS_2022_Full().generate() |
2127 | 2132 | CPS_2023_Full().generate() |
|
0 commit comments