Skip to content

Commit

Permalink
s0 can now be set manually for extrapolation to zero
Browse files Browse the repository at this point in the history
  • Loading branch information
CPrescher committed Jul 14, 2024
1 parent a0142d5 commit 833c2e4
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 1 deletion.
6 changes: 5 additions & 1 deletion glassure/calc.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,11 @@ def process_input(input: Input) -> Pattern:
sq = calculate_sq(norm, f_squared_mean, f_mean_squared)

# extrapolation
s0 = calculate_s0(composition)
if config.transform.extrapolation.s0 is not None:
s0 = config.transform.extrapolation.s0
else:
s0 = calculate_s0(composition)

extrapolation = transform.extrapolation
match extrapolation.method:
case ExtrapolationMethod.STEP:
Expand Down
1 change: 1 addition & 0 deletions glassure/configuration.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ class OptimizeConfig:
@dataclass
class ExtrapolationConfig:
method: ExtrapolationMethod = ExtrapolationMethod.STEP
s0: Optional[float] = field(default=None)
overlap: float = 0.2
replace: bool = False

Expand Down
10 changes: 10 additions & 0 deletions tests/test_calc.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,16 @@ def test_process_input_poly_extrapolation():

assert not np.array_equal(res.sq.y, res_poly.sq.y)

def test_process_extrapolation_with_s0():
input = prepare_input()
res = process_input(input)

input.config.transform.extrapolation.method = "linear"
input.config.transform.extrapolation.s0 = 0.1
res_s0 = process_input(input)

assert not np.array_equal(res.sq.y, res_s0.sq.y)


def test_process_input_kn_correction():
input = prepare_input()
Expand Down

0 comments on commit 833c2e4

Please sign in to comment.