You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am trying to import Ucrad as an LCIA method in brightway2, through its Excel file containing the characterization factors for various radionuclides. I've followed the documentation and use the code below, which works fine in theory (tested on the already present ionising radiations: human health method in EFv3.1, by extracting the data from the .json, building an Excel in the correct form, and do the import).
# Initialize and set project
import brightway2 as bw
import bw2io
bw.projects.set_current('myproject')
# bw.bw2setup() have already been done previously
# Necessary variables
NewLCIAm_path = r"mypath\Ucrad-BqU235AirEquivBq-CF.xlsx"
NewLCIAm_name = ("Ucrad", "Ucrad midpoint Bq U235 Air-Eq")
NewLCIAm_description = ""
NewLCIAm_unit = "Bq U235 Air-Eq"
# Import from Excel
NewLCIAm = bw2io.ExcelLCIAImporter(
NewLCIAm_path,
NewLCIAm_name,
NewLCIAm_description,
NewLCIAm_unit,
)
NewLCIAm.apply_strategies()
File ~\AppData\Local\miniconda3\envs\bw2\Lib\site-packages\bw2io\importers\base_lcia.py:118, in LCIAImporter.add_missing_cfs(self)
116 if "input" not in cf:
117 cf["code"] = str(uuid.uuid4())
--> 118 while (self.biosphere_name, cf["code"]) in mapping:
119 cf["code"] = str(uuid.uuid4())
120 new_flows.append(cf)
AttributeError: 'ExcelLCIAImporter' object has no attribute 'biosphere_name'
I don't understand the problem, did I miss something obvious?
Paul
The text was updated successfully, but these errors were encountered:
By looking at the code, it seems like the init of the ExcelLCIAImporter class in the excel_lcia.py prevents or cancels the init of the LCIAImporter class in the base_lcia.py.
The LCIAImporter class init in base_lcia.py:
class LCIAImporter(ImportBase):
def __init__(self, filepath, biosphere=None):
print("init yup")
self.applied_strategies = []
self.filepath = filepath
self.biosphere_name = biosphere or config.biosphere
if self.biosphere_name not in databases:
raise ValueError(
"Can't find biosphere database {}".format(self.biosphere_name)
)
self.strategies = [
# [...] the code continues
The excel_lcia.py import the LCIAImporter class, so biosphere_name should be ok, but then we have the ExcelLCIAImporter class init :
class ExcelLCIAImporter(LCIAImporter):
# [...] Some code commmentaries
format = "Excel"
extractor = ExcelExtractor
def __init__(self, filepath, name, description, unit, **metadata):
assert isinstance(name, tuple)
super(ExcelLCIAImporter, self).__init__(filepath, biosphere=None)
self.strategies = [
# [...] the code continues
The line super(ExcelLCIAImporter, self).__init__(filepath, biosphere=None) was added on our side after looking at the structure of the init of the SimaProLCIACSVImporter class, which contains an analog line, which gave the idea. When it's added, the AttributeError on biosphere_name of the ExcelLCIAImporter disappears.
Not sure if it's the proper way to fix the issue, but hope it helps!
Hello there,
I am trying to import Ucrad as an LCIA method in brightway2, through its Excel file containing the characterization factors for various radionuclides. I've followed the documentation and use the code below, which works fine in theory (tested on the already present ionising radiations: human health method in EFv3.1, by extracting the data from the .json, building an Excel in the correct form, and do the import).
Output:
Then:
Returns:
As the unlinked cfs come from the ones addressing unpresent biosphere flows, I thus do:
Which returns:
I don't understand the problem, did I miss something obvious?
Paul
The text was updated successfully, but these errors were encountered: