Exemplo n.º 1
0
def gencal(vis=None,caltable=None,caltype=None,infile=None,
           spw=None,antenna=None,pol=None,
           parameter=None):

       """ Externally specify calibration solutions af various types
       """

       #Python script
       try:

              if ((type(vis)==str) & (os.path.exists(vis))):
                     # don't need scr col for this
                     cb.open(filename=vis,compress=False,addcorr=False,addmodel=False)  
              else:
                     raise Exception, 'Visibility data set not found - please verify the name'

              if (caltable==''):
                     raise Exception, 'A caltable name must be specified'

              if caltype=='tecim' and not (type(infile)==str and os.path.exists(infile)):
                     raise Exception, 'An existing tec map must be specified in infile'

              # call a Python function to retreive ant position offsets automatically (currently EVLA only)
              if (caltype=='antpos' and antenna==''):
                casalog.post(" Determine antenna position offests from the baseline correction database")
                import correct_ant_posns as getantposns 
                # correct_ant_posns returns a list , [return_code, antennas, offsets]
                antenna_offsets=getantposns.correct_ant_posns(vis,False)
                if ((len(antenna_offsets)==3) and
                    (int(antenna_offsets[0])==0) and
                    (len(antenna_offsets[1])>0) ) :
                       antenna = antenna_offsets[1]
                       parameter = antenna_offsets[2] 
                else:
                   #raise Exception, 'No offsets found. No caltable created.'
                   import warnings
                   warnings.simplefilter('error',UserWarning)
                   warnings.warn('No offsets found. No caltable created.')

              cb.specifycal(caltable=caltable,time="",spw=spw,antenna=antenna,pol=pol,
                            caltype=caltype,parameter=parameter,infile=infile)

              #cb.close()
       
       except UserWarning, instance:
              print '*** Warning ***',instance
Exemplo n.º 2
0
def in_casapy(helper, vis=None):
    """This function is run inside the weirdo casapy IPython environment! A
    strange set of modules is available, and the
    `pwkit.environments.casa.scripting` system sets up a very particular
    environment to allow encapsulated scripting.

    """
    import numpy as np, sys
    from correct_ant_posns import correct_ant_posns

    info = correct_ant_posns(vis, False)
    if len(info) != 3 or info[0] != 0 or not len(info[1]):
        helper.die('failed to fetch VLA antenna positions; got %r', info)

    antenna = info[1]
    parameter = info[2]

    with open(helper.temppath('info.npy'), 'wb') as f:
        np.save(f, antenna)
        np.save(f, parameter)
Exemplo n.º 3
0
def in_casapy (helper, vis=None):
    """This function is run inside the weirdo casapy IPython environment! A
    strange set of modules is available, and the
    `pwkit.environments.casa.scripting` system sets up a very particular
    environment to allow encapsulated scripting.

    """
    import sys, cPickle as pickle
    from correct_ant_posns import correct_ant_posns

    info = correct_ant_posns (vis, False)
    if len (info) != 3 or info[0] != 0 or not len (info[1]):
        helper.die ('failed to fetch VLA antenna positions; got %r', info)

    antenna = info[1]
    parameter = info[2]

    with open (helper.temppath ('info.pkl'), 'w') as f:
        pickle.dump (antenna, f)
        pickle.dump (parameter, f)
Exemplo n.º 4
0
def gencal (cfg):
    cb = cu.tools.calibrater ()
    cb.open (filename=cfg.vis, compress=False, addcorr=False, addmodel=False)

    antenna = cfg.antenna or ''
    parameter = cfg.parameter

    if cfg.caltype == 'antpos' and cfg.antenna is None:
        from correct_ant_posns import correct_ant_posns
        info = correct_ant_posns (cfg.vis, False)
        if len (info) != 3 or info[0] != 0 or not len (info[1]):
            import sys
            print >>sys.stderr, 'correct_ant_posns: got %r' % info
            raise RuntimeError ('failed to fetch VLA antenna positions')

        antenna = info[1]
        parameter = info[2]

    cb.specifycal (caltable=cfg.caltable, time='', spw=(cfg.spw or ''),
                   antenna=antenna, pol=(cfg.pol or ''), caltype=cfg.caltype,
                   parameter=parameter)
    cb.close ()