casa  $Rev:20696$
 All Classes Namespaces Files Functions Variables
Functions
sdmath Namespace Reference

Functions

def sdmath

Function Documentation

def sdmath.sdmath (   expr = '',
  varlist = {},
  antenna = 0,
  fluxunit = '',
  telescopeparm = '',
  specunit = '',
  frame = '',
  doppler = '',
  scanlist = [],
  field = '',
  iflist = [],
  pollist = [],
  outfile = '',
  outform = 'ASAP',
  overwrite = False 
)
ASAP SD task: do simple arithmatic (subtraction, addition, multiplication, and division) for spectra
  Keyword arguments:
expr -- Mathematical expression using scantables 
varlist -- Dictionary of variables in expr and their values.
           Keys must be coincide with variables used in expr.
           Values are substituted in each value in expr.
antenna -- antenna name or id (only effective for MS input). 
fluxunit -- units for line flux
        options: 'K','Jy',''
        default: '' (keep current fluxunit)
        WARNING: For GBT data, see description below.
    >>> fluxunit expandable parameter
         telescopeparm -- the telescope characteristics
                options: (str) name or (list) list of gain info
                default: '' (none set)
                example: if telescopeparm='', it tries to get the telescope
                         name from the data.
                         Full antenna parameters (diameter,ap.eff.) known
                         to ASAP are
                         'ATPKSMB', 'ATPKSHOH', 'ATMOPRA', 'DSS-43',
                         'CEDUNA','HOBART'. For GBT, it fixes default fluxunit
                         to 'K' first then convert to a new fluxunit.
                         telescopeparm=[104.9,0.43] diameter(m), ap.eff.
                         telescopeparm=[0.743] gain in Jy/K
                         telescopeparm='FIX' to change default fluxunit
                         see description below

specunit -- units for spectral axis
        options: (str) 'channel','km/s','GHz','MHz','kHz','Hz'
        default: '' (=current)
        example: this will be the units for masklist
frame -- frequency frame for spectral axis
        options: (str) 'LSRK','REST','TOPO','LSRD','BARY',
                 'GEO','GALACTO','LGROUP','CMB'
        default: currently set frame in scantable
        WARNING: frame='REST' not yet implemented
doppler -- doppler mode
        options: (str) 'RADIO','OPTICAL','Z','BETA','GAMMA'
        default: currently set doppler in scantable
scanlist -- list of scan numbers to process
        default: [] (use all scans)
        example: [21,22,23,24]
        this selection is in addition to field, iflist, and pollist
field -- selection string for selecting scans by name
        default: '' (no name selection)
        example: 'FLS3a*'
        this selection is in addition to scanlist, iflist, and pollist
iflist -- list of IF id numbers to select
        default: [] (use all IFs)
        example: [15]
        this selection is in addition to scanlist, field, and pollist
pollist -- list of polarization id numbers to select
        default: [] (use all polarizations)
        example: [1]
        this selection is in addition to scanlist, field, and iflist
outfile -- Name of output file
        default: '' (<infile>_cal)
outform -- format of output file
        options: 'ASCII','SDFITS','MS','ASAP'
        default: 'ASAP'
        example: the ASAP format is easiest for further sd
                 processing; use MS for CASA imaging.
                 If ASCII, then will append some stuff to
                 the outfile name
overwrite -- overwrite the output file if already exists
        options: (bool) True,False
        default: False
        WARNING: if outform='ASCII', this parameter is ignored


DESCRIPTION:

Task sdmath execute a mathematical expression for single dish spectra.
The spectral data file can be any of the formats supported by
ASAP (scantable, MS, rpfits, and SDFITS). In the expression, 
these file names should be put inside of sigle or double quotes.

You can use variables in the expression. If you want to use, you 
must define varlist dictionary. Name of variables should be simple, 
e.g. V0, V1, etc., to avoid unexpected error. Keys of varlist must 
be name of variables that you used in the expression, and their 
values will be substituted for variables in the expression. Allowed 
type for the value is numerical values, one- or two-dimensional lists 
(Python list or numpy.ndarray), and filename strings that indicate 
spectral data or ASCII text, which is space-separated list of 
numerical values consisting of adequate number of rows and columns.  

The fluxunit, specunit, and frame can be set, otherwise, the current
settings of the first spectral data in the expression are used.  
Other selections (e.g. scan No, . IF, Pol) also apply to all 
the spectral data in the expression, so if any of the data does
not contains selection, the task will produce no output. 
       
WARNING for the GBT raw SDFITS format data as input:
SDtasks are able to handle GBT raw SDFITS format data since the 
data filler is available. However, the functionality is not well 
tested yet, so that there may be unknown bugs.  

Example:
# do on-off/off calculation
expr='("orion_on_data.asap"-"orion_off_data.asap")/"orion_off_data.asap"
outfile='orion_cal.asap'
sdmath()

# do on-off/off calculation using varlist
expr='V0/V1-V2'
varlist['V0']="orion_on_data.asap"
varlist['V1']="orion_off_data.asap"
varlist['V2']=1.0
outfile='orion_cal.asap'
sdmath()

# interpretation of ASCII file value for varlist
If the contents of input ASCII file is shown as, 

   0.5 0.3 0.2
   1.0 0.2 0.9

it is interpreted as a list [[0.5, 0.3, 0.2],[1.0, 0.2, 0.9]]. 

Definition at line 13 of file sdmath.py.

References task_sdmath.sdmath(), and vla_uvfits_line_sf.verify.