Skip to content

Commit 9a91d80

Browse files
committed
Exposed use_smoother flag.
1 parent 03ae620 commit 9a91d80

File tree

10 files changed

+14
-4
lines changed

10 files changed

+14
-4
lines changed

libcbm/model/cbm/cbm_config.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -298,7 +298,7 @@ def merch_volume_curve(
298298

299299

300300
def merch_volume_to_biomass_config(
301-
db_path: str, merch_volume_curves: list
301+
db_path: str, merch_volume_curves: list, use_smoother: bool = True
302302
) -> dict:
303303
"""Formats merchantable volume growth curve data for libcbm CBM model
304304
consumption.
@@ -307,6 +307,8 @@ def merch_volume_to_biomass_config(
307307
db_path (str): path to a cbm_defaults database
308308
merch_volume_curves (list): a list of dictionaries in the same format
309309
as the return value of :py:func:`merch_volume_curve`
310+
use_smoother (bool, optional): use the volume to biomass smoother (on
311+
by default)
310312
311313
Returns:
312314
dict: A dictionary containing configuration for merchantable volume
@@ -315,7 +317,8 @@ def merch_volume_to_biomass_config(
315317
For example::
316318
317319
{
318-
"db_path": "cbm_defaults.db"
320+
"db_path": "cbm_defaults.db",
321+
"use_smoother": True,
319322
"merch_volume_curves": [
320323
{
321324
"classifier_set": {
@@ -364,4 +367,5 @@ def merch_volume_to_biomass_config(
364367
]
365368
}
366369
"""
367-
return {"db_path": db_path, "merch_volume_curves": merch_volume_curves}
370+
return {"db_path": db_path, "merch_volume_curves": merch_volume_curves,
371+
"use_smoother": use_smoother,}

libcbm/model/cbm/stand_cbm_factory.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ def __init__(
5353
db_path: str = None,
5454
locale: str = "en-CA",
5555
dll_path: str = None,
56+
use_smoother = True,
5657
):
5758
"""Initialize an instance of CBMStandFactory using classifiers and
5859
merch volumes.
@@ -95,6 +96,8 @@ def __init__(
9596
corresponding translated version of default parameter strings
9697
dll_path (str, optional): path to the libcbm compiled library, if
9798
not specified a default value is used.
99+
use_smoother (bool, optional): use the volume to biomass smoother.
100+
If not specified, it is used.
98101
"""
99102
if not db_path:
100103
self._db_path = resources.get_cbm_defaults_path()
@@ -124,6 +127,7 @@ def __init__(
124127
self._classifier_idx = cbm_config.get_classifier_indexes(
125128
self._classifier_config
126129
)
130+
self._use_smoother = use_smoother
127131
self.merch_vol_factory = self.merch_volumes_factory()
128132

129133
self._disturbance_type_map = {
@@ -175,7 +179,8 @@ def merch_volumes_factory(self) -> dict:
175179
)
176180
)
177181
return cbm_config.merch_volume_to_biomass_config(
178-
db_path=self._db_path, merch_volume_curves=merch_volume_list
182+
db_path=self._db_path, merch_volume_curves=merch_volume_list,
183+
use_smoother=self._use_smoother,
179184
)
180185

181186
@property
-92.5 KB
Binary file not shown.
-31.2 KB
Binary file not shown.
10 KB
Binary file not shown.
22 Bytes
Binary file not shown.
0 Bytes
Binary file not shown.
-2 KB
Binary file not shown.
-7.59 KB
Binary file not shown.

libcbm/wrapper/cbm/cbm_wrapper.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ class CBMWrapper(LibCBM_ctypes):
3737
3838
{
3939
"cbm_defaults": {"p1": {}, "p2": {}, ..., "pN": {}},
40+
"use_smoother": true,
4041
"classifiers": [
4142
{"id": 1, "name": "a"},
4243
{"id": 2, "name": "b"},

0 commit comments

Comments
 (0)