From 8524c097332b19a2e0e54581f1e0194f77f03c49 Mon Sep 17 00:00:00 2001 From: meaghan66 <102330088+meaghan66@users.noreply.github.com> Date: Mon, 25 Nov 2024 11:02:28 -0700 Subject: [PATCH] Enabled adrio_cache for ADRIOs. (#199) * adrio_cache added to ADRIOs. * Removing left over test print statement. * Removed adrio_cache from CSV ADRIO. --- epymorph/adrio/cdc.py | 18 +++++++++++++++++- epymorph/adrio/commuting_flows.py | 3 ++- epymorph/adrio/humidity.py | 4 +++- epymorph/adrio/lodes.py | 6 +++++- epymorph/adrio/prism.py | 3 +++ 5 files changed, 30 insertions(+), 4 deletions(-) diff --git a/epymorph/adrio/cdc.py b/epymorph/adrio/cdc.py index cb43db72..6870ffe9 100644 --- a/epymorph/adrio/cdc.py +++ b/epymorph/adrio/cdc.py @@ -10,7 +10,7 @@ from pandas import DataFrame, concat, read_csv from typing_extensions import override -from epymorph.adrio.adrio import Adrio, ProgressCallback +from epymorph.adrio.adrio import Adrio, ProgressCallback, adrio_cache from epymorph.error import DataResourceException from epymorph.geography.scope import GeoScope from epymorph.geography.us_census import CensusScope @@ -397,6 +397,7 @@ def _validate_scope(scope: GeoScope) -> CensusScope: return scope +@adrio_cache class CovidCasesPer100k(Adrio[np.float64]): """ Creates a TxN matrix of tuples, containing a date and a float representing the @@ -417,6 +418,7 @@ def evaluate_adrio(self) -> NDArray[np.float64]: ) +@adrio_cache class CovidHospitalizationsPer100k(Adrio[np.float64]): """ Creates a TxN matrix of tuples, containing a date and a float representing the @@ -437,6 +439,7 @@ def evaluate_adrio(self) -> NDArray[np.float64]: ) +@adrio_cache class CovidHospitalizationAvgFacility(Adrio[np.float64]): """ Creates a TxN matrix of tuples, containing a date and a float representing the @@ -467,6 +470,7 @@ def evaluate_adrio(self) -> NDArray[np.float64]: ) +@adrio_cache class CovidHospitalizationSumFacility(Adrio[np.float64]): """ Creates a TxN matrix of tuples, containing a date and a float representing the @@ -497,6 +501,7 @@ def evaluate_adrio(self) -> NDArray[np.float64]: ) +@adrio_cache class InfluenzaHosptializationAvgFacility(Adrio[np.float64]): """ Creates a TxN matrix of tuples, containing a date and a float representing the @@ -527,6 +532,7 @@ def evaluate_adrio(self) -> NDArray[np.float64]: ) +@adrio_cache class InfluenzaHospitalizationSumFacility(Adrio[np.float64]): """ Creates a TxN matrix of tuples, containing a date and a float representing the @@ -557,6 +563,7 @@ def evaluate_adrio(self) -> NDArray[np.float64]: ) +@adrio_cache class CovidHospitalizationAvgState(Adrio[np.float64]): """ Creates a TxN matrix of tuples, containing a date and a float representing the @@ -577,6 +584,7 @@ def evaluate_adrio(self) -> NDArray[np.float64]: ) +@adrio_cache class CovidHospitalizationSumState(Adrio[np.float64]): """ Creates a TxN matrix of tuples, containing a date and a float representing the @@ -600,6 +608,7 @@ def evaluate_adrio(self) -> NDArray[np.float64]: ) +@adrio_cache class InfluenzaHospitalizationAvgState(Adrio[np.float64]): """ Creates a TxN matrix of tuples, containing a date and a float representing the @@ -623,6 +632,7 @@ def evaluate_adrio(self) -> NDArray[np.float64]: ) +@adrio_cache class InfluenzaHospitalizationSumState(Adrio[np.float64]): """ Creates a TxN matrix of tuples, containing a date and a float representing the @@ -646,6 +656,7 @@ def evaluate_adrio(self) -> NDArray[np.float64]: ) +@adrio_cache class FullCovidVaccinations(Adrio[np.float64]): """ Creates a TxN matrix of tuples, containing a date and a float representing the @@ -666,6 +677,7 @@ def evaluate_adrio(self) -> NDArray[np.float64]: ) +@adrio_cache class OneDoseCovidVaccinations(Adrio[np.float64]): """ Creates a TxN matrix of tuples, containing a date and a float representing the @@ -687,6 +699,7 @@ def evaluate_adrio(self) -> NDArray[np.float64]: ) +@adrio_cache class CovidBoosterDoses(Adrio[np.float64]): """ Creates a TxN matrix of tuples, containing a date and a float representing the @@ -707,6 +720,7 @@ def evaluate_adrio(self) -> NDArray[np.float64]: ) +@adrio_cache class CovidDeathsCounty(Adrio[np.float64]): """ Creates a TxN matrix of tuples, containing a date and a float representing the @@ -727,6 +741,7 @@ def evaluate_adrio(self) -> NDArray[np.float64]: ) +@adrio_cache class CovidDeathsState(Adrio[np.float64]): """ Creates a TxN matrix of tuples, containing a date and a float representing the @@ -747,6 +762,7 @@ def evaluate_adrio(self) -> NDArray[np.float64]: ) +@adrio_cache class InfluenzaDeathsState(Adrio[np.float64]): """ Creates a TxN matrix of tuples, containing a date and a float representing the diff --git a/epymorph/adrio/commuting_flows.py b/epymorph/adrio/commuting_flows.py index 33bb0edc..29829527 100644 --- a/epymorph/adrio/commuting_flows.py +++ b/epymorph/adrio/commuting_flows.py @@ -5,7 +5,7 @@ from pandas import read_excel from typing_extensions import override -from epymorph.adrio.adrio import Adrio +from epymorph.adrio.adrio import Adrio, adrio_cache from epymorph.cache import check_file_in_cache, load_or_fetch_url, module_cache_path from epymorph.data_usage import AvailableDataEstimate, DataEstimate from epymorph.error import DataResourceException @@ -83,6 +83,7 @@ def _validate_scope(scope: GeoScope) -> CensusScope: return scope +@adrio_cache class Commuters(Adrio[np.int64]): """ Creates an NxN matrix of integers representing commuters from the ACS commuting diff --git a/epymorph/adrio/humidity.py b/epymorph/adrio/humidity.py index 55ffa64a..d116b0d4 100644 --- a/epymorph/adrio/humidity.py +++ b/epymorph/adrio/humidity.py @@ -4,11 +4,12 @@ from numpy.typing import NDArray from typing_extensions import override -from epymorph.adrio.adrio import Adrio +from epymorph.adrio.adrio import Adrio, adrio_cache from epymorph.data_shape import Shapes from epymorph.simulation import AttributeDef +@adrio_cache class AbsoluteHumidity(Adrio[np.float64]): """ Creates a TxN matrix of floats representing absolute humidity in kilograms per cubic @@ -48,6 +49,7 @@ def evaluate_adrio(self) -> NDArray[np.float64]: return npHumidity +@adrio_cache class RelativeHumidity(Adrio[np.float64]): """ Creates a TxN matrix of floats representing relative humidity as a percentage diff --git a/epymorph/adrio/lodes.py b/epymorph/adrio/lodes.py index 1e302dd1..7f5b2257 100644 --- a/epymorph/adrio/lodes.py +++ b/epymorph/adrio/lodes.py @@ -8,7 +8,7 @@ from numpy.typing import NDArray from typing_extensions import override -from epymorph.adrio.adrio import Adrio, ProgressCallback +from epymorph.adrio.adrio import Adrio, ProgressCallback, adrio_cache from epymorph.cache import check_file_in_cache, load_or_fetch_url, module_cache_path from epymorph.data_usage import AvailableDataEstimate, DataEstimate from epymorph.error import DataResourceException @@ -379,6 +379,7 @@ def _estimate_lodes(self, scope: CensusScope, job_type: str, year: int) -> DataE ) +@adrio_cache class Commuters(Adrio[np.int64]): """ Creates an NxN matrix of integers representing the number of workers moving @@ -422,6 +423,7 @@ def evaluate_adrio(self) -> NDArray[np.int64]: return _fetch_lodes(scope, "S000", job_var, self.year, self.progress) +@adrio_cache class CommutersByAge(Adrio[np.int64]): """ Creates an NxN matrix of integers representing the number of workers moving from a @@ -480,6 +482,7 @@ def evaluate_adrio(self) -> NDArray[np.int64]: return _fetch_lodes(scope, age_var, job_var, self.year, self.progress) +@adrio_cache class CommutersByEarnings(Adrio[np.int64]): """ Creates an NxN matrix of integers representing the number of workers moving from a @@ -540,6 +543,7 @@ def evaluate_adrio(self) -> NDArray[np.int64]: return _fetch_lodes(scope, earning_var, job_var, self.year, self.progress) +@adrio_cache class CommutersByIndustry(Adrio[np.int64]): """ Creates an NxN matrix of integers representing the number of workers moving from a diff --git a/epymorph/adrio/prism.py b/epymorph/adrio/prism.py index 74b17a6a..cf8aa3cb 100644 --- a/epymorph/adrio/prism.py +++ b/epymorph/adrio/prism.py @@ -248,6 +248,7 @@ def evaluate_adrio(self) -> NDArray[np.float64]: return raster_vals +@adrio_cache class DewPoint(Adrio[np.float64]): """ Creates an TxN matrix of floats representing the dew point temperature in an area, @@ -294,6 +295,7 @@ def evaluate_adrio(self) -> NDArray[np.float64]: return raster_vals +@adrio_cache class Temperature(Adrio[np.float64]): """ Creates an TxN matrix of floats representing the temperature in an area, represented @@ -358,6 +360,7 @@ def evaluate_adrio(self) -> NDArray[np.float64]: return raster_vals +@adrio_cache class VaporPressureDeficit(Adrio[np.float64]): """ Creates an TxN matrix of floats representing the vapor pressure deficit in an area,