casa  $Rev:20696$
 All Classes Namespaces Files Functions Variables
casa.py
Go to the documentation of this file.
00001 import os
00002 import re
00003 import sys
00004 from casac import *
00005 
00006 ##
00007 ## first set up CASAPATH
00008 ##
00009 if os.environ.has_key('CASAPATH') :
00010     __casapath__ = os.environ['CASAPATH'].split(' ')[0]
00011     if not os.path.exists(__casapath__ + "/data") :
00012         raise RuntimeError, "CASAPATH environment variable is improperly set"
00013 else :
00014     __casapath__ = casac.__file__
00015     while __casapath__ and __casapath__ != "/" :
00016         if os.path.exists( __casapath__ + "/data") :
00017             break
00018         __casapath__ = os.path.dirname(__casapath__)
00019     if __casapath__ and __casapath__ != "/" :
00020         os.environ['CASAPATH']=__casapath__ + " linux local host"
00021     else :
00022         raise RuntimeError, "CASAPATH environment variable must be set"
00023 
00024 ##
00025 ## next adjust the PYTHONPATH
00026 ##
00027 if re.match( r'.*/\d+\.\d+\.\d+\w*-\d+$', __casapath__ ) :
00028     for root, dirs, files in os.walk(os.path.dirname(__casapath__)):
00029         if root.endswith("/numpy"):
00030             sys.path.append(os.path.dirname(root))
00031             break
00032 else:
00033     for root, dirs, files in os.walk(__casapath__):
00034         if root.endswith("/numpy"):
00035             sys.path.append(os.path.dirname(root))
00036             break
00037 
00038 ##
00039 ## next adjust PATH and LD_LIBRARY_PATH
00040 ##
00041 for root, dirs, files in os.walk(__casapath__):
00042     if root.endswith("/bin") and "casapyinfo" in files :
00043         __ipcontroller__ = (lambda fd: fd.readline().strip('\n'))(os.popen(root + "/casapyinfo --exec 'which ipcontroller'"))
00044         if os.path.exists(__ipcontroller__) :
00045             os.environ['PATH'] = os.path.dirname(__ipcontroller__) + ":" + os.environ['PATH']
00046         else :
00047             raise RuntimeError, "cannot configure CASA tasking system"
00048         __ld_library_path__ = (lambda fd: fd.readline().strip('\n').split(':'))(os.popen(root + "/casapyinfo --exec 'echo $LD_LIBRARY_PATH'"))
00049         map(lambda x: sys.path.append(x),__ld_library_path__)
00050         break
00051 
00052 ##
00053 ## finally load tools
00054 ##
00055 
00056 quanta = casac.quanta()
00057 measures = casac.measures()
00058 imager = casac.imager()
00059 synthesisimager = casac.synthesisimager()
00060 calibrater = casac.calibrater()
00061 ms = casac.ms()
00062 tableplot = casac.tableplot()
00063 msplot = casac.msplot()
00064 pmtool = casac.plotms()
00065 calplot = casac.calplot()
00066 table = casac.table()
00067 flagger = casac.flagger()
00068 agentflagger = casac.agentflagger()
00069 image = casac.image()
00070 imagepol = casac.imagepol()
00071 simulator = casac.simulator()
00072 componentlist = casac.componentlist()
00073 coordsys = casac.coordsys()
00074 regionmanager = casac.regionmanager()
00075 spectralline = casac.spectralline()
00076 utils = casac.utils()
00077 deconvolver = casac.deconvolver()
00078 vpmanager = casac.vpmanager()
00079 vlafillertask = casac.vlafillertask()
00080 atmosphere = casac.atmosphere()
00081 
00082 from accum import  accum
00083 from applycal import  applycal
00084 from asdmsummary import  asdmsummary
00085 from autoclean import  autoclean
00086 from bandpass import  bandpass
00087 from blcal import  blcal
00088 from boxit import  boxit
00089 from browsetable import  browsetable
00090 from calstat import  calstat
00091 from clean import  clean
00092 from clearcal import  clearcal
00093 from clearplot import  clearplot
00094 from clearstat import  clearstat
00095 #from concat import  concat
00096 from cvel import  cvel
00097 from deconvolve import  deconvolve
00098 from exportfits import  exportfits
00099 from exportuvfits import  exportuvfits
00100 from feather import  feather
00101 from find import  find
00102 from fixvis import  fixvis
00103 from flagdata import  flagdata
00104 from flagmanager import  flagmanager
00105 from fluxscale import  fluxscale
00106 from ft import  ft
00107 from gaincal import  gaincal
00108 from gencal import  gencal
00109 from hanningsmooth import  hanningsmooth
00110 from imcontsub import  imcontsub
00111 from imfit import  imfit
00112 from imhead import  imhead
00113 from immath import  immath
00114 from immoments import  immoments
00115 from importasdm import  importasdm
00116 from importfits import  importfits
00117 from importgmrt import  importgmrt
00118 from importuvfits import  importuvfits
00119 from importvla import  importvla
00120 from imregrid import  imregrid
00121 from imsmooth import  imsmooth
00122 from imstat import  imstat
00123 from imval import  imval
00124 from imview import imview
00125 from listcal import  listcal
00126 from listhistory import  listhistory
00127 from listobs import  listobs
00128 from listvis import  listvis
00129 from mosaic import  mosaic
00130 from msview import msview
00131 from partition import partition
00132 from peel import  peel
00133 from plotants import  plotants
00134 from plotcal import  plotcal
00135 from plotms import  plotms
00136 from plotxy import  plotxy
00137 from polcal import  polcal
00138 from rmtables import  rmtables
00139 from setjy import  setjy
00140 from simalma import  simalma
00141 from simobserve import  simobserve
00142 from simanalyze import  simanalyze
00143 from smoothcal import  smoothcal
00144 from specfit import  specfit
00145 from split import  split
00146 from uvcontsub import  uvcontsub
00147 from uvcontsub2 import  uvcontsub2
00148 from uvmodelfit import  uvmodelfit
00149 from uvsub import  uvsub
00150 from viewer import  viewer
00151 from vishead import  vishead
00152 from visstat import  visstat
00153 from widefield import  widefield
00154 from msmoments import msmoments
00155 
00156 
00157 ##
00158 ## asap may not be available with every casa installation
00159 ##
00160 try:
00161     import asap as sd
00162     from sdcal import sdcal
00163     from sdsmooth import sdsmooth
00164     from sdbaseline import sdbaseline
00165     from sdreduce import sdreduce
00166     from sdcoadd import sdcoadd
00167     from sdsave import sdsave
00168     from sdscale import sdscale
00169     from sdfit import sdfit
00170     from sdplot import sdplot
00171     from sdstat import sdstat
00172     from sdlist import sdlist
00173     from sdflag import sdflag
00174     from sdtpimaging import sdtpimaging
00175     from sdmath import sdmath
00176     from sdimaging import sdimaging
00177     from sdimprocess import sdimprocess
00178 except ImportError:
00179     sd = None
00180     sdcoadd = None
00181     sdscale = None
00182     sdtpimaging = None
00183     sdlist = None
00184     sdfit = None
00185     sdbaseline = None
00186     sdstat = None
00187     sdsave = None
00188     sdflag = None
00189     sdcal = None
00190     sdplot = None
00191     sdsmooth = None
00192     sdreduce = None