reV.rep_profiles.rep_profiles.RepresentativeMethods

class RepresentativeMethods(profiles, weights=None, rep_method='meanoid', err_method='rmse')[source]

Bases: object

Class for organizing the methods to determine representative-ness

Parameters:
  • profiles (np.ndarray) – (time, sites) timeseries array of cf profile data.

  • weights (np.ndarray | list) – 1D array of weighting factors (multiplicative) for profiles.

  • rep_method (str) – Method identifier for calculation of the representative profile.

  • err_method (str | None) – Method identifier for calculation of error from the representative profile (e.g. “rmse”, “mae”, “mbe”). If this is None, the representative meanoid / medianoid profile will be returned directly

Methods

mae(profiles, baseline[, i_profile])

Calculate the mean absolute error of profiles vs.

mbe(profiles, baseline[, i_profile])

Calculate the mean bias error of profiles vs.

meanoid(profiles[, weights])

Find the mean profile across all sites.

medianoid(profiles)

Find the median profile across all sites.

nargmin(arr, n)

Get the index of the Nth min value in arr.

rmse(profiles, baseline[, i_profile])

Calculate the RMSE of profiles vs.

run(profiles[, weights, rep_method, ...])

Run representative profile methods.

Attributes

err_methods

Lookup table of error methods

rep_methods

Lookup table of representative methods

property rep_methods

Lookup table of representative methods

property err_methods

Lookup table of error methods

static nargmin(arr, n)[source]

Get the index of the Nth min value in arr.

Parameters:
  • arr (np.ndarray) – 1D array.

  • n (int) – If n is 0, this returns the location of the min value in arr. If n is 1, this returns the location of the 2nd min value in arr.

Returns:

i (int) – Location of the Nth min value in arr.

static meanoid(profiles, weights=None)[source]

Find the mean profile across all sites.

Parameters:
  • profiles (np.ndarray) – (time, sites) timeseries array of cf profile data.

  • weights (np.ndarray | list) – 1D array of weighting factors (multiplicative) for profiles.

Returns:

arr (np.ndarray) – (time, 1) timeseries of the mean of all cf profiles across sites.

static medianoid(profiles)[source]

Find the median profile across all sites.

Parameters:

profiles (np.ndarray) – (time, sites) timeseries array of cf profile data.

Returns:

arr (np.ndarray) – (time, 1) timeseries of the median at every timestep of all cf profiles across sites.

classmethod mbe(profiles, baseline, i_profile=0)[source]

Calculate the mean bias error of profiles vs. a baseline profile.

Parameters:
  • profiles (np.ndarray) – (time, sites) timeseries array of cf profile data.

  • baseline (np.ndarray) – (time, 1) timeseries of the meanoid or medianoid to which cf profiles should be compared.

  • i_profile (int) – The index of the represntative profile being saved (for n_profiles). 0 is the most representative profile.

Returns:

  • profile (np.ndarray) – (time, 1) array for the most representative profile

  • i_rep (int) – Column Index in profiles of the representative profile.

classmethod mae(profiles, baseline, i_profile=0)[source]

Calculate the mean absolute error of profiles vs. a baseline profile

Parameters:
  • profiles (np.ndarray) – (time, sites) timeseries array of cf profile data.

  • baseline (np.ndarray) – (time, 1) timeseries of the meanoid or medianoid to which cf profiles should be compared.

  • i_profile (int) – The index of the represntative profile being saved (for n_profiles). 0 is the most representative profile.

Returns:

  • profile (np.ndarray) – (time, 1) array for the most representative profile

  • i_rep (int) – Column Index in profiles of the representative profile.

classmethod rmse(profiles, baseline, i_profile=0)[source]

Calculate the RMSE of profiles vs. a baseline profile

Parameters:
  • profiles (np.ndarray) – (time, sites) timeseries array of cf profile data.

  • baseline (np.ndarray) – (time, 1) timeseries of the meanoid or medianoid to which cf profiles should be compared.

  • i_profile (int) – The index of the represntative profile being saved (for n_profiles). 0 is the most representative profile.

Returns:

  • profile (np.ndarray) – (time, 1) array for the most representative profile

  • i_rep (int) – Column Index in profiles of the representative profile.

classmethod run(profiles, weights=None, rep_method='meanoid', err_method='rmse', n_profiles=1)[source]

Run representative profile methods.

Parameters:
  • profiles (np.ndarray) – (time, sites) timeseries array of cf profile data.

  • weights (np.ndarray | list) – 1D array of weighting factors (multiplicative) for profiles.

  • rep_method (str) – Method identifier for calculation of the representative profile.

  • err_method (str | None) – Method identifier for calculation of error from the representative profile (e.g. “rmse”, “mae”, “mbe”). If this is None, the representative meanoid / medianoid profile will be returned directly.

  • n_profiles (int) – Number of representative profiles to save to fout.

Returns:

  • profiles (np.ndarray) – (time, n_profiles) array for the most representative profile(s)

  • i_reps (list | None) – List (length of n_profiles) with column Index in profiles of the representative profile(s). If err_method is None, this value is also set to None.