Skip to content

Commit

Permalink
Scale area penalty with number of datasets
Browse files Browse the repository at this point in the history
This fix reproduces the area penalty behavior that was in v0.4.1 with multiple datasets with the same spectral axis.

For multiple datasets with different axes a more elaborate solution is required, see #800 for discussion.
  • Loading branch information
jsnel committed Aug 29, 2021
1 parent 9dc64af commit 52d1aaa
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
9 changes: 7 additions & 2 deletions glotaran/analysis/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,9 @@ def calculate_clp_penalties(
global_axis: np.ndarray,
) -> np.ndarray:

# TODO: make a decision on how to handle clp_penalties per dataset
# temporary workaround to better match v0.4.1 output
debug_scale = len(model.dataset)
penalties = []
for penalty in model.clp_area_penalties:
penalty = penalty.fill(model, parameters)
Expand All @@ -214,8 +217,10 @@ def calculate_clp_penalties(
penalty.target_intervals,
global_axis,
)

area_penalty = np.abs(np.sum(source_area) - penalty.parameter * np.sum(target_area))
area_penalty = np.abs(
debug_scale * np.sum(source_area)
- penalty.parameter * debug_scale * np.sum(target_area)
)

penalties.append(area_penalty * penalty.weight)

Expand Down
1 change: 1 addition & 0 deletions glotaran/model/clp_penalties.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ def apply_spectral_penalties(
group_tolerance: float,
) -> np.ndarray:

# TODO: seems to duplicate calculate_clp_penalties
penalties = []
for penalty in model.clp_area_penalties:

Expand Down

0 comments on commit 52d1aaa

Please sign in to comment.