Skip to content

Commit

Permalink
gtol, ltol with nanmax instead of amax (#92)
Browse files Browse the repository at this point in the history
* gtol, ltol with nanmax instead of amax

include test

* Apply nanmax fix to tunetest as well
  • Loading branch information
ksunden committed Aug 19, 2020
1 parent 648a620 commit 523baa4
Show file tree
Hide file tree
Showing 4 changed files with 98 additions and 2 deletions.
2 changes: 1 addition & 1 deletion attune/workup/_intensity.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ def intensity(
cutoff = channel.max() * gtol
channel.clip(min=cutoff)
max_axis = tuple(i for i, v in enumerate(data.axes[0].shape) if v > 1)
cutoff = np.amax(channel[:], axis=1, keepdims=True) * ltol
cutoff = np.nanmax(channel[:], axis=1, keepdims=True) * ltol
channel.clip(min=cutoff)

offsets = _intensity(data, channel.natural_name, setpoints[:], **spline_kwargs)
Expand Down
2 changes: 1 addition & 1 deletion attune/workup/_tune_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ def tune_test(
cutoff = channel.max() * gtol
channel.clip(min=cutoff)
max_axis = tuple(i for i, v in enumerate(data.axes[0].shape) if v > 1)
cutoff = np.amax(channel[:], axis=1, keepdims=True) * ltol
cutoff = np.nanmax(channel[:], axis=1, keepdims=True) * ltol
channel.clip(min=cutoff)

offsets = _offsets(data, channel.natural_name, setpoints[:], **spline_kwargs)
Expand Down
76 changes: 76 additions & 0 deletions tests/workup/intensity/2018-11-30/gtol_ltol.crv
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
600
OPA/NOPA
0
0
-1
0.0
0.0
4
0 1 2 3
2
NON-NON-NON-Sig
1

1
795.0
4
0.0 0.0 0.0 0.0
25
795.000000 1140.000000 4 -9.324437 2.165817 7.259192 56.900087
795.000000 1160.000000 4 -9.157580 2.187564 7.042477 56.883967
795.000000 1180.000000 4 -8.984826 2.208495 6.840474 56.919895
795.000000 1200.000000 4 -8.804315 2.228614 6.647392 57.041473
795.000000 1220.000000 4 -8.611249 2.247860 6.451987 57.083312
795.000000 1240.000000 4 -8.410807 2.266293 6.250346 57.181522
795.000000 1260.000000 4 -8.202496 2.283914 6.038194 57.259414
795.000000 1280.000000 4 -7.985876 2.300720 5.812338 57.319464
795.000000 1300.000000 4 -7.760571 2.316705 5.572450 57.375488
795.000000 1320.000000 4 -7.524883 2.331832 5.319858 57.474636
795.000000 1340.000000 4 -7.279892 2.346119 5.060538 57.408916
795.000000 1360.000000 4 -7.026407 2.359587 4.798632 57.403402
795.000000 1380.000000 4 -6.764418 2.372236 4.534670 57.572553
795.000000 1400.000000 4 -6.493978 2.384069 4.266426 57.565086
795.000000 1420.000000 4 -6.214258 2.395065 3.989824 57.691839
795.000000 1440.000000 4 -5.923851 2.405174 3.698642 57.657403
795.000000 1460.000000 4 -5.624523 2.414448 3.391164 57.696640
795.000000 1480.000000 4 -5.316681 2.422904 3.070804 57.737480
795.000000 1500.000000 4 -5.000809 2.430560 2.746774 57.708782
795.000000 1520.000000 4 -4.677497 2.437441 2.427717 57.660695
795.000000 1540.000000 4 -4.347266 2.443573 2.120012 57.671627
795.000000 1560.000000 4 -4.002260 2.448650 1.833213 57.299295
795.000000 1580.000000 4 -3.648984 2.452917 1.566733 57.387499
795.000000 1600.000000 4 -3.289828 2.456477 1.316282 57.889024
795.000000 1620.000000 4 -2.926032 2.459392 1.079490 58.774434
NON-NON-NON-Idl
1

0
795.0
4
0.0 0.0 0.0 0.0
25
795.000000 1561.090909 4 -2.926032 2.459392 1.079490 58.774434
795.000000 1580.124224 4 -3.289828 2.456477 1.316282 57.889024
795.000000 1600.127389 4 -3.648984 2.452917 1.566733 57.387499
795.000000 1621.176471 4 -4.002260 2.448650 1.833213 57.299295
795.000000 1643.355705 4 -4.347266 2.443573 2.120012 57.671627
795.000000 1666.758621 4 -4.677497 2.437441 2.427717 57.660695
795.000000 1691.489362 4 -5.000809 2.430560 2.746774 57.708782
795.000000 1717.664234 4 -5.316681 2.422904 3.070804 57.737480
795.000000 1745.413534 4 -5.624523 2.414448 3.391164 57.696640
795.000000 1774.883721 4 -5.923851 2.405174 3.698642 57.657403
795.000000 1806.240000 4 -6.214258 2.395065 3.989824 57.691839
795.000000 1839.669421 4 -6.493978 2.384069 4.266426 57.565086
795.000000 1875.384615 4 -6.764418 2.372236 4.534670 57.572553
795.000000 1913.628319 4 -7.026407 2.359587 4.798632 57.403402
795.000000 1954.678899 4 -7.279892 2.346119 5.060538 57.408916
795.000000 1998.857143 4 -7.524883 2.331832 5.319858 57.474636
795.000000 2046.534653 4 -7.760571 2.316705 5.572450 57.375488
795.000000 2098.144330 4 -7.985876 2.300720 5.812338 57.319464
795.000000 2154.193548 4 -8.202496 2.283914 6.038194 57.259414
795.000000 2215.280899 4 -8.410807 2.266293 6.250346 57.181522
795.000000 2282.117647 4 -8.611249 2.247860 6.451987 57.083312
795.000000 2355.555556 4 -8.804315 2.228614 6.647392 57.041473
795.000000 2436.623377 4 -8.984826 2.208495 6.840474 56.919895
795.000000 2526.575342 4 -9.157580 2.187564 7.042477 56.883967
795.000000 2626.956522 4 -9.324437 2.165817 7.259192 56.900087
20 changes: 20 additions & 0 deletions tests/workup/intensity/2018-11-30/qgnsm.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import attune
import pathlib
import pytest

import numpy as np
import WrightTools as wt


Expand All @@ -18,5 +20,23 @@ def test():
print(new)


def test_ltol_with_gtol():
data = wt.open(__here__ / "data.wt5")
data.print_tree()
data.transform("w1=wm", "w1_Delay_2", "wa_points")
data.moment("wa_points", moment=0)
data.transform("w1=wm", "w1_Delay_2_points")
old = attune.TopasCurve.read([__here__ / "old.crv"], interaction_string="NON-NON-NON-Sig")
new = attune.workup.intensity(
data, -1, "3", gtol=0.1, ltol=0.99999, spline=False, autosave=False, curve=old
)
correct = attune.TopasCurve.read(
[__here__ / "gtol_ltol.crv"], interaction_string="NON-NON-NON-Sig"
)
correct.convert("wn")
assert np.allclose(new["3"][::-1], correct["3"][:])


if __name__ == "__main__":
test()
test_ltol_with_gtol()

0 comments on commit 523baa4

Please sign in to comment.