Skip to content

Commit 473c4c0

Browse files
committed
removed casapy-free CASA and pyfftw as default build options
1 parent 00667e7 commit 473c4c0

File tree

5 files changed

+34
-64
lines changed

5 files changed

+34
-64
lines changed

README.md

+13-15
Original file line numberDiff line numberDiff line change
@@ -17,50 +17,48 @@ Requirements:
1717
-- python (probably version >2.6..?)
1818
-- numpy, matplotlib
1919
-- CASA 4.0 or higher
20-
-- patchelf (optional)
21-
-- pyFFTW (optional)
20+
21+
Optional (requires some hacking):
22+
-- patchelf (to get casapy-free CASA)
23+
-- pyFFTW (for accelerated fft)
2224

2325
Usage:
2426

25-
For full installation (see below), start a python session:
26-
$ python
27-
> import leanpipedt
28-
> d = leanpipedt.pipe_thread(filename='data.ms', scan=0, nskip=0, iterint=100, nints=100, spw=[0], chans=range(5,60), selectpol=['RR','LL'], searchtype='imgall', filtershape='z', secondaryfilter='fullim', dmarr=[0,100], dtarr=[1,2], size=512*58, res=58, nthreads=8, gainfile='cal.g1', bpfile='cal.b1')
27+
For baseline mode, start a casapy session:
28+
$ casapy
29+
CASA> import leanpipedt
30+
CASA> d = leanpipedt.pipe_thread(filename='data.ms', scan=0, nskip=0, iterint=100, nints=100, spw=[0], chans=range(5,60), selectpol=['RR','LL'], searchtype='imgall', filtershape='z', secondaryfilter='fullim', dmarr=[0,100], dtarr=[1,2], size=512*58, res=58, nthreads=8, gainfile='cal.g1', bpfile='cal.b1')
2931

3032
This command will read the first 100 interations from scan 0 (first scan) of 'data.ms'. It will look for the first spectral window and save channels 5,59 (inclusive) for two, orthogonal, circular polarizations. The data will have calibration applied from the gain and bp files. A zero-mean will be subtracted, data dedispersed, and resampled for DM=0 and 100 pc/cm3 and time widths of 1 and 2 integrations. The image search will use a uv grid cell size of 58 lambda and an image size of 512 pixels square (appropriate 2 pixels per beam for L-band, VLA images; covers twice the FWHM).
3133

32-
An alternative version (without patchelf dependency) requires running leanpipedt from within a casapy session.
33-
3434
Files:
3535
-- leanpipedt.py: master script that defines search pipeline.
3636
-- applycals2.py and applytelcal.py: script to parse CASA calibration tables (gain and bp) or telcalfile. Called by leanpipedt.py.
3737
-- leanpipedt_cython.pyx: Cython-accelerated utility functions, including dedispersion of visibilities.
3838
-- qimg_cython.pyx: Cython-accelerated imaging functions.
3939
-- setup.py: script to compile Cython into shared-object libraries.
40-
-- tpipe.py: old version of search script (class-based structure, includes Miriad format data support).
40+
-- tpipe.py: deprecated version of search script (class-based structure, includes Miriad format data support).
4141

4242
Build Instructions:
4343
1) Install CASA
4444

45-
2) Build casapy-free CASA (optional; not possible on OSX yet)
45+
(optional 2) Build casapy-free CASA (not possible on OSX yet)
4646
This step builds python modules to import CASA into any Python session (no "casapy" session needed).
4747
This requires fixing some links to libraries with patchelf.
4848
Full instructions at http://newton.cx/~peter/2014/02/casa-in-python-without-casapy.
4949
See also the casapatch.sh script, which must be edited and run to build new CASA python modules.
5050
Once complete, you should be able to simply type "import casac" and get access to CASA's ms and table tools.
5151
Finally, download "casautil.py" at https://github.com/pkgw/pwpy/blob/master/intflib/casautil.py.
52-
53-
If you skip this step, you will need to remove references to "casautil" and the "ms" and "tb" definitions in leanpipedt.py and applycals2.py. Running from inside casapy will automatically define those objects in the Python namespace.
52+
To use this, you will need to uncomment references to "casautil" and the "ms" and "tb" definitions in leanpipedt.py and applycals2.py.
5453

5554
3) Install Cython
5655
See http://cython.org to build Cython, an optimizing static compiler for Python.
5756

58-
4) Install pyFFTW (optional)
57+
(Optional 4) Install pyFFTW
5958
Get pyFFTW at https://github.com/hgomersall/pyFFTW. Note that there is an unsupported library with similar name at https://pypi.python.org/pypi/PyFFTW3/0.2.1.
6059
This supposedly requires Cython 0.15, FFTW 3.3, Python 2.7, Numpy 1.6. Although I've made it work with Python 2.6.
6160
FFTW is an optimized FFT library and can boost performance by a factor of 2. Can be tricky to do this stage, so skipping is ok for many use cases.
62-
63-
If you skip this step, you will need to edit leanpipedt.py, leanpipedt_cython.pyx, and qimg_cython.pyx to redefine "fft". Instead of "fft" being an object from pyFFTW, it will be from numpy.fft.
61+
To use this, you will need to change commented lines in leanpipedt.py and qimg_cython.pyx to redefine "fft" and add references to pyfftw.
6462

6563
5) Build accelerated functions
6664
Edit "setup.py" file to define how Cython will compile (basically setting filename/function to be compiled).

applycals2.py

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
import numpy as n
22
import os, glob
3-
import casautil
43

