Skip to content

Commit

Permalink
Add more log information and terminology updates.
Browse files Browse the repository at this point in the history
  • Loading branch information
gkahiu committed Dec 17, 2024
1 parent 16a10d9 commit 979f0e0
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 6 deletions.
4 changes: 2 additions & 2 deletions src/cplus_plugin/definitions/defaults.py
Original file line number Diff line number Diff line change
Expand Up @@ -266,12 +266,12 @@

MEAN_BASED_IRRECOVERABLE_CARBON_EXPRESSION_DESCRIPTION = (
"Calculates the total irrecoverable carbon (tons C) of "
"protection NCS pathways in an activity using the mean "
"protect NCS pathways in an activity using the mean "
"reference irrecoverable carbon dataset. This dataset "
"needs to be defined in the CPLUS settings for this "
"expression to be evaluated.<br><b>NOTE: A value of -1.0 "
"will be returned if an error is encountered, or 0.0 if "
"there are no protected NCS pathways in the activity or "
"there are no protect NCS pathways in the activity or "
"no overlapping pixels with the reference layer in the "
"area of interest.</b>"
)
12 changes: 9 additions & 3 deletions src/cplus_plugin/lib/carbon.py
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,8 @@ def calculate_irrecoverable_carbon_from_mean(
ic_pixel_count
)

log("Calculating the total irrecoverable carbon...")

return MEAN_REFERENCE_LAYER_AREA * ic_pixel_count * ic_mean


Expand Down Expand Up @@ -346,7 +348,7 @@ def run(self) -> float:
merge_result = None
try:
log(
f"{LOG_PREFIX} - Merging protected NCS pathways: {', '.join(protect_data_sources)}..."
f"{LOG_PREFIX} - Merging protect NCS pathways: {', '.join(protect_data_sources)}..."
)
merge_result = processing.run(
"gdal:merge",
Expand Down Expand Up @@ -381,7 +383,7 @@ def run(self) -> float:
boolean_result = None
try:
log(
f"{LOG_PREFIX} - Performing binary conversion of merged protected NCS pathways..."
f"{LOG_PREFIX} - Performing binary conversion of merged protect NCS pathways..."
)
boolean_result = processing.run(
"native:rasterlogicalor",
Expand All @@ -407,7 +409,7 @@ def run(self) -> float:
# Reproject the aggregated protect raster if required
if binary_layer.crs() != QgsCoordinateReferenceSystem("EPSG:4326"):
log(
f"{LOG_PREFIX} - Binary protected pathways layer has a different CRS from "
f"{LOG_PREFIX} - Binary protect pathways layer has a different CRS from "
f"the reference mean irrecoverable carbon dataset."
)
reproject_args = {
Expand Down Expand Up @@ -461,4 +463,8 @@ def run(self) -> float:
info=False,
)

log(
f"Finished calculating the total irrecoverable carbon of {self._activity.name} as {total_irrecoverable_carbon!s}"
)

return total_irrecoverable_carbon
2 changes: 1 addition & 1 deletion src/cplus_plugin/lib/reports/metrics.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
BASE_PLUGIN_NAME,
MEAN_BASED_IRRECOVERABLE_CARBON_EXPRESSION_DESCRIPTION,
NPV_EXPRESSION_DESCRIPTION,
PWL_IMPACT_EXPRESSION_DESCRIPTION
PWL_IMPACT_EXPRESSION_DESCRIPTION,
)
from ..carbon import IrrecoverableCarbonCalculator
from ..financials import calculate_activity_npv
Expand Down

0 comments on commit 979f0e0

Please sign in to comment.