started to separate algorithms out of main file
This commit is contained in:
4
dap/algos/__init__.py
Normal file
4
dap/algos/__init__.py
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
|
||||||
|
from .radprof import prepare_radial_profile, radial_profile
|
||||||
|
|
||||||
|
|
23
dap/algos/radprof.py
Normal file
23
dap/algos/radprof.py
Normal 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
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -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()
|
||||||
|
Reference in New Issue
Block a user