Skip to content

Commit

Permalink
fix the anomaly in netcdf file loading via moving from path to files …
Browse files Browse the repository at this point in the history
…for importlib resources
  • Loading branch information
AFg6K7h4fhy2 committed Nov 25, 2024
1 parent c96f216 commit 4189e58
Showing 1 changed file with 39 additions and 28 deletions.
67 changes: 39 additions & 28 deletions forecasttools/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,41 +28,52 @@
)

# location table (from Census data)
with importlib.resources.path(
__package__, "location_table.parquet"
) as data_path:
location_table = pl.read_parquet(data_path)
location_table_path = importlib.resources.files(__package__).joinpath(
"location_table.parquet"
)
location_table = pl.read_parquet(str(location_table_path))

# load example flusight submission
with importlib.resources.path(
__package__, "example_flusight_submission.parquet"
) as data_path:
dtypes_d = {"location": pl.Utf8}
example_flusight_submission = pl.read_parquet(data_path)
example_flusight_submission_path = importlib.resources.files(
__package__
).joinpath("example_flusight_submission.parquet")
dtypes_d = {"location": pl.Utf8}
example_flusight_submission = pl.read_parquet(
str(example_flusight_submission_path)
)

# load example fitting data for COVID (NHSN, as of 2024-09-26)
with importlib.resources.path(
__package__, "nhsn_hosp_COVID.parquet"
) as data_path:
nhsn_hosp_COVID = pl.read_parquet(data_path)
# load example fitting data for COVID
# (NHSN, as of 2024-09-26)
nhsn_hosp_COVID_path = importlib.resources.files(__package__).joinpath(
"nhsn_hosp_COVID.parquet"
)
nhsn_hosp_COVID = pl.read_parquet(str(nhsn_hosp_COVID_path))

# load example fitting data for influenza (NHSN, as of 2024-09-26)
with importlib.resources.path(
__package__, "nhsn_hosp_flu.parquet"
) as data_path:
nhsn_hosp_flu = pl.read_parquet(data_path)
# load example fitting data for influenza
# (NHSN, as of 2024-09-26)
nhsn_hosp_flu_path = importlib.resources.files(__package__).joinpath(
"nhsn_hosp_flu.parquet"
)
nhsn_hosp_flu = pl.read_parquet(str(nhsn_hosp_flu_path))

# load light idata NHSN influenza forecast (NHSN, as of 2024-09-26)
with importlib.resources.path(
__package__, "example_flu_forecast_wo_dates.nc"
) as data_path:
nhsn_flu_forecast_wo_dates = az.from_netcdf(data_path)
# load idata NHSN influenza forecast
# (NHSN, as of 2024-09-26) without dates
example_flu_forecast_wo_dates_path = importlib.resources.files(
__package__
).joinpath("example_flu_forecast_wo_dates.nc")
nhsn_flu_forecast_wo_dates = az.from_netcdf(
str(example_flu_forecast_wo_dates_path)
)

# load idata NHSN influenza forecast
# (NHSN, as of 2024-09-26) with dates
example_flu_forecast_w_dates_path = importlib.resources.files(
__package__
).joinpath("example_flu_forecast_w_dates.nc")
nhsn_flu_forecast_w_dates = az.from_netcdf(
str(example_flu_forecast_w_dates_path)
)

with importlib.resources.path(
__package__, "example_flu_forecast_w_dates.nc"
) as data_path:
nhsn_flu_forecast_w_dates = az.from_netcdf(data_path)

__all__ = [
"location_table",
Expand Down

0 comments on commit 4189e58

Please sign in to comment.