5-
tb = casautil.tools.table()
4+
# optional import for casapy-free CASA
5+
#import casautil
6+
#tb = casautil.tools.table()
67

78
class solutions():
89
""" Container for CASA caltable(s).

casapatch.sh

-32
This file was deleted.

leanpipedt.py

+9-6
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,16 @@
1717
import leanpipedt_cython as lib
1818
#import leanpipe_external as lib
1919
import qimg_cython as qimg
20-
#from numpy import fft as fft
21-
import pyfftw.interfaces.NUMPY_fft as fft
22-
import casautil
2320

24-
# set up tools
25-
ms = casautil.tools.ms()
26-
qa = casautil.tools.quanta()
21+
# Optional imports that have extra dependencies
22+
# can choose fft from numpy or pyfftw.
23+
from numpy import fft as fft
24+
#import pyfftw.interfaces.NUMPY_fft as fft
25+
#
26+
# optionally can use CASA outside of casapy session. requires hacking CASA shared-object libraries...
27+
#import casautil
28+
#ms = casautil.tools.ms()
29+
#qa = casautil.tools.quanta()
2730

2831
def numpyview(arr, datatype, shape):
2932
""" Takes mp.Array and returns numpy array with shape of data in MS.

qimg_cython.pyx

+9-9
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@ import numpy as n
22
cimport numpy as n
33
cimport cython
44
# can choose between numpy and pyfftw
5-
#from numpy import fft
6-
import pyfftw
7-
import pyfftw.interfaces.NUMPY_fft as fft
5+
from numpy import fft
6+
#import pyfftw
7+
#import pyfftw.interfaces.NUMPY_fft as fft
88

99
CTYPE = n.long
1010
ctypedef n.long_t CTYPE_t
@@ -213,7 +213,7 @@ cpdef imgallfull(n.ndarray[n.float32_t, ndim=2] u, n.ndarray[n.float32_t, ndim=2
213213
for p in xrange(len3):
214214
grid[t, cellu, cellv] = data[t,i,j,p] + grid[t, cellu, cellv]
215215

216-
pyfftw.interfaces.cache.enable()
216+
# pyfftw.interfaces.cache.enable()
217217
for t in xrange(len0):
218218
grid[t] = fft.ifft2(grid[t])
219219
# too slow
@@ -267,7 +267,7 @@ cpdef imgallfullfilter(n.ndarray[n.float32_t, ndim=2] u, n.ndarray[n.float32_t,
267267
grid[t, cellu, cellv] = data[t,i,j,p] + grid[t, cellu, cellv]
268268

269269
# make images and filter based on threshold
270-
pyfftw.interfaces.cache.enable()
270+
# pyfftw.interfaces.cache.enable()
271271
candints = []; candims = []; candsnrs = []
272272
for t in xrange(len0):
273273
im = fft.ifft2(grid[t]).real
@@ -325,7 +325,7 @@ cpdef imgallfullfilterxy(n.ndarray[n.float32_t, ndim=2] u, n.ndarray[n.float32_t
325325
grid[t, cellu, cellv] = data[t,i,j,p] + grid[t, cellu, cellv]
326326

327327
# make images and filter based on threshold
328-
pyfftw.interfaces.cache.enable()
328+
# pyfftw.interfaces.cache.enable()
329329
candints = []; candims = []; candsnrs = []
330330
for t in xrange(len0):
331331
im = fft.ifft2(grid[t]).real
@@ -391,7 +391,7 @@ cpdef imgallfullfilterxy2(n.ndarray[n.float32_t, ndim=2] u, n.ndarray[n.float32_
391391
grid[t, cellu, cellv] = data[t,i,j,p] + grid[t, cellu, cellv]
392392

393393
# make images and filter based on threshold
394-
pyfftw.interfaces.cache.enable()
394+
# pyfftw.interfaces.cache.enable()
395395
candints = []; candims = []; candsnrs = []
396396
for t in xrange(len0):
397397
im = fft.ifft2(grid[t]).real*int(ndimx*ndimy)/float(nonzeros)
@@ -449,7 +449,7 @@ cpdef imgallfullfilterminxy(n.ndarray[n.float32_t, ndim=2] u, n.ndarray[n.float3
449449
grid[t, cellu, cellv] = data[t,i,j,p] + grid[t, cellu, cellv]
450450

451451
# make images and filter based on threshold
452-
pyfftw.interfaces.cache.enable()
452+
# pyfftw.interfaces.cache.enable()
453453
candints = []; candims = []; candsnrs = []
454454
for t in xrange(len0):
455455
im = fft.ifft2(grid[t]).real
@@ -523,7 +523,7 @@ cpdef imgallfullw(n.ndarray[n.float32_t, ndim=2] u, n.ndarray[n.float32_t, ndim=
523523
# grid[t, cellu-ksize/2:cellu+ksize/2+1, cellv-ksize/2:cellv+ksize/2+1] = uvker*data[t,i,j,p,None,None] + grid[t, cellu-ksize/2:cellu+ksize/2+1, cellv-ksize/2:cellv+ksize/2+1]
524524
# grid[t, cellu, cellv] = data[t,i,j,p] + grid[t, cellu, cellv] # no conv gridding
525525

526-
pyfftw.interfaces.cache.enable()
526+
# pyfftw.interfaces.cache.enable()
527527
for t in xrange(len0):
528528
grid[t] = fft.ifft2(grid[t])
529529

0 commit comments

Comments
 (0)