bw2io.importers.base_lci#
Classes#
Base class for format-specific importers. |
Module Contents#
- 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_nameis None, match against current data. Otherwise,db_nameshould be the name of an existingDatabase.fieldsis a list of fields to use for matching. Field values are case-insensitive, but otherwise must match exactly for a link to be valid. IffieldsisNone, use the default fields of ‘name’, ‘categories’, ‘unit’, ‘reference product’, and ‘location’.If
ignore_categories, link based only on name, unit and location.ignore_categoriesconflicts withfields.If
relink, relink exchanges even if a link is already present.kindcan be a string or a list of strings. Common values are “technosphere”, “biosphere”, “production”, and “substitution”.Nothing is returned, but
self.datais changed.
- write_database(data=None, delete_existing=True, backend=None, activate_parameters=False, **kwargs)[source]#
Write data to a
Database.All arguments are optional, and are normally not specified.
delete_existingeffects both the existing database (it will be emptied prior to writing if True, which is the default), and, ifactivate_parametersis 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_parametersis notNone) - the same is true for activity parameters. If you need finer-grained control, please use theDatabaseParameter, etc. objects directly.- Parameters:
data (*) – The data to write to the
Database. Default isself.data.delete_existing (*) – See above.
activate_parameters (*)
backend (*) – Storage backend to use when creating
Database. Default is the default backend.
- Returns:
Databaseinstance.
- 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
ProjectParameterdatabase table.delete_existingcontrols whether new parameters will delete_existing existing parameters, or just update values. Thenamefield is used to determine if a parameter exists.datashould be a list of dictionaries (self.project_parametersis 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) }]