| 1234567891011121314151617181920212223242526272829303132333435363738 |
- import numpy as np
- def create_k_steps_PI(k_span, steps, PI_factor):
- """
- A function that returns a k_span gradient span with odd and even gradient steps
- """
- steps_PI = int(np.ceil(steps/PI_factor))
- k_steps = np.array(range(steps_PI + 1))
- if steps == 1:
- k_steps = np.array([0])
- else:
- k_steps = (k_steps*PI_factor + steps%PI_factor - np.ceil(steps/2))/ np.floor(steps/ 2)
- k_steps = [k_steps[i] for i in range(len(k_steps)) if abs(k_steps[i]) <= 1]
-
- k_steps = np.flip(k_steps, 0)
- if len(k_steps)>steps_PI:
- k_steps = np.delete(k_steps, -1)
-
- return k_steps * k_span * 0.5
- def create_k_steps(k_span, steps):
- """
- A function that returns a k_span gradient span with odd and even gradient steps
- """
- k_steps = np.array(range(steps + 1))
- if (np.mod(steps, 2) == 0):
- k_steps = (k_steps - steps / 2) / (steps / 2)
- else:
- k_steps = (k_steps - (steps + 1) / 2) / (steps / 2)
- k_steps = np.flip(k_steps, 0)
- k_steps = np.delete(k_steps, -1)
- return k_steps * k_span * 0.5
-
|