mettoolbox.indices.pe

mettoolbox.indices.pe(rainfall, pet, source_units, nsmallest=None, nlargest=None, groupby='M', window=30, min_periods=None, center=None, win_type=None, closed=None, target_units='mm')

Precipitation minus evaporation index.

Calculates a windows cumulative sum of daily precipitation minus evaporation.

Parameters:
  • rainfall (Union[int, str, DataFrame]) –

    A csv, wdm, hdf5, xlsx file or a pandas DataFrame or Series or an integer column or string name of standard input.

    Represents a daily time-series of precipitation in units specified in source_units.

  • pet (Union[int, str, DataFrame]) –

    A csv, wdm, hdf5, xlsx file or a pandas DataFrame or Series or an integer column or string name of standard input.

    Represents a daily time-series of evaporation in units specified in source_units.

  • source_units (str) –

    [optional, default is None, transformation]

    If unit is specified for the column as the second field of a ‘:’ delimited column name, then the specified units and the ‘source_units’ must match exactly.

    Any unit string compatible with the ‘pint’ library can be used.

  • nsmallest (int) –

    [optional, default is None]

    Return the “n” days with the smallest precipitation minus evaporation index value within the groupby pandas offset period.

    Cannot assign both nsmallest and nlargest keywords.

  • nlargest (int) –

    [optional, default is None]

    Return the “n” days with the largest precipitation minus evaporation index value within the groupby pandas offset period.

    Cannot assign both nsmallest and nlargest keywords.

  • groupby (str) – Pandas offset period string representing the time over which the nsmallest or nlargest values would be evaluated.

  • window (int) –

    [optional, default is 30]

    Size of the moving window. This is the number of observations used for calculating the statistic. Each window will be a fixed size.

    If its an offset then this will be the time period of each window. Each window will be a variable sized based on the observations included in the time-period. This is only valid for datetimelike indexes.

  • min_periods (int, default 170 days) – Minimum number of observations in window required to have a value (otherwise result is NA). For a window that is specified by an offset, min_periods will default to 1. Otherwise, min_periods will default to the size of the window.

  • center (bool, default False) – Set the labels at the center of the window.

  • win_type (str, default None) – Provide a window type. If None, all points are evenly weighted. See the notes below for further information.

  • closed (str, default None) – Make the interval closed on the ‘right’, ‘left’, ‘both’ or ‘neither’ endpoints. Defaults to ‘right’.

  • input_ts (str) –

    [optional though required if using within Python, default is ‘-’ (stdin)]

    Whether from a file or standard input, data requires a single line header of column names. The default header is the first line of the input, but this can be changed for CSV files using the ‘skiprows’ option.

    Most common date formats can be used, but the closer to ISO 8601 date/time standard the better.

    Comma-separated values (CSV) files or tab-separated values (TSV):

    File separators will be automatically detected.
    
    Columns can be selected by name or index, where the index for
    data columns starts at 1.
    

    Command line examples:

    Keyword Example

    Description

    –input_ts=fn.csv

    read all columns from ‘fn.csv’

    –input_ts=fn.csv,2,1

    read data columns 2 and 1 from ‘fn.csv’

    –input_ts=fn.csv,2,skiprows=2

    read data column 2 from ‘fn.csv’, skipping first 2 rows so header is read from third row

    –input_ts=fn.xlsx,2,Sheet21

    read all data from 2nd sheet all data from “Sheet21” of ‘fn.xlsx’

    –input_ts=fn.hdf5,Table12,T2

    read all data from table “Table12” then all data from table “T2” of ‘fn.hdf5’

    –input_ts=fn.wdm,210,110

    read DSNs 210, then 110 from ‘fn.wdm’

    –input_ts=’-’

    read all columns from standard input (stdin)

    –input_ts=’-’ –columns=4,1

    read column 4 and 1 from standard input (stdin)

    If working with CSV or TSV files you can use redirection rather than use –input_ts=fname.csv. The following are identical:

    From a file:

    command subcmd –input_ts=fname.csv

    From standard input (since ‘–input_ts=-’ is the default:

    command subcmd < fname.csv

    Can also combine commands by piping:

    command subcmd < filein.csv | command subcmd1 > fileout.csv

    Python library examples:

    You must use the `input_ts=...` option where `input_ts` can be
    one of a [pandas DataFrame, pandas Series, dict, tuple, list,
    StringIO, or file name].
    

  • start_date (str) –

    [optional, defaults to first date in time-series, input filter]

    The start_date of the series in ISOdatetime format, or ‘None’ for beginning.

  • end_date (str) –

    [optional, defaults to last date in time-series, input filter]

    The end_date of the series in ISOdatetime format, or ‘None’ for end.

  • dropna (str) –

    [optional, defauls it ‘no’, input filter]

    Set dropna to ‘any’ to have records dropped that have NA value in any column, or ‘all’ to have records dropped that have NA in all columns. Set to ‘no’ to not drop any records. The default is ‘no’.

  • clean

    [optional, default is False, input filter]

    The ‘clean’ command will repair a input index, removing duplicate index values and sorting.

  • round_index

    [optional, default is None which will do nothing to the index, output format]

    Round the index to the nearest time point. Can significantly improve the performance since can cut down on memory and processing requirements, however be cautious about rounding to a very course interval from a small one. This could lead to duplicate values in the index.

  • index_type (str) –

    [optional, default is ‘datetime’, output format]

    Can be either ‘number’ or ‘datetime’. Use ‘number’ with index values that are Julian dates, or other epoch reference.

  • names (str) –

    [optional, default is None, transformation]

    If None, the column names are taken from the first row after ‘skiprows’ from the input dataset.

    MUST include a name for all columns in the input dataset, including the index column.

  • target_units (str) –

    [optional, default is None, transformation]

    The purpose of this option is to specify target units for unit conversion. The source units are specified in the header line of the input or using the ‘source_units’ keyword.

    The units of the input time-series or values are specified as the second field of a ‘:’ delimited name in the header line of the input or in the ‘source_units’ keyword.

    Any unit string compatible with the ‘pint’ library can be used.

    This option will also add the ‘target_units’ string to the column names.

  • print_input

    [optional, default is False, output format]

    If set to ‘True’ will include the input columns in the output table.

  • tablefmt (str) –

    [optional, default is ‘csv’, output format]

    The table format. Can be one of ‘csv’, ‘tsv’, ‘plain’, ‘simple’, ‘grid’, ‘pipe’, ‘orgtbl’, ‘rst’, ‘mediawiki’, ‘latex’, ‘latex_raw’ and ‘latex_booktabs’.