Search in sources :

Example 1 with ImpactDescriptor

use of org.openlca.core.model.descriptors.ImpactDescriptor in project olca-modules by GreenDelta.

the class SimulationResultExport method writeImpactSheet.

private void writeImpactSheet(Workbook wb) {
    Sheet sheet = wb.createSheet("Impact Assessment");
    Excel.trackSize(sheet, 0, IMPACT_HEADER.length + 6);
    row = 0;
    row++;
    writer.headerRow(sheet, row, 1, IMPACT_HEADER);
    int nextCol = IMPACT_HEADER.length + 1;
    writeValueHeaders(sheet, row, nextCol);
    row++;
    for (ImpactDescriptor impact : result.getImpacts()) {
        writer.impactRow(sheet, row, 1, impact);
        double[] values = result.getAll(impact);
        writeValues(sheet, row, IMPACT_HEADER.length + 1, values);
        row++;
    }
    Excel.autoSize(sheet, 0, IMPACT_HEADER.length + 6);
}
Also used : ImpactDescriptor(org.openlca.core.model.descriptors.ImpactDescriptor) Sheet(org.apache.poi.ss.usermodel.Sheet) SXSSFSheet(org.apache.poi.xssf.streaming.SXSSFSheet)

Example 2 with ImpactDescriptor

use of org.openlca.core.model.descriptors.ImpactDescriptor in project olca-modules by GreenDelta.

the class SimulationResultExport method fillContributions.

private void fillContributions(TechFlow pp, Sheet sheet) {
    row = 0;
    String label = "Contributions of: ";
    if (pp.provider() != null) {
        label += pp.provider().name;
        if (pp.provider() instanceof ProcessDescriptor) {
            ProcessDescriptor p = (ProcessDescriptor) pp.provider();
            if (p.location != null) {
                Location loc = cache.get(Location.class, p.location);
                if (loc != null) {
                    label += " - " + loc.code;
                }
            }
        }
    }
    if (pp.flow() != null) {
        label += " | " + pp.flow().name;
        if (pp.flow().location != null) {
            Location loc = cache.get(Location.class, pp.flow().location);
            if (loc != null) {
                label += " - " + loc.code;
            }
        }
    }
    writer.headerRow(sheet, row, 1, label);
    row++;
    row++;
    if (result.hasImpacts()) {
        writer.headerRow(sheet, row++, 1, "Direct LCIA contributions");
        writer.headerRow(sheet, row, 1, IMPACT_HEADER);
        int valCol = IMPACT_HEADER.length + 1;
        writeValueHeaders(sheet, row++, valCol);
        for (ImpactDescriptor impact : result.getImpacts()) {
            writer.impactRow(sheet, row, 1, impact);
            double[] values = result.getAllDirect(pp, impact);
            writeValues(sheet, row, IMPACT_HEADER.length + 1, values);
            row++;
        }
        row++;
        writer.headerRow(sheet, row++, 1, "Upstream LCIA contributions");
        writer.headerRow(sheet, row, 1, IMPACT_HEADER);
        writeValueHeaders(sheet, row++, valCol);
        for (ImpactDescriptor impact : result.getImpacts()) {
            writer.impactRow(sheet, row, 1, impact);
            double[] values = result.getAllUpstream(pp, impact);
            writeValues(sheet, row, IMPACT_HEADER.length + 1, values);
            row++;
        }
        row++;
    }
    List<EnviFlow> flows = result.getFlows();
    writer.headerRow(sheet, row++, 1, "Direct LCI contributions - Inputs");
    writeFlowContributions(flows, pp, true, result::getAllDirect, sheet);
    writer.headerRow(sheet, row++, 1, "Direct LCI contributions - Outputs");
    writeFlowContributions(flows, pp, false, result::getAllDirect, sheet);
    writer.headerRow(sheet, row++, 1, "Upstream LCI contributions - Inputs");
    writeFlowContributions(flows, pp, true, result::getAllUpstream, sheet);
    writer.headerRow(sheet, row++, 1, "Upstream LCI contributions - Outputs");
    writeFlowContributions(flows, pp, false, result::getAllUpstream, sheet);
}
Also used : ImpactDescriptor(org.openlca.core.model.descriptors.ImpactDescriptor) EnviFlow(org.openlca.core.matrix.index.EnviFlow) ProcessDescriptor(org.openlca.core.model.descriptors.ProcessDescriptor) Location(org.openlca.core.model.Location)

Example 3 with ImpactDescriptor

use of org.openlca.core.model.descriptors.ImpactDescriptor in project olca-modules by GreenDelta.

the class Utils method contributionImpact.

RpcResponse contributionImpact(RpcRequest req, ContributionImpact handler) {
    if (req == null || req.params == null || !req.params.isJsonObject())
        return Responses.invalidParams("No parameter given", req);
    JsonObject json = req.params.getAsJsonObject();
    ContributionResult result = getResult(json);
    ImpactDescriptor impact = get(result.impactIndex(), json);
    if (impact == null)
        return Responses.invalidParams("Missing or invalid impact category parameter", req);
    EntityCache cache = EntityCache.create(ctx.db);
    return Responses.ok(handler.handle(result, impact, cache), req);
}
Also used : EntityCache(org.openlca.core.database.EntityCache) JsonObject(com.google.gson.JsonObject) ImpactDescriptor(org.openlca.core.model.descriptors.ImpactDescriptor) ContributionResult(org.openlca.core.results.ContributionResult)

Example 4 with ImpactDescriptor

use of org.openlca.core.model.descriptors.ImpactDescriptor in project olca-modules by GreenDelta.

the class SystemExport method createImpactCategoryHeader.

private ExcelHeader createImpactCategoryHeader(ImpactIndex impactIndex) {
    ExcelHeader header = new ExcelHeader();
    header.setHeaders(HEADERS.IMPACT_CATEGORY.VALUES);
    List<IExcelHeaderEntry> headerEntries = new ArrayList<>();
    List<ImpactDescriptor> sortedCategories = mapImpactCategoryIndices(header, impactIndex);
    for (ImpactDescriptor category : sortedCategories) {
        headerEntries.add(new ImpactCategoryHeaderEntry(conf.impactMethod.name, category));
    }
    header.setEntries(headerEntries.toArray(new IExcelHeaderEntry[headerEntries.size()]));
    return header;
}
Also used : ArrayList(java.util.ArrayList) ImpactDescriptor(org.openlca.core.model.descriptors.ImpactDescriptor)

Example 5 with ImpactDescriptor

use of org.openlca.core.model.descriptors.ImpactDescriptor in project olca-app by GreenDelta.

the class ResultMap method addMetaData.

private void addMetaData(Location loc, Feature f, Object selection) {
    f.properties.put("location_code", loc.code);
    f.properties.put("location", loc.name);
    f.properties.put("location_id", loc.refId);
    if (selection instanceof FlowDescriptor) {
        FlowDescriptor flow = (FlowDescriptor) selection;
        f.properties.put("flow_id", flow.refId);
        f.properties.put("flow", Labels.name(flow));
        f.properties.put("flow_category", Labels.category(flow));
        f.properties.put("unit", Labels.refUnit(flow));
        return;
    }
    if (selection instanceof ImpactDescriptor) {
        var imp = (ImpactDescriptor) selection;
        f.properties.put("impact_id", imp.refId);
        f.properties.put("impact_name", imp.name);
        f.properties.put("unit", imp.referenceUnit);
        return;
    }
    if (selection instanceof CostResultDescriptor) {
        CostResultDescriptor c = (CostResultDescriptor) selection;
        f.properties.put("cost_type", c.forAddedValue ? "added value" : "net costs");
        f.properties.put("unit", Labels.getReferenceCurrencyCode());
    }
}
Also used : FlowDescriptor(org.openlca.core.model.descriptors.FlowDescriptor) ImpactDescriptor(org.openlca.core.model.descriptors.ImpactDescriptor) CostResultDescriptor(org.openlca.app.util.CostResultDescriptor)

Aggregations

ImpactDescriptor (org.openlca.core.model.descriptors.ImpactDescriptor)25 ContributionResult (org.openlca.core.results.ContributionResult)7 ArrayList (java.util.ArrayList)6 EnviFlow (org.openlca.core.matrix.index.EnviFlow)6 JsonObject (com.google.gson.JsonObject)5 FlowDescriptor (org.openlca.core.model.descriptors.FlowDescriptor)5 ProcessDescriptor (org.openlca.core.model.descriptors.ProcessDescriptor)5 List (java.util.List)4 CostResultDescriptor (org.openlca.app.util.CostResultDescriptor)4 EntityCache (org.openlca.core.database.EntityCache)4 Contribution (org.openlca.core.results.Contribution)4 File (java.io.File)3 Collectors (java.util.stream.Collectors)3 ITreeContentProvider (org.eclipse.jface.viewers.ITreeContentProvider)3 Button (org.eclipse.swt.widgets.Button)3 LocationDescriptor (org.openlca.core.model.descriptors.LocationDescriptor)3 Collections (java.util.Collections)2 Sheet (org.apache.poi.ss.usermodel.Sheet)2 Action (org.eclipse.jface.action.Action)2 ArrayContentProvider (org.eclipse.jface.viewers.ArrayContentProvider)2