Skip to content

Commit

Permalink
Fix indentation (#221)
Browse files Browse the repository at this point in the history
Fixed the indentation, using `reindent` (https://pypi.org/project/reindent/). 

From the documentation:
> Change Python (.py) files to use 4-space indents and no hard tab characters. Also trim excess spaces and tabs from ends of lines, and remove empty lines at the end of files. Also ensure the last line ends with a newline.
  • Loading branch information
gmloose authored Apr 16, 2024
1 parent 94ad55a commit 942a3ed
Show file tree
Hide file tree
Showing 32 changed files with 2,666 additions and 2,682 deletions.
266 changes: 133 additions & 133 deletions bdsf/_version.py

Large diffs are not rendered by default.

11 changes: 4 additions & 7 deletions bdsf/cleanup.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,12 @@ def __call__(self, img):
pl.title('All gaussians including wavelet images')
allgaus = img.gaussians
if hasattr(img, 'atrous_gaussians'):
for gg in img.atrous_gaussians:
allgaus += gg
for gg in img.atrous_gaussians:
allgaus += gg

for g in allgaus:
ellx, elly = func.drawellipse(g)
pl.plot(ellx, elly, 'r')
ellx, elly = func.drawellipse(g)
pl.plot(ellx, elly, 'r')

from math import log10
bdir = img.basedir + '/misc/'
Expand All @@ -50,6 +50,3 @@ def __call__(self, img):
pl.close()

img.completed_Ops.append('cleanup')



438 changes: 219 additions & 219 deletions bdsf/collapse.py

Large diffs are not rendered by default.

1 change: 0 additions & 1 deletion bdsf/const.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,3 @@
c=2.99792458e8
bolt=1.3806505e-23
sq2=math.sqrt(2)

530 changes: 265 additions & 265 deletions bdsf/functions.py

Large diffs are not rendered by default.

144 changes: 72 additions & 72 deletions bdsf/gaul2srl.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,14 +54,14 @@ def __call__(self, img):
g_list.append(g)

if len(g_list) > 0:
if len(g_list) == 1:
src_index, source = self.process_single_gaussian(img, g_list, src_index, code = 'S')
sources.append(source)
isl_sources.append(source)
else:
src_index, source = self.process_CM(img, g_list, isl, src_index)
sources.extend(source)
isl_sources.extend(source)
if len(g_list) == 1:
src_index, source = self.process_single_gaussian(img, g_list, src_index, code = 'S')
sources.append(source)
isl_sources.append(source)
else:
src_index, source = self.process_CM(img, g_list, isl, src_index)
sources.extend(source)
isl_sources.extend(source)
else:
if not img.waveletimage:
dg = isl.dgaul[0]
Expand Down Expand Up @@ -179,36 +179,36 @@ def process_CM(self, img, g_list, isl, src_index):
for pair in index:
same_island = self.in_same_island(pair, img, g_list, isl, subim, subn, subm, delc)
if same_island:
nsrc -= 1
mmax, mmin = max(src_id[pair[0]],src_id[pair[1]]), min(src_id[pair[0]],src_id[pair[1]])
arr = N.where(src_id == mmax)[0]; src_id[arr] = mmin
# now reorder src_id so that it is contiguous
nsrc -= 1
mmax, mmin = max(src_id[pair[0]],src_id[pair[1]]), min(src_id[pair[0]],src_id[pair[1]])
arr = N.where(src_id == mmax)[0]; src_id[arr] = mmin
# now reorder src_id so that it is contiguous
for i in range(ngau):
ind1 = N.where(src_id==i)[0]
if len(ind1) == 0:
arr = N.where(src_id > i)[0]
if len(arr) > 0:
decr = N.min(src_id[arr])-i
for j in arr: src_id[j] -= decr
decr = N.min(src_id[arr])-i
for j in arr: src_id[j] -= decr
nsrc = N.max(src_id)+1
# now do whats in sub_calc_para_source

source_list = []
for isrc in range(nsrc):
posn = N.where(src_id == isrc)[0]
g_sublist=[]
for i in posn:
g_sublist.append(g_list[i])
ngau_insrc = len(posn)
# Do source type C
if ngau_insrc == 1:
src_index, source = self.process_single_gaussian(img, g_sublist, src_index, code = 'C')
else:
# make mask and subim. Invalid mask value is -1 since 0 is valid srcid
mask = self.make_mask(isl, subn, subm, 1, isrc, g_sublist, delc)
src_index, source = self.process_Multiple(img, g_sublist, mask, src_index, isrc, subim, \
isl, delc, subn, subm)
source_list.append(source)
posn = N.where(src_id == isrc)[0]
g_sublist=[]
for i in posn:
g_sublist.append(g_list[i])
ngau_insrc = len(posn)
# Do source type C
if ngau_insrc == 1:
src_index, source = self.process_single_gaussian(img, g_sublist, src_index, code = 'C')
else:
# make mask and subim. Invalid mask value is -1 since 0 is valid srcid
mask = self.make_mask(isl, subn, subm, 1, isrc, g_sublist, delc)
src_index, source = self.process_Multiple(img, g_sublist, mask, src_index, isrc, subim, \
isl, delc, subn, subm)
source_list.append(source)

return src_index, source_list

Expand Down Expand Up @@ -243,35 +243,35 @@ def same_island_min(pair, g_list, subim, delc, tol=0.5):
same_island_min = False
same_island_cont = False
if maxline == 1:
same_island_min = True
same_island_cont = True
else:
if abs(pixdif[0]) > abs(pixdif[1]):
xline = N.round(min(pix1[0],pix2[0])+N.arange(maxline))
yline = N.round((pix1[1]-pix2[1])/(pix1[0]-pix2[0])* \
(min(pix1[0],pix2[0])+N.arange(maxline)-pix1[0])+pix1[1])
else:
yline = N.round(min(pix1[1],pix2[1])+N.arange(maxline))
xline = N.round((pix1[0]-pix2[0])/(pix1[1]-pix2[1])* \
(min(pix1[1],pix2[1])+N.arange(maxline)-pix1[1])+pix1[0])
rpixval = N.zeros(maxline, dtype=N.float32)
xbig = N.where(xline >= N.size(subim,0))
xline[xbig] = N.size(subim,0) - 1
ybig = N.where(yline >= N.size(subim,1))
yline[ybig] = N.size(subim,1) - 1
for i in range(maxline):
pixval = subim[int(xline[i]), int(yline[i])]
rpixval[i] = pixval
min_pixval = N.min(rpixval)
minind_p = N.argmin(rpixval)
maxind_p = N.argmax(rpixval)

if minind_p in (0, maxline-1) and maxind_p in (0, maxline-1):
same_island_cont = True
if min_pixval >= min(flux1, flux2):
same_island_min = True
elif abs(min_pixval-min(flux1,flux2)) <= tol*isl.rms*img.opts.thresh_isl:
same_island_min = True
same_island_cont = True
else:
if abs(pixdif[0]) > abs(pixdif[1]):
xline = N.round(min(pix1[0],pix2[0])+N.arange(maxline))
yline = N.round((pix1[1]-pix2[1])/(pix1[0]-pix2[0])* \
(min(pix1[0],pix2[0])+N.arange(maxline)-pix1[0])+pix1[1])
else:
yline = N.round(min(pix1[1],pix2[1])+N.arange(maxline))
xline = N.round((pix1[0]-pix2[0])/(pix1[1]-pix2[1])* \
(min(pix1[1],pix2[1])+N.arange(maxline)-pix1[1])+pix1[0])
rpixval = N.zeros(maxline, dtype=N.float32)
xbig = N.where(xline >= N.size(subim,0))
xline[xbig] = N.size(subim,0) - 1
ybig = N.where(yline >= N.size(subim,1))
yline[ybig] = N.size(subim,1) - 1
for i in range(maxline):
pixval = subim[int(xline[i]), int(yline[i])]
rpixval[i] = pixval
min_pixval = N.min(rpixval)
minind_p = N.argmin(rpixval)
maxind_p = N.argmax(rpixval)

if minind_p in (0, maxline-1) and maxind_p in (0, maxline-1):
same_island_cont = True
if min_pixval >= min(flux1, flux2):
same_island_min = True
elif abs(min_pixval-min(flux1,flux2)) <= tol*isl.rms*img.opts.thresh_isl:
same_island_min = True

return same_island_min, same_island_cont

Expand All @@ -293,9 +293,9 @@ def same_island_dist(pair, g_list, tol=0.5):
dist = sqrt(dy*dy + dx*dx)

if dist <= tol*(fwhm1+fwhm2):
same_island = True
same_island = True
else:
same_island = False
same_island = False

return same_island

Expand Down Expand Up @@ -353,16 +353,16 @@ def process_Multiple(self, img, g_sublist, mask, src_index, isrc, subim, isl, de
x_ax, y_ax = N.indices(data.shape)

if N.sum(~rmask) >=6:
para, ierr = func.fit_gaus2d(data, p_ini, x_ax, y_ax, rmask)
if (0.0<para[1]<s_imsize[0]) and (0.0<para[2]<s_imsize[1]) and \
para[3]<s_imsize[0] and para[4]<s_imsize[1]:
maxpeak = para[0]
else:
maxpeak = maxv
posn = para[1:3]-(0.5*N.sum(s_imsize)-1)/2.0+N.array([maxx, maxy])-1+delc
para, ierr = func.fit_gaus2d(data, p_ini, x_ax, y_ax, rmask)
if (0.0<para[1]<s_imsize[0]) and (0.0<para[2]<s_imsize[1]) and \
para[3]<s_imsize[0] and para[4]<s_imsize[1]:
maxpeak = para[0]
else:
maxpeak = maxv
posn = para[1:3]-(0.5*N.sum(s_imsize)-1)/2.0+N.array([maxx, maxy])-1+delc
else:
maxpeak = maxv
posn = N.unravel_index(N.argmax(data*~rmask), data.shape)+N.array(delc) +blc
maxpeak = maxv
posn = N.unravel_index(N.argmax(data*~rmask), data.shape)+N.array(delc) +blc

# calculate peak by bilinear interpolation around centroid
# First check that moment analysis gave a valid position. If not, use
Expand Down Expand Up @@ -479,11 +479,11 @@ def process_Multiple(self, img, g_sublist, mask, src_index, isrc, subim, isl, de
if mompara5E > 2.0*mompara[5]:
mompara5E = 2.0*mompara[5] # Don't let errors get too large
else:
mompara1E = 0.0
mompara2E = 0.0
mompara3E = 0.0
mompara4E = 0.0
mompara5E = 0.0
mompara1E = 0.0
mompara2E = 0.0
mompara3E = 0.0
mompara4E = 0.0
mompara5E = 0.0

# Now add MC errors in quadrature with Condon (1997) errors
size_skyE = [sqrt(mompara3E**2 + errors[3]**2) * sqrt(cdeltsq),
Expand Down
Loading

0 comments on commit 942a3ed

Please sign in to comment.