From 36f9cff04ad6dde5fdefdf3feead3984a21e3fc4 Mon Sep 17 00:00:00 2001 From: Lachlan Grose Date: Fri, 3 Dec 2021 15:17:00 +1100 Subject: [PATCH] fix: gradient norm used for folds when fold normalisation is 0 --- LoopStructural/modelling/fold/fold_builder.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/LoopStructural/modelling/fold/fold_builder.py b/LoopStructural/modelling/fold/fold_builder.py index e2d3ee990..c69a6ac0f 100644 --- a/LoopStructural/modelling/fold/fold_builder.py +++ b/LoopStructural/modelling/fold/fold_builder.py @@ -76,7 +76,7 @@ def set_fold_limb_rotation(self): fold_limb_rotation.fit_fourier_series(wl=l_wl, **kwargs) self.fold.fold_limb_rotation = fold_limb_rotation - def build(self, data_region=None, constrained=True, **kwargs): + def build(self, data_region=None, constrained=None, **kwargs): """[summary] Parameters @@ -88,6 +88,14 @@ def build(self, data_region=None, constrained=True, **kwargs): # gradient not norm, to prevent issues with fold norm constraint # TODO folding norm constraint should be minimising the difference in norm # not setting the norm + + # Use norm constraints if the fold normalisation weight is 0. + if constrained is None: + if "fold_normalisation" in kwargs: + if kwargs["fold_normalisation"] == 0.0: + constrained = False + else: + constrained = True self.add_data_to_interpolator(constrained=constrained) if self.fold.foldframe[0].is_valid() == False: raise InterpolatorError("Fold frame main coordinate is not valid")