epymorph.adrio.csv
ADRIOs that load data from locally available CSV files.
CSVFileN
CSVFileN(
*,
file_path: str | Path,
dtype: dtype | type[generic],
key_col: int,
key_type: GeoKeyType,
data_col: int,
skiprows: int | None = None,
)
Bases: _CSVMixin
, ADRIO[generic, generic]
Loads an N-shaped array of data from a user-provided CSV file.
Parameters:
-
file_path
(str | Path
) –The path to the CSV file containing data.
-
dtype
(dtype | type[generic]
) –The data type of values in the data column.
-
key_col
(int
) –Numerical index of the column containing information to identify geographies.
-
key_type
(GeoKeyType
) –The type of geographic identifier in the key column.
-
data_col
(int
) –Numerical index of the column containing the data of interest.
-
skiprows
(int | None
, default:None
) –Number of header rows in the file to be skipped.
file_path
instance-attribute
file_path: Path = (
file_path
if isinstance(file_path, Path)
else Path(file_path)
)
The path to the CSV file containing data.
dtype
instance-attribute
dtype: dtype = (
dtype if isinstance(dtype, dtype) else dtype(dtype)
)
The data type of values in the data column.
key_col
instance-attribute
key_col: int = key_col
Numerical index of the column containing information to identify geographies.
key_type
instance-attribute
key_type: GeoKeyType = key_type
The type of geographic identifier in the key column.
data_col
instance-attribute
data_col: int = data_col
Numerical index of the column containing the data of interest.
skiprows
instance-attribute
skiprows: int | None = skiprows
Number of header rows in the file to be skipped.
result_format
property
result_format: ResultFormat
Information about the expected format of the ADRIO's resulting data.
inspect
inspect() -> InspectResult[generic, generic]
Produce an inspection of the ADRIO's data for the current context.
When implementing an ADRIO, override this method to provide data fetching and processing logic. Use self methods and properties to access the simulation context or defer processing to another function.
NOTE: if you are implementing this method, make sure to call validate_context
first and _validate_result
last.
Returns:
-
InspectResult[ResultT, ValueT]
–The data inspection results for the ADRIO's current context.
CSVFileTxN
CSVFileTxN(
*,
file_path: str | Path,
dtype: dtype | type[generic],
key_col: int,
key_type: GeoKeyType,
time_col: int,
data_col: int,
skiprows: int | None = None,
date_range: DateRange | None = None,
)
Bases: _CSVMixin
, ADRIO[generic, generic]
Loads a TxN-shaped array of data from a user-provided CSV file.
Parameters:
-
file_path
(str | Path
) –The path to the CSV file containing data.
-
dtype
(dtype | type[generic]
) –The data type of values in the data column.
-
key_col
(int
) –Numerical index of the column containing information to identify geographies.
-
key_type
(GeoKeyType
) –The type of geographic identifier in the key column.
-
time_col
(int
) –The numerical index of the column containing time information.
-
data_col
(int
) –Numerical index of the column containing the data of interest.
-
skiprows
(int | None
, default:None
) –Number of header rows in the file to be skipped.
-
date_range
(DateRange | None
, default:None
) –The time period encompassed by data in the file.
file_path
instance-attribute
file_path: Path = (
file_path
if isinstance(file_path, Path)
else Path(file_path)
)
The path to the CSV file containing data.
dtype
instance-attribute
dtype: dtype = (
dtype if isinstance(dtype, dtype) else dtype(dtype)
)
The data type of values in the data column.
key_col
instance-attribute
key_col: int = key_col
Numerical index of the column containing information to identify geographies.
data_col
instance-attribute
data_col: int = data_col
Numerical index of the column containing the data of interest.
key_type
instance-attribute
key_type: GeoKeyType = key_type
The type of geographic identifier in the key column.
skiprows
instance-attribute
skiprows: int | None = skiprows
Number of header rows in the file to be skipped.
date_range
instance-attribute
date_range: DateRange | None = date_range
The time period encompassed by data in the file.
time_col
instance-attribute
time_col: int = time_col
The numerical index of the column containing time information.
result_format
property
result_format: ResultFormat
Information about the expected format of the ADRIO's resulting data.
inspect
inspect() -> InspectResult
Produce an inspection of the ADRIO's data for the current context.
When implementing an ADRIO, override this method to provide data fetching and processing logic. Use self methods and properties to access the simulation context or defer processing to another function.
NOTE: if you are implementing this method, make sure to call validate_context
first and _validate_result
last.
Returns:
-
InspectResult[ResultT, ValueT]
–The data inspection results for the ADRIO's current context.
validate_result
Validates that the result of evaluating the ADRIO adheres to the expected result format.
Parameters:
-
context
(Context
) –The context in which the result has been evaluated.
-
result
(NDArray[ResultT]
) –The result produced by the ADRIO.
Raises:
-
ADRIOProcessingError
–If the result is invalid, indicating the processing logic has a bug.
CSVFileNxN
CSVFileNxN(
*,
file_path: PathLike,
dtype: dtype | type[generic],
from_key_col: int,
to_key_col: int,
key_type: GeoKeyType,
data_col: int,
skiprows: int | None,
)
Bases: _CSVMixin
, ADRIO[generic, generic]
Loads an NxN-shaped array of data from a user-provided CSV file.
Parameters:
-
file_path
(PathLike
) –The path to the CSV file containing data.
-
dtype
(dtype | type[generic]
) –The data type of values in the data column.
-
from_key_col
(int
) –Index of the column identifying source geographies.
-
to_key_col
(int
) –Index of the column identifying destination geographies.
-
key_type
(GeoKeyType
) –The type of geographic identifier in the key columns.
-
data_col
(int
) –Index of the column containing the data of interest.
-
skiprows
(int | None
) –Number of header rows in the file to be skipped.
file_path
instance-attribute
file_path: Path = (
file_path
if isinstance(file_path, Path)
else Path(file_path)
)
The path to the CSV file containing data.
dtype
instance-attribute
dtype: dtype = (
dtype if isinstance(dtype, dtype) else dtype(dtype)
)
The data type of values in the data column.
from_key_col
instance-attribute
from_key_col: int = from_key_col
Index of the column identifying source geographies.
to_key_col
instance-attribute
to_key_col: int = to_key_col
Index of the column identifying destination geographies.
key_type
instance-attribute
key_type: GeoKeyType = key_type
The type of geographic identifier in the key columns.
data_col
instance-attribute
data_col: int = data_col
Index of the column containing the data of interest.
skiprows
instance-attribute
skiprows: int | None = skiprows
Number of header rows in the file to be skipped.
result_format
property
result_format: ResultFormat
Information about the expected format of the ADRIO's resulting data.
inspect
inspect() -> InspectResult
Produce an inspection of the ADRIO's data for the current context.
When implementing an ADRIO, override this method to provide data fetching and processing logic. Use self methods and properties to access the simulation context or defer processing to another function.
NOTE: if you are implementing this method, make sure to call validate_context
first and _validate_result
last.
Returns:
-
InspectResult[ResultT, ValueT]
–The data inspection results for the ADRIO's current context.