Skip to content

Instantly share code, notes, and snippets.

@nikitinvv
Created May 18, 2023 16:05
Show Gist options
  • Save nikitinvv/525b6c0f9dc12cbb072d843d1fdd7723 to your computer and use it in GitHub Desktop.
Save nikitinvv/525b6c0f9dc12cbb072d843d1fdd7723 to your computer and use it in GitHub Desktop.
import numpy
def gen_interlaced_theta_W():
numproj = 1440#1800-360
prime = 2
nProj_per_rot = 360
pst = 0
pend = 360
seq = []
i = 0
sgn = 1 # for switching direction
while len(seq) < numproj:
b = i
i += 1
r = 0
q = 1 / prime
while (b != 0):
a = numpy.mod(b, prime)
r += (a * q)
q /= prime
b = numpy.floor(b / prime)
r *= ((pend-pst) / nProj_per_rot)
k = 0
while (numpy.logical_and(len(seq) < numproj, k < nProj_per_rot)):
if(sgn==1):
seq.append(pst+ (r + k * (pend-pst) /
nProj_per_rot)+360*(i-1))
else:
seq.append(pend-((1-r) + k * (pend-pst) / nProj_per_rot))
k += 1
#sgn*=-1# to fix later
# Print interlaced values:
# print(seq)
seq = numpy.array(seq)
a = numpy.sort(seq%360)
print("min distance between neighbours:", numpy.min(seq[1::2]-seq[::2]))
print("max distance between neighbours:", numpy.max(seq[1::2]-seq[::2]))
print("min distance between sorted neighbours:", numpy.min(a[1::2]-a[::2]))
print("max distance between sorted neighbours:", numpy.max(a[1::2]-a[::2]))
print('number of unique elements:', len(numpy.unique(seq)))
print('max element:',max((seq)))
print('min element:',min((seq)))
return seq
seq = gen_interlaced_theta_W()
print(seq[:10])
print(seq[360:360+10])
#seq = numpy.array([1,2,10])
numpy.save('/home/beams/USERTXM/angles/theta_interlaced.npy',seq)
#print(seq[2*360:3*360])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment