Data Readers
- class flodym.DataReader
Template for creating a data reader, showing required methods and data formats needed for use in the MFASystem model.
- abstract read_dimension(dimension_definition)
Required method to read data for a single dimension, corresponding to the dimension definition.
- Parameters:
dimension_definition (DimensionDefinition)
- Return type:
- read_dimensions(dimension_definitions)
Method to read data for multiple dimensions, by looping over read_dimension.
- Parameters:
dimension_definitions (List[DimensionDefinition])
- Return type:
- abstract read_parameter_values(parameter_name, dims)
Required method to read data for a particular parameter.
- Parameters:
parameter_name (str)
dims (DimensionSet)
- Return type:
- read_parameters(parameter_definitions, dims)
Method to read data for a list of parameters, by looping over read_parameter_values.
- Parameters:
parameter_definitions (List[ParameterDefinition])
dims (DimensionSet)
- Return type:
Dict[str, Parameter]
- class flodym.CompoundDataReader(dimension_reader, parameter_reader)
Combines a DimensionReader and a ParameterReader to create a DataReader, reading both dimensions and parameters.
- Parameters:
dimension_reader (DimensionReader)
parameter_reader (ParameterReader)
- read_dimension(dimension_definition)
Required method to read data for a single dimension, corresponding to the dimension definition.
- Parameters:
dimension_definition (DimensionDefinition)
- Return type:
- read_dimensions(dimension_definitions)
Method to read data for multiple dimensions, by looping over read_dimension.
- Parameters:
dimension_definitions (List[DimensionDefinition])
- Return type:
- read_parameter_values(parameter_name, dims)
Required method to read data for a particular parameter.
- Parameters:
parameter_name (str)
dims (DimensionSet)
- Return type:
- read_parameters(parameter_definitions, dims)
Method to read data for a list of parameters, by looping over read_parameter_values.
- Parameters:
parameter_definitions (List[ParameterDefinition])
dims (DimensionSet)
- Return type:
Dict[str, Parameter]
- class flodym.DimensionReader
Template for creating a dimension reader, showing required methods and data formats needed
- read_dimensions(dimension_definitions)
Method to read data for multiple dimensions, by looping over read_dimension.
- Parameters:
dimension_definitions (List[DimensionDefinition])
- Return type:
- class flodym.ParameterReader
Template for creating a parameter reader, showing required methods and data formats needed
- read_parameters(parameter_definitions, dims)
Method to read data for a list of parameters, by looping over read_parameter_values.
- Parameters:
parameter_definitions (List[ParameterDefinition])
dims (DimensionSet)
- Return type:
Dict[str, Parameter]
- class flodym.CSVDimensionReader(dimension_files, **read_csv_kwargs)
Read dimensions from a CSV file. Expects a single row or single columns csv file with no header containing the dimension items.
- Parameters:
dimension_files (dict) – {dimension_name: file_path, …}
read_csv_kwargs – Additional keyword arguments passed to pandas.read_csv. The default is {“header”: None}. Not encouraged to use, since it may not lead to the intended DataFrame format. Sticking to recommended csv file format is preferred.
- read_dimensions(dimension_definitions)
Method to read data for multiple dimensions, by looping over read_dimension.
- Parameters:
dimension_definitions (List[DimensionDefinition])
- Return type:
- class flodym.CSVParameterReader(parameter_files=None, allow_missing_values=False, allow_extra_values=False, **read_csv_kwargs)
Reads a csv file to a pandas data frame and calls
flodym.Parameter.from_df(). Expects comma separation and no header, apart from optional column names. For further detail on expected format, seeflodym.FlodymArray.from_df().- Parameters:
parameter_files (dict) – Mapping of parameter names to file paths. Format: {parameter_name: file_path, …}
allow_missing_values (bool, optional) – Whether to allow missing values in the DataFrame. This includes both missing rows, and NaN values in the value column. Defaults to False.
allow_extra_values (bool, optional) – Whether to allow extra rows in the DataFrame, i.e. tows with index items not present in the FlodymArray dimension items. Defaults to False.
read_csv_kwargs – Additional keyword arguments passed to pandas.read_csv. Not encouraged to use, since it may not lead to the intended DataFrame format. Sticking to recommended csv file format is preferred.
- read_parameters(parameter_definitions, dims)
Method to read data for a list of parameters, by looping over read_parameter_values.
- Parameters:
parameter_definitions (List[ParameterDefinition])
dims (DimensionSet)
- Return type:
Dict[str, Parameter]
- class flodym.ExcelDimensionReader(dimension_files, dimension_sheets=None, **read_excel_kwargs)
Read dimensions from Excel file(s). Expects a single row or single columns excel sheet with no header containing the dimension items.
- Parameters:
dimension_files (dict) – {dimension_name: file_path, …}
dimension_sheets (dict) – {dimension_name: sheet_name, …}
ead_excel_kwargs – Additional keyword arguments passed to pandas.read_excel. The default is {“header”: None}. Not encouraged to use, since it may not lead to the intended DataFrame format. Sticking to recommended excel file format is preferred.
- read_dimensions(dimension_definitions)
Method to read data for multiple dimensions, by looping over read_dimension.
- Parameters:
dimension_definitions (List[DimensionDefinition])
- Return type:
- class flodym.ExcelParameterReader(parameter_files, parameter_sheets=None, allow_missing_values=False, allow_extra_values=False, **read_excel_kwargs)
Reads an excel file to a pandas data frame and calls
flodym.Parameter.from_df(). Expects contiguous data starting in the upper left cell A1. For further detail on expected format, seeflodym.FlodymArray.from_df().- Parameters:
parameter_files (dict) – Mapping of parameter names to file paths. Can be the same file for multiple parameters if the sheets are different. Format: {parameter_name: file_path, …}
parameter_sheets (dict) – Mapping of parameter names to sheet names in the excel file. If None, the first sheet is used. Format: {parameter_name: sheet_name, …} Defaults to None.
allow_missing_values (bool, optional) – Whether to allow missing values in the DataFrame. This includes both missing rows, and NaN values in the value column. Defaults to False.
allow_extra_values (bool, optional) – Whether to allow extra rows in the DataFrame, i.e. tows with index items not present in the FlodymArray dimension items. Defaults to False.
read_excel_kwargs – Additional keyword arguments passed to pandas.read_excel. Not encouraged to use, since it may not lead to the intended DataFrame format. Sticking to recommended excel file format is preferred
- read_parameters(parameter_definitions, dims)
Method to read data for a list of parameters, by looping over read_parameter_values.
- Parameters:
parameter_definitions (List[ParameterDefinition])
dims (DimensionSet)
- Return type:
Dict[str, Parameter]