API Reference

This is a reference covering the Python modules and objects across the CATS codebase. For the interface for the command-line, which is likely to be more relevant to users (rather than developers) of CATS, please see Command-line (CLI) reference.

Modules

cats.__init__

cats.__init__.parse_arguments()

Parse command line arguments :return: [dict] parsed arguments

cats.__main__

cats.CI_api_interface

class cats.CI_api_interface.APIInterface(get_request_url, parse_response_data)
get_request_url

Alias for field number 0

parse_response_data

Alias for field number 1

exception cats.CI_api_interface.InvalidLocationError
cats.CI_api_interface.ciuk_parse_response_data(response: dict)

This wraps the API from carbonintensity.org.uk and is set up to cache data from call to call even accross different processes within the same half hour window. The returned prediction data is in half hour blocks starting from the half hour containing the current time and extending for 48 hours into the future.

Parameters

response

Returns

cats.CI_api_query

cats.CI_api_query.get_CI_forecast(location: str, CI_API_interface) list[cats.forecast.CarbonIntensityPointEstimate]

get carbon intensity from an API

Given the location and an API interface, return a list of predictions of the future carbon intensity.

param location: [str] Depends on country. UK postcode (just the first section), e.g. M15. returns: a list of CarbonIntensityPointEstimate

cats.carbonFootprint

class cats.carbonFootprint.Estimates(now, best, savings)
best

Alias for field number 1

now

Alias for field number 0

savings

Alias for field number 2

cats.forecast

class cats.forecast.CarbonIntensityAverageEstimate(value: float, start: datetime.datetime, end: datetime.datetime)

Represents a single data point within an integrated carbon intensity timeseries. Use order=True in order to enable comparison of class instance based on the first attribute. See https://peps.python.org/pep-0557

class cats.forecast.CarbonIntensityPointEstimate(value: float, datetime: datetime.datetime)

Represents a single data point within an intensity timeseries. Use order=True in order to enable comparison of class instance based on the first attribute. See https://peps.python.org/pep-0557

cats.optimise_starttime

cats.optimise_starttime.get_avg_estimates(data, duration=None)

Get lowest carbon intensity in data depending on user method return dict of timestamp and carbon intensity

duration is in minutes

Python objects

In cats.__init__

Functions

cats.__init__.parse_arguments()

Parse command line arguments :return: [dict] parsed arguments

cats.__init__.main([arguments])

In cats.__main__

n/a

In cats.CI_api_interface

Functions

cats.CI_api_interface.ciuk_request_url(...)

cats.CI_api_interface.ciuk_parse_response_data(...)

This wraps the API from carbonintensity.org.uk and is set up to cache data from call to call even accross different processes within the same half hour window.

Variables and constants

cats.CI_api_interface.APIInterface(...)

cats.CI_api_interface.API_interfaces

dict() -> new empty dictionary dict(mapping) -> new dictionary initialized from a mapping object's (key, value) pairs dict(iterable) -> new dictionary initialized as if via: d = {} for k, v in iterable: d[k] = v dict(**kwargs) -> new dictionary initialized with the name=value pairs in the keyword argument list. For example: dict(one=1, two=2).

In cats.CI_api_query

Functions

cats.CI_api_query.get_CI_forecast(location, ...)

get carbon intensity from an API

In cats.carbonFootprint

Classes

cats.carbonFootprint.greenAlgorithmsCalculator(...)

Variables and constants

cats.carbonFootprint.Estimates(now, best, ...)

In cats.forecast

Classes

cats.forecast.CarbonIntensityPointEstimate(...)

Represents a single data point within an intensity timeseries.

cats.forecast.CarbonIntensityAverageEstimate(...)

Represents a single data point within an integrated carbon intensity timeseries.

cats.forecast.WindowedForecast(data, ...)

In cats.optimise_starttime

Functions

cats.optimise_starttime.get_avg_estimates(data)

Get lowest carbon intensity in data depending on user method return dict of timestamp and carbon intensity