bw2io.importers.base_lci
#
Module Contents#
Classes#
Base class for format-specific importers. |
- class bw2io.importers.base_lci.LCIImporter(db_name)[source]#
Bases:
bw2io.importers.base.ImportBase
Base class for format-specific importers.
Defines workflow for applying strategies.
Takes a database name (string) as initialization parameter.
- create_new_biosphere(biosphere_name, relink=True)[source]#
Create new biosphere database from biosphere flows in
self.data
.Links all biosphere flows to new bio database if
relink
.
- match_database(db_name=None, fields=None, ignore_categories=False, relink=False, kind=None)[source]#
Match current database against itself or another database.
If
db_name
is None, match against current data. Otherwise,db_name
should be the name of an existingDatabase
.fields
is a list of fields to use for matching. Field values are case-insensitive, but otherwise must match exactly for a link to be valid. Iffields
isNone
, use the default fields of ānameā, ācategoriesā, āunitā, āreference productā, and ālocationā.If
ignore_categories
, link based only on name, unit and location.ignore_categories
conflicts withfields
.If
relink
, relink exchanges even if a link is already present.kind
can be a string or a list of strings. Common values are ātechnosphereā, ābiosphereā, āproductionā, and āsubstitutionā.Nothing is returned, but
self.data
is changed.
- write_database(data=None, delete_existing=True, backend=None, activate_parameters=False, db_name=None, searchable=True, **kwargs)[source]#
Write data to a
Database
.All arguments are optional, and are normally not specified.
delete_existing
effects both the existing database (it will be emptied prior to writing if True, which is the default), and, ifactivate_parameters
is True, existing database and activity parameters. Database parameters will only be deleted if the import data specifies a new set of database parameters (i.e.database_parameters
is notNone
) - the same is true for activity parameters. If you need finer-grained control, please use theDatabaseParameter
, etc. objects directly.- Args:
data (dict, optional): The data to write to the
Database
. Default isself.data
.delete_existing (bool, default
True
): See above.activate_parameters (bool, default
False
). Instead of storing parameters inActivity
and other proxy objects, createActivityParameter
and other parameter objects, and evaluate all variables and formulas.backend (string, optional): Storage backend to use when creating
Database
. Default is the default backend.
- Returns:
Database
instance.
- write_excel(only_unlinked=False, only_names=False)[source]#
Write database information to a spreadsheet.
If
only_unlinked
, then only write unlinked exchanges.If
only_names
, then write only activity names, no exchange data.Returns the filepath to the spreadsheet file.
- write_project_parameters(data=None, delete_existing=True)[source]#
Write global parameters to
ProjectParameter
database table.delete_existing
controls whether new parameters will delete_existing existing parameters, or just update values. Thename
field is used to determine if a parameter exists.data
should be a list of dictionaries (self.project_parameters
is used by default):[{ 'name': name of variable (unique), 'amount': numeric value of variable (optional), 'formula': formula in Python as string (optional), optional keys like uncertainty, etc. (no limitations) }]