Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ WORKER_REPLICAS ?= 1
WORKER_ARL_DATA ?= /arl/data
CURRENT_DIR = $(shell pwd)
JUPYTER_PASSWORD ?= changeme
CONTAINER_EXISTS = $(shell $(DOCKER) ps -aqf ancestor=itsthenetwork/nfs-server-alpine)
SERVER_DEVICE ?= $(shell ip link | grep BROADCAST | head -1 | awk '{print $$2}' | sed 's/://')
NFS_SERVER ?= "127.0.0.1"

Expand Down Expand Up @@ -100,9 +99,8 @@ docker_push: docker_build
docker push $(DOCKER_REPO)$(DOCKER_IMAGE)

docker_nfs_arl_data:
ifneq "$(strip $(CONTAINER_EXISTS))" ""
$(DOCKER) rm -f $(CONTAINER_EXISTS)
endif
CONTAINER_EXISTS=$$($(DOCKER) ps -aqf ancestor=itsthenetwork/nfs-server-alpine) && \
if [ -n "$${CONTAINER_EXISTS}" ]; then $(DOCKER) rm -f $${CONTAINER_EXISTS}; fi
docker run -d --name nfs --privileged -p 2049:2049 \
-v $(CURRENT_DIR)/:/arl \
-e SHARED_DIRECTORY=/arl itsthenetwork/nfs-server-alpine:latest
Expand Down
6 changes: 3 additions & 3 deletions libs/calibration/solvers.py
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,7 @@ def solution_residual_scalar(gain, x, xwt):
for ant2 in range(nants):
for chan in range(nchan):
error = x[ant2, ant1, chan, 0, 0] - \
gain[ant1, chan, 0, 0] * numpy.conjugate(gain[ant2, chan, 0, 0])
gain[ant1, chan, 0, 0] * numpy.conjugate(gain[ant2, chan, 0, 0])
residual += (error * xwt[ant2, ant1, chan, 0, 0] * numpy.conjugate(error)).real
sumwt += xwt[ant2, ant1, chan, 0, 0]

Expand Down Expand Up @@ -353,7 +353,7 @@ def solution_residual_vector(gain, x, xwt):
for chan in range(nchan):
for rec in range(nrec):
error = x[ant2, ant1, chan, rec, rec] - \
gain[ant1, chan, rec, rec] * numpy.conjugate(gain[ant2, chan, rec, rec])
gain[ant1, chan, rec, rec] * numpy.conjugate(gain[ant2, chan, rec, rec])
residual += (error * xwt[ant2, ant1, chan, rec, rec] * numpy.conjugate(error)).real
sumwt += xwt[ant2, ant1, chan, rec, rec]

Expand Down Expand Up @@ -385,7 +385,7 @@ def solution_residual_matrix(gain, x, xwt):
for rec1 in range(nrec):
for rec2 in range(nrec):
error = x[ant2, ant1, chan, rec2, rec1] - \
gain[ant1, chan, rec2, rec1] * numpy.conjugate(gain[ant2, chan, rec2, rec1])
gain[ant1, chan, rec2, rec1] * numpy.conjugate(gain[ant2, chan, rec2, rec1])
residual[chan, rec2, rec1] += (error * xwt[ant2, ant1, chan, rec2, rec1] * numpy.conjugate(
error)).real
sumwt[chan, rec2, rec1] += xwt[ant2, ant1, chan, rec2, rec1]
Expand Down
2 changes: 1 addition & 1 deletion libs/fourier_transforms/convolutional_gridding.py
Original file line number Diff line number Diff line change
Expand Up @@ -358,7 +358,7 @@ def visibility_recentre(uvw, dl, dm):
:returns: Visibility coordinates re-centrered on the peak of their w-kernel
"""

u, v, w = numpy.hsplit(uvw, 3)
u, v, w = numpy.hsplit(uvw, 3) # pylint: disable=unbalanced-tuple-unpacking
return numpy.hstack([u - w * dl, v - w * dm, w])


Expand Down
5 changes: 2 additions & 3 deletions libs/fourier_transforms/fft_support.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,8 @@ def pad_mid(ff, npixel):
if npixel == nx:
return ff
assert npixel > nx and npixel > ny
pw = [(0, 0)] * (ff.ndim-2) + [(npixel // 2 - cy, npixel // 2 - cy),
(npixel // 2 - cx, npixel // 2 - cx)]
pw = [(0, 0)] * (ff.ndim - 2) + [(npixel // 2 - cy, npixel // 2 - cy),
(npixel // 2 - cx, npixel // 2 - cx)]
return numpy.pad(ff,
pad_width=pw,
mode='constant',
Expand Down Expand Up @@ -94,7 +94,6 @@ def extract_mid(a, npixel):
return a[..., cx - s:cx + s, cy - s:cy + s]



def extract_oversampled(a, xf, yf, kernel_oversampling, kernelwidth):
"""
Extract the (xf-th,yf-th) w-kernel from the oversampled parent
Expand Down
30 changes: 13 additions & 17 deletions libs/image/cleaners.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,23 +29,22 @@ def hogbom(dirty, psf, window, gain, thresh, niter, fracthresh, prefix=''):
assert 0.0 < gain < 2.0
assert niter > 0


