Example #1
0
 def __write_products(self, pack):
     for s in self.model.each_sector():
         cat_id = util.make_uuid('FLOW', s.sub_category, s.category)
         flow = {
             "@context":
             "http://greendelta.github.io/olca-schema/context.jsonld",
             "@type":
             "Flow",
             "@id":
             s.product_uid,
             "name":
             s.name,
             "category": {
                 "@type": "Category",
                 "@id": cat_id
             },
             "flowType":
             "PRODUCT_FLOW",
             "flowProperties": [{
                 "@type": "FlowPropertyFactor",
                 "referenceFlowProperty": True,
                 "conversionFactor": 1.0,
                 "flowProperty": {
                     "@type": "FlowProperty",
                     "@id": "b0682037-e878-4be4-a63a-a7a81053a691"
                 }
             }]
         }
         loc = self.model.locations.get(s.location)
         if loc is not None:
             flow["location"] = {"@type": "Location", "@id": loc.uid}
         dump(flow, 'flows', pack)
Example #2
0
def _write_category(model_type, name, pack, parent_name=None):
    uid = util.make_uuid(model_type, name, parent_name)
    c = {
        "@context": "http://greendelta.github.io/olca-schema/context.jsonld",
        "@type": "Category",
        "@id": uid,
        "name": name,
        "modelType": model_type
    }
    if parent_name is not None:
        parent_id = util.make_uuid(model_type, parent_name)
        # to be compatible with openLCA 1.4 and 1.5 we use 'category' and
        # 'parentCategory'
        c["category"] = {"@type": "Category", "@id": parent_id}
        c["parentCategory"] = {"@type": "Category", "@id": parent_id}
    dump(c, 'categories', pack)
Example #3
0
 def __prepare_process(self, s: ref.Sector):
     cat_id = util.make_uuid('PROCESS', s.sub_category, s.category)
     p = {
         "@context":
         "http://greendelta.github.io/olca-schema/context.jsonld",
         "@type":
         "Process",
         "@id":
         s.uid,
         "name":
         s.name,
         "processTyp":
         "UNIT_PROCESS",
         "category": {
             "@type": "Category",
             "@id": cat_id
         },
         "processDocumentation": {
             "copyright": False
         },
         "exchanges": [{
             "@type": "Exchange",
             "avoidedProduct": False,
             "input": False,
             "amount": 1.0,
             "flow": {
                 "@type": "Flow",
                 "@id": s.product_uid
             },
             "unit": {
                 "@type": "Unit",
                 "@id": "3f90ee51-c78b-4b15-a693-e7f320c1e894"
             },
             "flowProperty": {
                 "@type": "FlowProperty",
                 "@id": "b0682037-e878-4be4-a63a-a7a81053a691"
             },
             "quantitativeReference": True
         }]
     }
     Export.__add_doc_fields(p, s)
     loc = self.model.locations.get(s.location)
     if loc is not None:
         p["location"] = {"@type": "Location", "@id": loc.uid}
     if self.with_data_quality:
         append_data_quality(p, s)
     return p
Example #4
0
def _write_methods(dump_fn, ia_table, pack):
    for method in _get_methods(ia_table):
        log.info('Write LCIA method %s', method)
        m = {
            "@context":
            "http://greendelta.github.io/olca-schema/context.jsonld",
            "@type": "ImpactMethod",
            "@id": util.make_uuid(method),
            "name": method,
            "impactCategories": []
        }
        for category in _get_categories(ia_table, method):
            c = {
                "@type": "ImpactCategory",
                "@id": category.uid,
                "name": category.name
            }
            m['impactCategories'].append(c)
        dump_fn(m, 'lcia_methods', pack)
 def test_make_uuid(self):
     expected = str(uuid.uuid3(uuid.NAMESPACE_OID, "flow/a/1/b"))
     actual = util.make_uuid("Flow", None, "a", 1, "B")
     self.assertEqual(expected, actual)