Skip to content
Snippets Groups Projects
Commit 6f7a769e authored by Cristian Lalescu's avatar Cristian Lalescu
Browse files

update mode counter

parent 18ac43d7
No related branches found
No related tags found
1 merge request!23WIP: Feature/use cmake
Pipeline #
import numpy as np
def count_expensive(fk0, fk1):
kcomponent = np.arange(-fk1-1, fk1+2, 1).astype(np.float)
kcomponent = np.arange(-np.floor(fk1)-1, np.floor(fk1)+2, 1).astype(np.float)
ksize = (kcomponent[:, None, None]**2 +
kcomponent[None, :, None]**2 +
kcomponent[None, None, :]**2)**.5
#print(ksize[0])
good_indices = np.where(np.logical_and(
ksize >= fk0,
ksize <= fk1))
#print(ksize[good_indices])
#print(good_indices[0].shape)
return good_indices[0].shape[0]
return np.unique(ksize[good_indices].flatten(), return_counts = True)
def main():
for ff in [[2, 4],
[1.5, 3],
[1, 2],
[1.5, 2.5],
[1.5, 2.3]]:
print(1 / ff[1], ff, count_expensive(ff[0], ff[1]))
for ff in [[1, 2],
[1.4, 2.3],
[1.4, 2.2]]:
modes, counts = count_expensive(ff[0], ff[1])
nmodes = np.sum(counts)
print(1 / ff[1], ff, nmodes)
modes_str = ''
counts_str = ''
for ii in range(counts.shape[0]):
modes_str += '{0:>5g}\t'.format(modes[ii])
counts_str += '{0:>5g}\t'.format(counts[ii])
print(modes_str + '\n' + counts_str + '\n')
return None
if __name__ == '__main__':
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment