Data Readers

class flodym.DataReader

Template for creating a data reader, showing required methods and data formats needed for use in the MFASystem model.

class flodym.CompoundDataReader(dimension_reader, parameter_reader)

Combines a DimensionReader and a ParameterReader to create a DataReader, reading both dimensions and parameters.

Parameters:
class flodym.DimensionReader

Template for creating a dimension reader, showing required methods and data formats needed

class flodym.ParameterReader

Template for creating a parameter reader, showing required methods and data formats needed

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.

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, see flodym.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.

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.

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, see flodym.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