Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

InconsistentGlobalIndex error when trying to modify the characterization matrix via interfaces #70

Open
mfastudillo opened this issue Aug 31, 2024 · 0 comments

Comments

@mfastudillo
Copy link
Contributor

From this stackoverflow post. If I try to modify the characterization matrix via an interface I get an IconsistentGlobalIndex error when I try to calculate the lca score.

import bw2data as bd
import bw_processing as bwp
import numpy as np
import bw2calc as bc

bd.projects.set_current("bw25")

mobility_db = bd.Database('Mobility example')
combustion_car_driving = mobility_db.get(name='Driving an combustion car')
co2 = mobility_db.get(name='CO2')

# create datapackage with alternative values for the GWP of CO2
indices_array = np.array([(co2.id,
                           bd.geomapping[bd.config.global_location])],
                           dtype=bwp.INDICES_DTYPE)

values_array = np.array([list(range(1,10))])
dp_c = bwp.create_datapackage(sequential=True)
dp_c.add_dynamic_array(
    matrix='characterization_matrix',
    indices_array=indices_array,
    interface=values_array,
)

If I set the global_index using the default global_location then it works. But this is not very intuitive. I guess this should be done by default. I am not sure where it the right place.

## hack
r = dp_c.filter_by_attribute('matrix',
    'characterization_matrix').filter_by_attribute("kind","indices").resources[0]
r["global_index"] = bd.geomapping[bd.config.global_location]
##
fu, data_objs , _ = bd.prepare_lca_inputs({combustion_car_driving:1},
                                          method=('IPCC','simple'))
lca = bc.LCA(demand=fu,
       method=('IPCC','simple'),
       data_objs=data_objs+[dp_c],
       use_arrays=True)
lca.lci()
lca.lcia()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant