casa  $Rev:20696$
 All Classes Namespaces Files Functions Variables
ssoflux.py
Go to the documentation of this file.
00001 #
00002 # This file was generated using xslt from its XML file
00003 #
00004 # Copyright 2009, Associated Universities Inc., Washington DC
00005 #
00006 import sys
00007 import os
00008 from  casac import *
00009 import string
00010 from taskinit import casalog
00011 #from taskmanager import tm
00012 import task_ssoflux
00013 def ssoflux(vis='', field='', spw='', modimage='', fluxdensity=-1, standard='Perley-Taylor 99'):
00014 
00015         """Fills the model column with the visibilities of a calibrator
00016        *This is an experimental clone of setjy while flux calibration with
00017         Solar System objects is being tested.  It will eventually be merged
00018         back into setjy.*
00019 
00020        This task sets the model visibility amp and phase of a
00021        specified source (generally a calibrator).  The simplest way is
00022        to enter the flux density (I,Q,U,V) explicitly, but this is
00023        valid only for a point source.
00024 
00025        For an extended source, the clean model (image.model) can be
00026        specified and the model visibilities associated with this clean
00027        model is placed in the visibility model column.
00028 
00029        Models are available for 3C48, 3C138, 3C286 between
00030        1.4 and 43 GHz.  3C147 is available above 13 GHz.  These models
00031        are scaled to the precise frequency of the data.  Only I source 
00032        model can be inserted at a time.
00033 
00034        The location of the models are system dependent:  At the AOC and CV,
00035        the models are in the directory::/usr/lib/casapy/data/nrao/VLA/CalModels
00036        or /usr/lib64/casapy/data/nrao/VLA/CalModel.
00037 
00038        ssoflux need only be run on the calibrator sources with a known flux
00039        density and/or model.
00040 
00041        Keyword arguments:
00042        vis -- Name of input visibility file
00043                default: none.  example: vis='ngc5921.ms'
00044        field -- Select field using field id(s) or field name(s).
00045               default: ''=all fields, but run ssoflux one field at a time.
00046                  [run listobs to obtain the list id's or names of calibrators]
00047               If field is a non-negative integer, it is assumed to be a field
00048               index.  Otherwise, it is taken to be a field name.
00049               field='0~2'; field ids 0,1,2
00050               field='0,4,5~7'; field ids 0,4,5,6,7
00051               field='3C286,3C295'; field named 3C286 and 3C295
00052               field = '3,4C*'; field id 3, all names starting with 4C
00053        spw -- Select spectral window/channels
00054               default: ''=all spectral windows and channels
00055               spw='0~2,4'; spectral windows 0,1,2,4 (all channels)
00056               spw='<2';  spectral windows less than 2 (i.e. 0,1)
00057               spw='0:5~61'; spw 0, channels 5 to 61
00058               spw='0,10,3:3~45'; spw 0,10 all channels, spw 3, channels 3 to 45.
00059               spw='0~2:2~6'; spw 0,1,2 with channels 2 through 6 in each.
00060               spw='0:0~10;15~60'; spectral window 0 with channels 0-10,15-60
00061               spw='0:0~10,1:20~30,2:1;2;4'; spw 0, channels 0-10,
00062                        spw 1, channels 20-30, and spw 2, channels, 1,2 and 4
00063 
00064        Use one of the two methods below:  modimage or fluxdensity
00065 
00066        modimage -- Model image (I only) for setting the model visibilities.
00067               default: '' means use fluxdensity instead of modimage. 
00068               Each field must be done separately.  The image clean model
00069               will be scaled from the frequency in the model to that actually used,
00070               unless fluxdensity = 0 (or fluxdensity[0] = 0).
00071               Both the amplitude and phase are calculated.
00072               At the AOC or CV, the models are located in
00073               /usr/lib/casapy/data/nrao/VLA/CalModels/3C286_L.im (egs)
00074                    lib64
00075 
00076        fluxdensity -- Specified flux density [I,Q,U,V] in Jy
00077                default: -1, uses [1,0,0,0] flux density for all sources,
00078                   except for 3C286, 3C48 and 3C147, which use standard flux
00079                   densities.  It is recommended to use modimage for
00080                   these sources if they are resolved by the observation.
00081                Only one flux density can be specified at a time.  The phases are
00082                   set to zero.
00083                example   fluxdensity=-1  will insert 1.0 for all calibrators
00084                          except 3C286, 3C147 and 3C48.
00085                example   field = '1'; fluxdensity=[3.2,0,0,0] wil put in 
00086                          a flux density of I=3.2 for field='1'
00087 
00088                At present (June 2000), this is the only method to insert a
00089                polarized flux density model.
00090                example:  fluxdensity=[2.63,0.21,-0.33,0.02]
00091                          will put in I,Q,U,V flux densities of 2.63,0.21,-0.33,
00092                          and 0.02, respectively, in the model column.
00093 
00094        standard -- Flux density standard, used if fluxdensity<0
00095                default: 'Perley-Taylor 99'; example: standard='Baars'
00096                Options: 'Baars','Perley 90','Perley-Taylor 95',
00097                   'Perley-Taylor 99', 'Perley-Butler 2010',
00098                   and 'Butler-JPL-Horizons 2010'.
00099                All but the last one are for extragalactic calibrators,
00100                and the final one is for Solar System objects.
00101  
00102         """
00103 
00104 #
00105 #    The following is work around to avoid a bug with current python translation
00106 #
00107         mytmp = {}
00108 
00109         mytmp['vis'] = vis
00110         mytmp['field'] = field
00111         mytmp['spw'] = spw
00112         mytmp['modimage'] = modimage
00113         mytmp['fluxdensity'] = fluxdensity
00114         mytmp['standard'] = standard
00115         pathname='file:///'+os.environ.get('CASAPATH').split()[0]+'/share/xml/'
00116         trec = casac.utils().torecord(pathname+'ssoflux.xml')
00117 
00118         casalog.origin('ssoflux')
00119         if trec.has_key('ssoflux') and casac.utils().verify(mytmp, trec['ssoflux']) :
00120             result = task_ssoflux.ssoflux(vis, field, spw, modimage, fluxdensity, standard)
00121 
00122         else :
00123           result = False
00124         return result