bw2io.extractors.ecospold2#
Attributes#
Classes#
Functions#
|
Get attribute of an object; return empty dict if AttributeError occurs. |
Module Contents#
- class bw2io.extractors.ecospold2.Ecospold2DataExtractor[source]#
Bases:
object
- classmethod abort_exchange(exc, comment=None)[source]#
Set the uncertainty type of the input exchange to UndefinedUncertainty.id. Remove the keys “scale”, “shape”, “minimum”, and “maximum” from the dictionary. Update the “loc” key to “amount”. Append “comment” to “exc[‘comment’]” if “comment” is not None, otherwise append “Invalid parameters - set to undefined uncertainty.” to “exc[‘comment’]”.
- Parameters:
exc (dict) – The input exchange.
comment (str, optional) – A string to append to “exc[‘comment’]”. Defaults to None.
- Returns:
None
- classmethod condense_multiline_comment(element)[source]#
Concatenate the text of all child elements with the tag “{http://www.EcoInvent.org/EcoSpold02}text” and the text of all child elements with the tag “{http://www.EcoInvent.org/EcoSpold02}imageUrl” in the given element XML element.
cls (type): The class object. element (lxml.etree.Element): The XML element.
- Returns:
str (The concatenated text of all child elements with the tag)
”{http (//www.EcoInvent.org/EcoSpold02}text” and the text of all child)
elements with the tag “{http (//www.EcoInvent.org/EcoSpold02}imageUrl”.)
If an error occurs, an empty string is returned.
- classmethod extract(dirpath: pathlib.Path, db_name: str, use_mp: bool = True)[source]#
Extract data from all ecospold2 files in a directory.
- Parameters:
dirpath (str) – The path to the directory containing the ecospold2 files.
db_name (str) – The name of the database to create.
use_mp (bool, optional) – Whether to use multiprocessing to extract the data (default is True).
- Returns:
A list of the extracted data from the ecospold2 files.
- Return type:
list
- Raises:
FileNotFoundError – If no .spold files are found in the directory.
- classmethod extract_activity(dirpath, filename, db_name)[source]#
Extract and return the data of an activity from an XML file with the given filename in the directory with the path dirpath.
cls (type): The class object. dirpath (str): The path of the directory containing the XML file. filename (str): The name of the XML file. db_name (str): The name of the database.
- Returns:
dict –
- follows:
”comment”: str. The condensed multiline comment.
”classifications”: list of tuples. The classification systems and values of the activity.
”activity type”: str. The type of the activity.
”activity”: str. The ID of the activity.
”database”: str. The name of the database.
”exchanges”: list of dicts. The exchanges of the activity.
”filename”: str. The name of the XML file.
”location”: str. The short name of the location of the activity.
”name”: str. The name of the activity.
”synonyms”: list of str. The synonyms of the activity.
”parameters”: dict. The parameters of the activity.
”authors”: dict of dicts. The authors of the activity. The keys and values of the inner dicts are as follows:
”name”: str. The name of the author.
”email”: str. The email of the author.
”type”: str. The type of the activity.
- Return type:
The dictionary of data for the activity. The keys and values are as
- classmethod extract_exchange(exc)[source]#
Process exchange.
Input groups are:
Materials/fuels
Electricity/Heat
Services
From environment (elementary exchange only)
FromTechnosphere
Output groups are:
0. ReferenceProduct 2. By-product 3. MaterialForTreatment 4. To environment (elementary exchange only) 5. Stock addition
- classmethod extract_parameter(exc)[source]#
Extract parameter information from “exc” and return it as a tuple.
- Parameters:
exc (dict) – The input exchange.
- Returns:
A tuple containing the parameter name and a dictionary containing the parameter information.
- Return type:
tuple
- classmethod extract_properties(exc)[source]#
Extract the properties of an exchange.
- Parameters:
exc (lxml.etree.Element) – An XML element representing an exchange.
- Returns:
A dictionary of the properties of the exchange. Each key in the dictionary is a string representing the name of a property, and the corresponding value is a dictionary with the following keys:
”amount” (float): The numerical value of the property.
”comment” (str, optional): A comment describing the property, if available.
”unit” (str, optional): The unit of the property, if available.
”variable name” (str, optional): The name of the variable associated with
the property, if available.
- Return type:
dict
- bw2io.extractors.ecospold2.getattr2(obj, attr)[source]#
Get attribute of an object; return empty dict if AttributeError occurs.
- Parameters:
obj (object) – The object to get attribute from.
attr (str) – The name of the attribute to get.
- Returns:
The attribute value if it exists, else an empty dict.
- Return type:
dict