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

Make it easier to create & combine LCIA methods from LCIA categories #98

Open
msrocka opened this issue Oct 11, 2019 · 1 comment
Open

Make it easier to create & combine LCIA methods from LCIA categories #98

msrocka opened this issue Oct 11, 2019 · 1 comment
Assignees
Labels
Milestone

Comments

@msrocka
Copy link
Member

@msrocka msrocka commented Oct 11, 2019

See also the discussion here: https://ask.openlca.org/2056/is-it-possible-to-merge-2-lcia-methods-in-openlca

Probably, the cleanest solution would be to make LCIA categories "stand-alone entities" which would mean that you can use them in different LCIA methods (like flows in processes). But this requires quite some changes:

  • editing and user interface:
    • add them as category to the navigation tree
    • LCIA categories should have a separate editor
    • it should be possible to create / modify / delete them independently from the LCIA methods (=> of course with usage checks etc.)
    • use LCIA categories in the LCIA method editor via references
  • move LCIA method parameters to the LCIA category level
    • for the database update, we just copy them for each LCIA category
    • the parameter evaluation context moves to the LCIA category level
    • shapefiles and regionalized calculations!: probably this should also move to the category level
  • imports & exports:
    • JSON-LD: the LCIA categories are already stored in separate folders but updates regarding the parameters, shapefiles etc. are required; also the olca-schema doc, the IPC interface, olca-ipc.py etc. need an update then
    • ILCD: the "stand-alone" concept matches nicely with the concept of LCIA methods / categories in ILCD
    • EcoSpold 1: not sure if we still should support this?
    • SimaPro CSV: is currently not supported for LCIA methods in openLCA; there is https://github.com/GreenDelta/spm2olca that would need an update then
@msrocka msrocka self-assigned this Oct 11, 2019
@msrocka msrocka added the enhancement label Oct 11, 2019
@msrocka msrocka added this to the v1.11 milestone Oct 11, 2019
@msrocka

This comment has been minimized.

Copy link
Member Author

@msrocka msrocka commented Oct 11, 2019

Currently, using an LCIA category in another method is only possible by copying that category. With the following script it is possible to copy a LCIA category from one method to another (tested in openLCA 1.10 but should also work in 1.9):

from org.openlca.core.database import ImpactMethodDao

# the name of the indicator / LCIA category you want to copy
INDICATOR = "Climate change - GWP100"
# the method that contains the indicator
SOURCE_METHOD = "CML (baseline) [v4.4, January 2015]"
# the method where you want to have the indicator copied to
TARGET_METHOD = "My method"

def main():
  dao = ImpactMethodDao(db)

  # load the targe method
  target = dao.getForName(TARGET_METHOD)
  if len(target) == 0:
    log.error("Could not find method {}", TARGET_METHOD)
    return
  target = target[0]

  # check that the indicator is not already there
  for i in target.impactCategories:
    if i.name == INDICATOR:
      log.error("The indicator {} already exists in {}",
                INDICATOR, TARGET_METHOD)
      return

  # load the source method
  source = dao.getForName(SOURCE_METHOD)
  if len(source) == 0:
    log.error("Could not find method {}", SOURCE_METHOD)
    return
  source = source[0]

  # find the indicator
  indicator = None
  for i in source.impactCategories:
    if i.name == INDICATOR:
      indicator = i
      break
  if indicator is None:
    log.error("Could not find indicator {} in method {}",
              INDICATOR, SOURCE_METHOD)
    return

  # finally, copy the indicator
  log.info("Copy indicator {} from {} to {}",
           INDICATOR, SOURCE_METHOD, TARGET_METHOD)
  cloned = indicator.clone()
  target.impactCategories.add(cloned)
  dao.update(target)
  log.info("done")

if __name__ == "__main__":
  main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
1 participant
You can’t perform that action at this time.