GithubHelp home page GithubHelp logo

casanova's Introduction

CASANOVA - A New Way to use CASA

Why casanova?

NRAO's CASA (Common Astronomy Software Applications) is set of C++ tools bundled together under an iPython interface and comes with its own Python installation. There are probably very good reasons to bundle a separate Python installation but sometimes this approach has its drawbacks.

Some disadvantages:

  • Casapy comes with it's own (old) versions of Python, Matplotlib, etc.
  • It is not possible to import Python packages which are already installed against the system Python.
  • Installing third party packages is possible but devious.
  • Running scripts in casapy is done using execfile('somefile.py'). This makes that importing scripts that are in the same directory as somefile.py does not work automatically.
  • The same holds for self made modules in the same directory.
  • This makes creating a more elaborate pipeline (combination of scripts) ugly.

Various other CASA users have noted these disadvantages and several workarounds exist, e.g. drive-casa which allows for dynamic interaction with CASA from a separate Python process, casa-python which allows for a pip-like installation of third party packages and another project named casa-python which packages up the CASA C++ code and Python interface in the format used by the Anaconda project. This last one makes the CASA core easily installable in Anaconda the same way that Python modules with binary code are. It comes with separate tasks and is made by Dr. Peter K. G. Williams. Casanova is based on his work.

The idea of casanova is to make sure that you can import CASA (toolkit and tasks) inside your normal version of Python.

Accessing the CASA toolkit

CASA comes with a toolkit and tasks. In order to enable Python to import the CASA toolkit or CASA core (casac) you need to install its binary modules. If you can use Anaconda Python, the easiest way to do this is to install Peter Williams' casa-python and casa-data packages into an Anaconda install using the conda command. If you are unable to use Anaconda, you can try to copy the necessary binaries out of a standard CASA installation and set up the dynamically-linked libraries so that they can all find each other as explained a blog post by Peter Williams. This is what the install_casanova script does.

In casanova, accessing the CASA toolkits (casac) comes down to:

import casac
ms = casac.casac.ms()
ms.open ('vis.ms')
print ms.nrow()
ms.close()

Note that ms is an instance of the ms class.

Accessing CASA tasks

There are 137 CASA tasks which you can access in casanova using:

from casat import plotants
plotants = plotants.plotants
plotants(vis='myMeasurementSet.ms')

casat stands for CASA tasks. Note that the actual task function is located in a script with the same name.

Casapy uses its own installation of Python with an older version of matplotlib. In order to enable the tasks to work with the newer matplotlib installed in your own Python I had to change some files which are now in the code directory in this repository. I disabled the additional buttons in casapy's version of the plotter (for the differences see plotants in casapy and plotants in casanova). Also, I changed taskinit.py and created __init__.py in the casat directory in order to recreate a needed variable normally set when opening casapy.

The files tasks.txt and dependencies.txt contain the available CASA tasks and the files needed to execute them.

Installation

These instructions are for tcsh.

  1. Download (and unzip) the files in this repository to some directory.

  2. Move casa (I used casa-release-4.5.2-el6) to a directory named casapy (or so). Other directories such as python_packages will also end up in this directory. Create also a subdirectory called "python_packages"

  3. Download and install patchelf.

    If you don't have sudo permissions, you might want to do:

  4. Untar patchelf and go to directory.

  5. ./configure --prefix=/some/folder

  6. make

  7. make install

  8. Set the location in your path: set path = ($path /some/folder/bin) Note that patchelf now only works in this instance of your shell. You can also permanently add patchelf to your path in .cshrc.

  9. Modify and run the script install_casanova.

  10. Modify the casanova_startup script which was automatically placed in the CASA installation directory (the directory of step 2).

  11. Add alias casanova "source /net/dedemsvaart/data2/kvdam/casa_installation/casanova_startup" to your .cshrc file. Note that you should change the path to the casanova_startup script in your casa installation directory and not to the one in the directory where you stored this repository. This way everything stays in the same directory and you can later delete this repository on your computer without disabling casanova.

  12. Restart your shell (or source ~/.cshrc) and type casanova or casanova myscript.py.

Note: I ran into problems with libgfortran.so.3 and libgfortran.so.3.0.0. My other programs now preferred this fortran library over others (i.e.: version `GFORTRAN_1.4' not found (required by /usr/lib64/atlas/libtatlas.so.3)). I fixed this very bluntly by removing the libgfortran files from the __casac__ directory and storing them in a new folder called not_needed_libraries in the python_packages directory. I sort of hope that GFORTRAN_1.4 is newer and backwards compatible. For now, it seems to work.

Extra Task

A user-contributed task ftw() is automatically added. This new task is adapted from the regular ft() task but now also takes W-projection into account. The task is made by R. J. van Weeren.

Notes

You might want to change os.rename in cleanhelper.py to shutil.move because of invalid cross-device link problems

Project status

I've tried quite a few of the CASA tasks but not all of them (there are 137). So it's possible that you find a bug using one of the tasks.

I ended up creating casanova for my master's research project at Leiden Observatory (see my cspam repository) so after a few months I might not be a radio astronomer anymore ;-).

EDIT: I work at Nikhef now.

Contact: [email protected] or [email protected]

casanova's People

Contributors

cvalenzu avatar karlheitmann avatar kaspervd avatar maray avatar pkgw avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.