wadi.dataobject module

class wadi.dataobject.DataObject(log_fname='wadi.log', output_dir='wadi_output', silent=False)

Bases: WadiBaseClass

Class for importing hydrochemical data in a variety of formats. The class provides various functions that allow the user to convert the data into different formats.

Examples

import wadi as wd

wdo = wd.DataObject() wdo.file_reader(‘chem_data.xlsx’) df = wd.get_frame()

__init__(log_fname='wadi.log', output_dir='wadi_output', silent=False)

Class initialization method. Initializes the parent class object so that a log file and an output directory are created. Also initializes the Reader, Mapper and Harmonizer callable classes so that the user can set their attributes via the methods file_reader, name_map, unit_map and harmonizer.

Parameters:
  • log_fname (str, optional) – Name of the log file. Default: ‘wadi.log’

  • output_dir (str, optional) – Name of the directory with output files. Default: ‘wadi_output’

  • silent (bool, optional) – Flag to indicate if screen output is desired during data processing. When True then no screen output is displayed. Default is False (recommended for large data files when processing can be slow). When True messages will still appear in the log file. Warnings are always displayed on the screen regardless of the value for ‘silent’.

_execute(import_only=False)

This method calls the _execute methods of the child objects that read, map and harmonize the data. Upon success the converted data are stored in self._converted_df

Parameters:

import_only (bool, optional) – When True the data are read but not mapped or harmonized. Default: False.

get_converted_dataframe(include_units=True, force_conversion=False)

This method converts the input data based on the specified name and unit maps and harmonizer, and returns the result as a DataFrame.

Parameters:
  • include_units (bool, optional) – When True the DataFrame’s columns will be a MultiIndex that contains both the feature aliases and their units. When set to False a DataFrame is returned of which the columns simply correspond to the feature aliases and the units are discarded. The latter option is useful when the DataFrame is intended for further processing in HGC. Default: True.

  • force_conversion (bool, optional) – When True, the function will always map and harmonize the data before it returns the DataFrame. When False, the results from any previously executed data mapping and harmonizing are returned, when present. Default: False.

Returns:

result – The converted DataFrame.

Return type:

DataFrame

get_imported_dataframe()

This method returns the imported DataFrame (that is, the data ‘as read’).

Returns:

result – The imported DataFrame.

Return type:

DataFrame

get_imported_names()

This method returns the names of the features in the imported DataFrame.

Returns:

result – A list with feature names in the imported DataFrame.

Return type:

list