Package References

Base class

class allotools.AlloUsage(from_date=None, to_date=None, site_filter=None, crc_filter=None, crc_wap_filter=None, in_allo=True, include_hydroelectric=False)

Class to to process the allocation and usage data at ECan.

Parameters
  • from_date (str or None) – The start date of the consent and the final time series. In the form of ‘2000-01-01’. None will return all consents and subsequently all dates.

  • to_date (str or None) – The end date of the consent and the final time series. In the form of ‘2000-01-01’. None will return all consents and subsequently all dates.

  • site_filter (dict) – A dict in the form of {str: [values]} to select specific values from a specific column in the ExternalSite table.

  • crc_filter (dict) – A dict in the form of {str: [values]} to select specific values from a specific column in the CrcAllo table.

  • crc_wap_filter (dict) – A dict in the form of {str: [values]} to select specific values from a specific column in the CrcWapAllo table.

  • in_allo (bool) – Should only the consumptive takes be included?

  • include_hydroelectric (bool) – Should hydroelectric takes be included?

Returns

with all of the base sites, allo, and allo_wap DataFrames

Return type

AlloUsage object

Get the time series data

AlloUsage.get_ts(self, datasets, freq, groupby, sd_days=150, irr_season=False, usage_allo_ratio=2)

Function to create a time series of allocation and usage.

Parameters
  • datasets (list of str) – The dataset types to be returned. Must be one or more of {ds}.

  • freq (str) – Pandas time frequency code for the time interval. Must be one of ‘D’, ‘W’, ‘M’, ‘A’, or ‘A-JUN’.

  • groupby (list of str) – The fields that should grouped by when returned. Can be any variety of fields including crc, take_type, allo_block, ‘wap’, CatchmentGroupName, etc. Date will always be included as part of the output group, so it doesn’t need to be specified in the groupby.

  • sd_days (int) – The stream depletion days for the groundwater to surface water rationing. Must be one of 7, 30, or 150.

  • irr_season (bool) – Should the calculations and the resulting time series be only over the irrigation season? The irrigation season is from October through to the end of April.

  • usage_allo_ratio (int or float) – The cut off ratio of usage/allocation. Any usage above this ratio will be removed from the results (subsequently reducing the metered allocation).

  • Results

  • -------

  • DataFrame – Indexed by the groupby (and date)

plotting methods

AlloUsage.plot_group(self, freq, val='total', group='SwazName', with_restr=True, yaxis_mag=1000000, yaxis_lab='Million', col_pal='pastel', export_path='', **kwargs)

Function to plot the allocation, metered allocation, and usage as a time series barchart with three adjacent bars per time period. Optionally with restriction volumes.

Parameters
  • freq (str) – The Pandas time series freq.

  • val (str) – The volume value columns. Must be one of ‘total’, ‘gw’, or ‘sw’.

  • group (str) – The grouping of the plot sets. Where each plot will be broken into the group values.

  • with_restr (bool) – Should the restriction volumes be included in the plots?

  • yaxis_mag (int) – The magnitude that the volumes should be divided by and plotted with on the Y axis.

  • yaxis_lab (str) – The label of the Y axis.

  • col_pal (str) – The seaborn color palette to use.

  • export_path (str) – The path where all the plots will be saved.

  • **kwargs – Any kwargs to be passed to get_ts.

Returns

But outputs many png files to the export_path.

Return type

None

AlloUsage.plot_stacked(self, freq, val='total', stack='use_type', group='SwazName', yaxis_mag=1000000, yaxis_lab='Million', col_pal='pastel', export_path='', **kwargs)

Function to plot the allocation stacked by a specific ‘stack’ group as a time series barchart.

Parameters
  • freq (str) – The Pandas time series freq.

  • val (str) – The allocation volume column. Must be one of ‘total’, ‘gw’, or ‘sw’.

  • stack (str) – The field of categories used for the volume stacking.

  • group (str) – The grouping of the plot sets. Where each plot will be broken into the group values.

  • with_restr (bool) – Should the restriction volumes be included in the plots?

  • yaxis_mag (int) – The magnitude that the volumes should be divided by and plotted with on the Y axis.

  • yaxis_lab (str) – The label of the Y axis.

  • col_pal (str) – The seaborn color palette to use.

  • export_path (str) – The path where all the plots will be saved.

  • **kwargs – Any kwargs to be passed to get_ts.

Returns

But outputs many png files to the export_path.

Return type

None

API Pages