started to separate algorithms out of main file

This commit is contained in:
2024-03-25 10:23:43 +01:00
parent 94b1202256
commit 36612ec82e
3 changed files with 29 additions and 19 deletions

4
dap/algos/__init__.py Normal file
View File

@ -0,0 +1,4 @@
from .radprof import prepare_radial_profile, radial_profile

23
dap/algos/radprof.py Normal file
View File

@ -0,0 +1,23 @@
import numpy as np
def radial_profile(data, r, nr, keep_pixels=None):
if keep_pixels is not None:
tbin = np.bincount(r, data[keep_pixels].ravel())
else:
tbin = np.bincount(r, data.ravel())
radialprofile = tbin / nr
return radialprofile
def prepare_radial_profile(data, center, keep_pixels=None):
y, x = np.indices((data.shape))
r = np.sqrt((x - center[0])**2 + (y - center[1])**2)
if keep_pixels is not None:
r = r[keep_pixels].astype(int).ravel()
else:
r = r.astype(np.int).ravel()
nr = np.bincount(r)
return r, nr

View File

@ -10,29 +10,12 @@ import numpy as np
import zmq import zmq
from peakfinder8_extension import peakfinder_8 from peakfinder8_extension import peakfinder_8
from .algos import prepare_radial_profile, radial_profile
FLAGS = 0 FLAGS = 0
def radial_profile(data, r, nr, keep_pixels=None):
if keep_pixels is not None:
tbin = np.bincount(r, data[keep_pixels].ravel())
else:
tbin = np.bincount(r, data.ravel())
radialprofile = tbin / nr
return radialprofile
def prepare_radial_profile(data, center, keep_pixels=None):
y, x = np.indices((data.shape))
r = np.sqrt((x - center[0])**2 + (y - center[1])**2)
if keep_pixels is not None:
r = r[keep_pixels].astype(int).ravel()
else:
r = r.astype(np.int).ravel()
nr = np.bincount(r)
return r, nr
def main(): def main():
parser = argparse.ArgumentParser() parser = argparse.ArgumentParser()