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);
}
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);
}
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);
}
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;
}
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());
}
}
Aggregations