log.info("hogbom %s Max abs in dirty image = %.6f Jy/beam" % (prefix, numpy.max(numpy.abs(dirty))))
absolutethresh = max(thresh, fracthresh * numpy.fabs(dirty).max())
log.info("hogbom %s Start of minor cycle" % prefix)
log.info("hogbom %s This minor cycle will stop at %d iterations or peak < %.6f (Jy/beam)" % (prefix, niter,
absolutethresh))
log.info("hogbom %s This minor cycle will stop at %d iterations or peak < %.6f (Jy/beam)" %
(prefix, niter, absolutethresh))

comps = numpy.zeros(dirty.shape)
res = numpy.array(dirty)
pmax = psf.max()
assert pmax > 0.0
log.info('hogbom %s: Timing for setup: %.3f (s) for dirty shape %s, PSF shape %s' %
(prefix, time.time() - starttime, str(dirty.shape), str(psf.shape)))
(prefix, time.time() - starttime, str(dirty.shape), str(psf.shape)))
starttime = time.time()
aiter = 0
for i in range(niter):
aiter = i+1
aiter = i + 1
if window is not None:
mx, my = numpy.unravel_index((numpy.fabs(res * window)).argmax(), dirty.shape)
else:
Expand All @@ -63,7 +62,7 @@ def hogbom(dirty, psf, window, gain, thresh, niter, fracthresh, prefix=''):

dtime = time.time() - starttime
log.info('%s Timing for clean: %.3f (s) for dirty %s, PSF %s , %d iterations, time per clean %.3f (ms)' %
(prefix, dtime, str(dirty.shape), str(psf.shape), aiter, 1000.0 * dtime/aiter))
(prefix, dtime, str(dirty.shape), str(psf.shape), aiter, 1000.0 * dtime / aiter))

return comps, res

Expand Down Expand Up @@ -173,11 +172,11 @@ def msclean(dirty, psf, window, gain, thresh, niter, scales, fracthresh, prefix=
log.info("msclean %s: Max abs in dirty Image = %.6f Jy/beam" % (prefix, numpy.fabs(res_scalestack[0, :, :]).max()))
absolutethresh = max(thresh, fracthresh * numpy.fabs(res_scalestack[0, :, :]).max())
log.info("msclean %s: Start of minor cycle" % prefix)
log.info("msclean %s: This minor cycle will stop at %d iterations or peak < %.6f (Jy/beam)" % (prefix, niter,
absolutethresh))
log.info("msclean %s: This minor cycle will stop at %d iterations or peak < %.6f (Jy/beam)" %
(prefix, niter, absolutethresh))

log.info('msclean %s: Timing for setup: %.3f (s) for dirty shape %s, PSF shape %s , scales %s' %
(prefix, time.time() - starttime, str(dirty.shape), str(psf.shape), str(scales)))
(prefix, time.time() - starttime, str(dirty.shape), str(psf.shape), str(scales)))
starttime = time.time()
aiter = 0
for i in range(niter):
Expand Down Expand Up @@ -211,7 +210,7 @@ def msclean(dirty, psf, window, gain, thresh, niter, scales, fracthresh, prefix=
dtime = time.time() - starttime
log.info('msclean %s: Timing for clean: %.3f (s) for dirty shape %s, PSF shape %s , scales %s, %d iterations, '
'time per clean %.3f (ms)' %
(prefix, dtime, str(dirty.shape), str(psf.shape), str(scales), aiter, 1000.0 * dtime/aiter))
(prefix, dtime, str(dirty.shape), str(psf.shape), str(scales), aiter, 1000.0 * dtime / aiter))

return comps, pmax * res_scalestack[0, :, :]

