Pathways

This python file contains the class CreatePathway and the methods necessary for this class:

  • get_values() - fetch Value

  • get_infos() - fetch Stakeholder, realisation factor, type, entries ID, entries names

  • get_precision() - fetch dimensions of precision

  • estimate_homogeneisation() - type 2 function, transform into mean notation

  • estimate_statistical() - type 2 function, statistical model for normalisation

  • calcul() - type 1 function, pathway evaluation.

Pathways entries and output are defined in pathway_data database (see the Guide to study its structure). We use the “get_entry_list” method to obtain the values of the entry parameters. We use the “get_precision” method to obtain the precision of the value of each entry.

We use pathways calcul to return the output value of the pathway, depending on its ID.

1/ Creating a new pathway ? (*more complex explanation in Contributor Guide*)

A. To create a new pathway with ID_new as ID, start by adding its metadata in your pathway_data database. There, make sure the entries are existing in TEMPLATE sheet. If not, add them.

B. Then, add an “if self.ID == ID_new:” and the calculs of the new pathway. The entries are automatically stored in a dictionary called e. To use an entry called “entry” in the database, just type e[“entry”]

  1. Finally, store the result in self.value

2/ CreatePathway Class & functions

class Pathways.CreatePathway(id_)

The attribute of CreatePathway class object are:

  • self.ID:

    The only parameter of the CreatePathway class. Its the Id of the pathway in the pathway_data database.

  • self.type:

    « 1 » if pathway evaluation use calcul(). « 2, statistical_model » if it use estimate methods. Fetched using get_info()

  • self.stakeholder:

    Where the output stakeholder will be stored.

  • self.statistique_model :

    Fetched using get_info().

  • self.realisation :

    The pathway realisation factor. Forced on 1 for alpha version.

  • self.entry :

    List of entries ID, fetched using get_info().

  • self.name :

    List of entries name, fetched using get_info().

  • self.precision:

    A list of integer containing the precision fetched using get_precision().

  • self.value:

    Raw value of the evaluation of the pathway.

  • self.value_n:

    Final value after going through homogeneisation, normalisation, ponderation.

Paramètres:

id (int) – The identifiant of the pathway we are creating.

calcul(LCI_table)

The calcul() method translates the calculating method to evaluate a pathway.

The function stores input parameters in a dictionary named “e”. So, to use the variable “degrad_eaux” in the code, simply use e[“degrad_eaux”].

In the function, we look at the pathway identifier and perform the corresponding calculation module. Finally, we store the result in self.value.

Avertissement

Be careful to name inputs in the same way in the LCI and in the calcul() function.

Paramètres:

LCI_table – a panda.DataFrame of the Life cycle inventory of either the scenario or the reference.

estimate_homogeneisation(LCI_table)

The function estimate_homogeneisation is the 1st/2 function of the estimate evaluation method. It aims at importing the entries values, and translating the notation into a mean notation.

Paramètres:

LCI_table – a panda.DataFrame of the Life cycle inventory of either the scenario or the reference.

estimate_statistical(ref)

The function estimate_statistical is the 2nd/2 function of the estimate evaluation method. Its goal is to transform the value using the predetermined statistical model.

Paramètres:

ref – A Class CreatePathway object that belong to the chosen reference, with the same name & ID as the pathway that called the pathway_estimate function.

get_info(pathways_data)

get_info is a method of the class CreatePathway. It is used to fetch the data of the current pathway from pathways_data database. It will fetch: The stakeholder, the realisation factor, the pathways’s type, the entries list of ID and names.

Paramètres:

pathways_data – a panda.DataFrame of the database of the information of every pathway. See Pathways database for further details.

get_precision(LCI_table)

get_precision is a self function of the class CreatePathway. It is used to fetch the precision’s data of the pathway’s inputs (which IDs are stored in self.entry). Then it will calcul the mean of each precision category.

Paramètres:

LCI_table – a panda.DataFrame of the Life cycle inventory of either the scenario or the reference.

Pathways.get_values(LCI_table, id_variable)

Fetch data of the variable with ID id_variable from the DataFrame dataframe_variables.

It accepts three formats:
  • string (ex: Hello)

  • list (ex: [1,2,3])

  • array (ex: [[1,2],[A,B]])

pathway_get_value return a string, a list of string, or an array of string. But in string type!

Paramètres:
  • LCI_table (panda.DataFrame) – a dataframe with the Life cycle inventory of either a scenario or a reference.

  • id_variable (int) – The ID of the variable we want the data.

Return value:

The string or list or array containing the data of the variable.