diff --git a/Makefile b/Makefile index a0c5f6d7..e87d891c 100644 --- a/Makefile +++ b/Makefile @@ -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" @@ -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 diff --git a/libs/calibration/solvers.py b/libs/calibration/solvers.py index 12fec81f..85460927 100644 --- a/libs/calibration/solvers.py +++ b/libs/calibration/solvers.py @@ -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] @@ -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] @@ -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] diff --git a/libs/fourier_transforms/convolutional_gridding.py b/libs/fourier_transforms/convolutional_gridding.py index 9de02793..c5c354c4 100644 --- a/libs/fourier_transforms/convolutional_gridding.py +++ b/libs/fourier_transforms/convolutional_gridding.py @@ -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]) diff --git a/libs/fourier_transforms/fft_support.py b/libs/fourier_transforms/fft_support.py index 5474e0a7..3a25a156 100644 --- a/libs/fourier_transforms/fft_support.py +++ b/libs/fourier_transforms/fft_support.py @@ -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', @@ -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 diff --git a/libs/image/cleaners.py b/libs/image/cleaners.py index fa099e38..35cdd504 100644 --- a/libs/image/cleaners.py +++ b/libs/image/cleaners.py @@ -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: @@ -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 @@ -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): @@ -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, :, :] @@ -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() @@ -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])) @@ -488,8 +485,8 @@ 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') @@ -497,7 +494,7 @@ def msmfsclean(dirty, psf, window, gain, thresh, niter, scales, fracthresh, find 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 @@ -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, :, :, :] diff --git a/libs/image/operations.py b/libs/image/operations.py index f4cf562b..0fd822de 100644 --- a/libs/image/operations.py +++ b/libs/image/operations.py @@ -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 \ No newline at end of file + return fim diff --git a/libs/util/array_functions.py b/libs/util/array_functions.py index c13fd84c..1ae07ef3 100644 --- a/libs/util/array_functions.py +++ b/libs/util/array_functions.py @@ -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 \ No newline at end of file + return im diff --git a/libs/util/coordinate_support.py b/libs/util/coordinate_support.py index 924aeefc..d0377250 100644 --- a/libs/util/coordinate_support.py +++ b/libs/util/coordinate_support.py @@ -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) @@ -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 @@ -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 @@ -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 @@ -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)