Skip to content
Snippets Groups Projects

Base knife-edge scan analysis implementation

Merged Cammille Carinan requested to merge knife-edge-base into master
1 unresolved thread
2 files
+ 61
99
Compare changes
  • Side-by-side
  • Inline
Files
2
@@ -107,13 +107,7 @@ def prepare_arrays(arrX: np.ndarray, arrY: np.ndarray,
3. Retrieve finite values.
"""
# Convert both arrays to 1D of the same size
assert arrX.shape[0] == arrY.shape[0]
arrX = arrX.flatten()
arrY = arrY.flatten()
if len(arrX) > len(arrY):
arrY = np.repeat(arrY, len(arrX) // len(arrY))
else:
arrX = np.repeat(arrX, len(arrY) // len(arrX))
arrX, arrY = arrays_to1d(arrX, arrY)
# Select ranges
if xRange is not None:
@@ -133,6 +127,18 @@ def prepare_arrays(arrX: np.ndarray, arrY: np.ndarray,
return arrX, arrY
def arrays_to1d(arrX: np.ndarray, arrY: np.ndarray):
"""Flatten two arrays and matches their sizes
"""
assert arrX.shape[0] == arrY.shape[0]
arrX, arrY = arrX.flatten(), arrY.flatten()
if len(arrX) > len(arrY):
arrY = np.repeat(arrY, len(arrX) // len(arrY))
else:
arrX = np.repeat(arrX, len(arrY) // len(arrX))
return arrX, arrY
def range_mask(array, minimum=None, maximum=None):
"""Retrieve the resulting array from the given minimum and maximum
"""
Loading