def main(): with rpc.Client() as client: kg = rpc.unit_of('kg') units = rpc.unit_group_of('Units of mass', kg) client.put_unit_group(units) mass = rpc.flow_property_of('Mass', units) client.put_flow_property(mass) co2 = rpc.elementary_flow_of('CO2', mass) client.put_flow(co2) steel = rpc.product_flow_of('Steel', mass) client.put_flow(steel) process = rpc.process_of('Steel production') steel_output = rpc.output_of(process, steel, 1.0) steel_output.quantitative_reference = True process.exchanges.append(steel_output) co2_output = rpc.output_of(process, co2, 2.0) process.exchanges.append(co2_output) client.put_process(process) print(process)
def copy(): with rpc.Client() as client: status: rpc.FlowMapStatus = client.get_flow_map('ILCD_Import.csv') if not status.ok: raise RuntimeError(status.error) flow_map: rpc.FlowMap = status.flow_map flow_map.name = 'My copy.csv' status: rpc.Status = client.put_flow_map(flow_map) if not status.ok: raise RuntimeError(status.error)
def fetch_big_system(): client = rpc.Client() print('start at: %s' % datetime.datetime.now()) sys: rpc.ProductSystem = client.get_product_system( '4d4eb50c-3943-41c0-a90a-34b621474271').product_system print('fetched at: %s' % datetime.datetime.now()) sys.id = str(uuid.uuid4()) sys.name = "copied thing" client.put_product_system(sys) print('put at: %s' % datetime.datetime.now()) print(sys.name) client.close()
def create(): flow_map = rpc.FlowMap(name='hsc2ei.csv') entry = rpc.FlowMapEntry( conversion_factor=1.0, to=rpc.FlowMapRef(flow=rpc.Ref( id='64cea105-f89a-4f95-ae44-84ff904a28fc', name='limestone, crushed, washed', ref_unit='kg', ), provider=rpc.Ref( id='a321ecf5-907e-3d93-bcd9-2f1a9b5a1189', name='limestone production, crushed, washed ...', location='RoW'))) source: rpc.FlowMapRef = getattr(entry, 'from') source.flow.id = 'hsc/Limestone' source.flow.name = 'Limestone' source.flow.ref_unit = 'kg' flow_map.mappings.append(entry) with rpc.Client() as client: client.put_flow_map(flow_map)
def print_flow_maps(): with rpc.Client() as client: for flow_map_name in client.get_flow_maps(): print(flow_map_name)
def delete(): with rpc.Client() as client: status: rpc.Status = client.delete_flow_map('My copy.csv') if not status.ok: raise RuntimeError(status.error)
def setUp(self): self.client = rpc.Client()
def main(): with rpc.Client() as client: mass = client.get_flow_property(name='Mass').flow_property flow = rpc.product_flow_of('butter, fried', mass) client.put_flow(flow) print(client.get_flow(flow.id))
def main(): with rpc.Client(port=8080) as client: # we assume that we are connected to an openLCA # database with reference data, so that `Mass` # and the respective units are defined. # note that you should only get things by name # when you are sure that only one entity with # this name exists in the database, otherwise # it is safer to get things by their IDs # get flow property mass status = client.get_flow_property(name='Mass') if not status.ok: raise RuntimeError('flow property `Mass` does not exist') mass: rpc.FlowProperty = status.flow_property process = rpc.process_of('Iron Process - Gas cleaning') # set the location loc = location(client, 'Global') process.location.id = loc.id process.location.name = loc.name # add inputs inputs = [ ('Air Blast', rpc.FlowType.PRODUCT_FLOW, 245.8751543969349), ('Combustion Air', rpc.FlowType.WASTE_FLOW, 59.764430236449158), ('Hematite Pellets', rpc.FlowType.PRODUCT_FLOW, 200), ('Coke', rpc.FlowType.PRODUCT_FLOW, 50), ('Limestone', rpc.FlowType.PRODUCT_FLOW, 30.422441963816247), ('Steel Scrap', rpc.FlowType.WASTE_FLOW, 1.8853256607049331), ('Reductant', rpc.FlowType.PRODUCT_FLOW, 16), ('Washing Solution', rpc.FlowType.PRODUCT_FLOW, 75), ] for (name, flow_type, amount) in inputs: f = flow(client, name, flow_type, mass) i = rpc.input_of(process, f, amount) process.exchanges.append(i) # add outputs outputs = [ ('Slag', rpc.FlowType.WASTE_FLOW, 33.573534216580185), ('Carbon dioxide', rpc.FlowType.ELEMENTARY_FLOW, 140.44236409682583), ('Water vapour', rpc.FlowType.ELEMENTARY_FLOW, 30.591043638569072), ('Sulfur dioxide', rpc.FlowType.ELEMENTARY_FLOW, 0.01134867565288134), ('Air', rpc.FlowType.ELEMENTARY_FLOW, 158.58576460676247), ('Pig Iron', rpc.FlowType.PRODUCT_FLOW, 138.2370620852756), ('Heat Loss', rpc.FlowType.WASTE_FLOW, 32727.272727272728), ('Coarse Dust', rpc.FlowType.ELEMENTARY_FLOW, 1.4340290871696806), ('Scrubber Sludge', rpc.FlowType.WASTE_FLOW, 56.261517810249792), ('Fine Dust', rpc.FlowType.ELEMENTARY_FLOW, 0.18398927491951844), ] for (name, flow_type, amount) in outputs: f = flow(client, name, flow_type, mass) o = rpc.output_of(process, f, amount) if name == 'Pig Iron': o.quantitative_reference = True process.exchanges.append(o) client.put_process(process) print(process)
import olcarpc as rpc if __name__ == '__main__': with rpc.Client() as client: # select the product system and LCIA method and calculate the result system: rpc.Ref = client.get_descriptor( rpc.ProductSystem, name='compost plant, open').ref method: rpc.Ref = client.get_descriptor( rpc.ImpactMethod, name='TRACI [v2.1, February 2014]').ref result = client.calculate(system, method, with_regionalization=True).result # query the inventory i = 0 for r in client.get_inventory(result): print(r) i += 1 if i == 10: break # query the impact results for r in client.get_impacts(result): print(r) print(client.dispose(result))
def setUp(self) -> None: self.client = rpc.Client()