Expand Down Expand Up @@ -442,7 +441,6 @@ def msmfsclean(dirty, psf, window, gain, thresh, niter, scales, fracthresh, find
pmax = psf.max()
assert pmax > 0.0


psfpeak = argmax(numpy.fabs(psf))
log.info("mmclean %s: Peak of PSF = %s at %s" % (prefix, pmax, psfpeak))
dmax = dirty.max()
Expand Down Expand Up @@ -471,7 +469,6 @@ def msmfsclean(dirty, psf, window, gain, thresh, niter, scales, fracthresh, find
ssmmpsf = calculate_scale_scale_moment_moment_psf(lpsf, pscalestack)
hsmmpsf, ihsmmpsf = calculate_scale_inverse_moment_moment_hessian(ssmmpsf)


for scale in range(nscales):
log.debug("mmclean %s: Moment-moment coupling matrix[scale %d] =\n %s" % (prefix, scale, hsmmpsf[scale]))

Expand All @@ -488,16 +485,16 @@ def msmfsclean(dirty, psf, window, gain, thresh, niter, scales, fracthresh, find
log.info("mmclean %s: Max abs in dirty Image = %.6f Jy/beam" % (prefix, numpy.fabs(smresidual[0, 0, :, :]).max()))
absolutethresh = max(thresh, fracthresh * numpy.fabs(smresidual[0, 0, :, :]).max())
log.info("mmclean %s: Start of minor cycle" % prefix)
log.info("mmclean %s: This minor cycle will stop at %d iterations or peak < %.6f (Jy/beam)" % (prefix, niter,
absolutethresh))
log.info("mmclean %s: This minor cycle will stop at %d iterations or peak < %.6f (Jy/beam)" %
(prefix, niter, absolutethresh))

# Start iterations
scale_counts = numpy.zeros(nscales, dtype='int')
scale_flux = numpy.zeros(nscales)

aiter = 0
log.info('mmclean %s: Timing for setup: %.3f (s) for dirty shape %s, PSF shape %s , scales %s, %d moments' %
(prefix, time.time() - starttime, str(dirty.shape), str(psf.shape), str(scales), nmoments))
(prefix, time.time() - starttime, str(dirty.shape), str(psf.shape), str(scales), nmoments))
starttime = time.time()
for i in range(niter):
aiter = i + 1
Expand Down Expand Up @@ -533,8 +530,7 @@ def msmfsclean(dirty, psf, window, gain, thresh, niter, scales, fracthresh, find
dtime = time.time() - starttime
log.info('mmclean %s: Timing for clean: %.3f (s) for dirty shape %s, PSF shape %s , scales %s, %d moments, '
'%d iterations, time per clean %.3f (ms)' %
(prefix, dtime, str(dirty.shape), str(psf.shape), str(scales), nmoments, aiter, 1000.0 * dtime/aiter))

(prefix, dtime, str(dirty.shape), str(psf.shape), str(scales), nmoments, aiter, 1000.0 * dtime / aiter))

return m_model, pmax * smresidual[0, :, :, :]

Expand Down
2 changes: 1 addition & 1 deletion libs/image/operations.py
Original file line number Diff line number Diff line change
Expand Up @@ -336,4 +336,4 @@ def create_w_term_like(im: Image, w, phasecentre=None, remove_shift=False, dopol
fresnel = numpy.abs(w) * (0.5 * fov) ** 2
log.debug('create_w_term_image: For w = %.1f, field of view = %.6f, Fresnel number = %.2f' % (w, fov, fresnel))

return fim
return fim
2 changes: 1 addition & 1 deletion libs/util/array_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -172,4 +172,4 @@ def insert_array(im, x, y, flux, bandwidth=1.0, support=7, insert_function=inser
for pol in range(npol):
im[chan, pol, inty - support:inty + support, intx - support:intx + support] += flux[chan, pol] * insert

return im
return im
9 changes: 5 additions & 4 deletions libs/util/coordinate_support.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ def xyz_at_latitude(local_xyz, lat):
:return: Celestial XYZ coordinates
"""

x, y, z = numpy.hsplit(local_xyz, 3)
x, y, z = numpy.hsplit(local_xyz, 3) # pylint: disable=unbalanced-tuple-unpacking

lat2 = numpy.pi / 2 - lat
y2 = -z * numpy.sin(lat2) + y * numpy.cos(lat2)
Expand All @@ -72,7 +72,7 @@ def xyz_to_uvw(xyz, ha, dec):
:param dec: declination of phase tracking centre.
"""

x, y, z = numpy.hsplit(xyz, 3)
x, y, z = numpy.hsplit(xyz, 3) # pylint: disable=unbalanced-tuple-unpacking

# Two rotations:
# 1. by 'ha' along the z axis
Expand Down Expand Up @@ -100,7 +100,7 @@ def uvw_to_xyz(uvw, ha, dec):
:param dec: declination of phase tracking centre
"""

u, v, w = numpy.hsplit(uvw, 3)
u, v, w = numpy.hsplit(uvw, 3) # pylint: disable=unbalanced-tuple-unpacking

# Two rotations:
# 1. by 'dec-90' along the u axis
Expand Down Expand Up @@ -168,6 +168,7 @@ def skycoord_to_lmn(pos: SkyCoord, phasecentre: SkyCoord):
# not quite follow imaging conventions
return dc.y.value, dc.z.value, dc.x.value - 1


def lmn_to_skycoord(lmn, phasecentre: SkyCoord):
"""
Convert l,m,n coordinate system + phascentre to astropy sky coordinate
Expand All @@ -182,7 +183,7 @@ def lmn_to_skycoord(lmn, phasecentre: SkyCoord):
"""

# Convert l,m,n to SkyCoord convention, also enforce celestial sphere
n = numpy.sqrt(1-lmn[0]**2-lmn[1]**2)-1.0
n = numpy.sqrt(1 - lmn[0] ** 2 - lmn[1] ** 2) - 1.0
dc = n + 1, lmn[0], lmn[1]
target = SkyCoord(x=dc[0], y=dc[1], z=dc[2], representation='cartesian', frame=phasecentre.skyoffset_frame())
return target.transform_to(phasecentre.frame)
Expand Down