antelope.flows package

Submodules

antelope.flows.flow module

antelope.flows.flow.flowname_is_biogenic(flowname)
class antelope.flows.flow.Flow

Bases: FlowInterface, ABC

A partly-abstract class that implements the flow specification but not the entity specification.

Included in this specification is a detection of biogenic CO2 by regex Each flow has a quell_co2 property which is True if:

  • the flow is a synonym for CO2 and

  • the flow’s name matches the biogenic regex: ‘(biotic|biogenic|non-fossil|in air)’ (case insensitive)

There are 3 ways for a flow to be identified as a synonym for CO2:
  1. pass is_co2=True at instantiation

  2. set flow.is_co2 = True

  3. assign a CasNumber equivalent to ‘124-38-9’

Item #2 can be used in general by downstream implementations.

For the time being, the flow name matching the regex is the only way to identify a flow as biogenic.

property locale

A flow can have a locale :return:

property is_co2
property name
property synonyms
property context

A flow’s context is any hierarchical tuple of strings (generic, intermediate, …, specific). :return:

match(other)

match if any synonyms match :param other: :return:

property quell_co2
lookup_cf(quantity, context, locale, refresh=False, **kwargs)

Cache characterization factors obtained from quantity relation queries. It is decided to leave this in the interface, since it does not depend on anything from outside the interface.

However, it does introduce some severe constraints. One: it requires an EXACT MATCH of quantity, context, and locale to retrieve a cached result. Wildcard results, such as with ‘None’ specified for any of the three, are not supported.

Two, it requires implementations to properly handle the Quell-Biogenic-CO2 feature.

BIOGENIC CO2: This function includes a mechanism to suppress ALL impact scores for biogenic CO2. Any flow can have the is_co2 flag set– this happens automatically if the flow is given a name that matches ‘carbon dioxide’ or a CAS number that matches CO2 (124-38-9). It can also be set in client code.

If this flag is true, AND the flow’s name matches a regexp that describes non-fossil, biogenic, “in air”, then the flow is considered to be biogenic CO2 (its quell_co2 property is True).

It is up to implementation code to handle these properties.

Parameters:
  • quantity

  • context

  • locale

  • refresh – drop cached result and re-query.

  • kwargs

Returns:

whatever the implementation’s quantity_relation() returns

pop_char(qq, cx, loc)
clear_chars(quantity=None)
see_chars(qq, cx, cfs)
Parameters:
  • qq – an actual quantity or quantity ref

  • cx – an actual context

  • cfs – a list of objects that could be returned from a quantity_relation query (implementation-dependent)

Returns:

is_seen(qq, context=None, locale=None)

antelope.flows.flow_interface module

class antelope.flows.flow_interface.BaseEntity

Bases: object

The very most basic characteristics of entities and entity refs

property entity_type
property reference_entity

Must have a .unit property that returns a string, should have .entity_type property that returns ‘quantity’ :return:

property origin

Must return a resolvable unique ID, nominally ‘origin/external_ref’ :return:

property external_ref

Must return a resolvable unique ID, nominally ‘origin/external_ref’ :return:

properties()
get(item)
property is_entity

Used to distinguish between entities and catalog refs (which answer False) :return: True for LcEntity subclasses

make_ref(query)

if is_entity is true, entity must return a ref made from the provided query :param query: :return:

class antelope.flows.flow_interface.NullEntity(origin)

Bases: BaseEntity

entity_type = 'null'
external_ref = 'null'
reference_entity = None
property origin

Must return a resolvable unique ID, nominally ‘origin/external_ref’ :return:

properties()
get(item)
make_ref(query)

if is_entity is true, entity must return a ref made from the provided query :param query: :return:

class antelope.flows.flow_interface.FlowInterface

Bases: BaseEntity, ABC

An abstract class that establishes common functionality for OBSERVATIONS OF FLOWS. A Flow consists of:
  • a reference quantity with a fixed unit

  • a flowable (a list of synonyms for the flowable substnce being described)

  • a context (a hierarchical list of strings designating the flows ‘compartment’ or category)

Must be implemented (properties):
  • name - string

  • link - string

  • synonyms - iterable

property unit
property name
property synonyms
property context

A flow’s context is any hierarchical tuple of strings (generic, intermediate, …, specific) 0-length default for flows with no specific context :return:

property locale

A flow can have a locale :return:

get_context()
match(other)

match if any synonyms match :param other: :return:

lookup_cf(quantity, context, locale, refresh=False, **kwargs)

Look for cached characterizations, and retrieve one from the provided quantity if none is found. :param quantity: a QuantityRef :param context: :param locale: :param refresh: [False] if True, discard cached CF :param kwargs: passed to quantity relation :return:

pop_char(quantity, context, locale)

Module contents