Example #1
0
File: ms.py Project: SpheMakh/pyxis
def from_uvfits (fitsfile,msname="$MS"):
  """Converts UVFITS file into MS""";
  fitsfile,msname = interpolate_locals("fitsfile msname");
  if not msname:
    msname = fitsfile+".MS";
  std.runcasapy("""ms.fromfits(msfile='$msname',fitsfile='$fitsfile')""");
  verify_antpos(msname,fix=True);
Example #2
0
def from_uvfits(fitsfile, msname="$MS"):
    """Converts UVFITS file into MS"""
    fitsfile, msname = interpolate_locals("fitsfile msname")
    if not msname:
        msname = fitsfile + ".MS"
    std.runcasapy("""ms.fromfits(msfile='$msname',fitsfile='$fitsfile')""")
    verify_antpos(msname, fix=True)
Example #3
0
def fits2casa (input,output):
    """Converts FITS image to CASA image."""
    if exists(output):
        rm_fr(output)
    if not exists(input):
        abort("$input does not exist")
    std.runcasapy("importfits('$input','$output',overwrite=True)")
Example #4
0
def split_rebin(msname="$MS",
                output="$MSOUT",
                chan=None,
                time=None,
                field=None,
                spw=None,
                column="DATA"):
    """Splits and/or resamples MS in frequency with the given channel stepping size, and/or in time
  with the give time bin size (e.g. '5s'), and/or breaks out the specified fields and spws"""
    msname, output = interpolate_locals("msname output")
    args = ""

    def list2str(arg):
        return ",".join(map(str, stg)) if isinstance(arg,
                                                     (list,
                                                      tuple)) else str(arg)

    if chan:
        args += II(",width=[$chan]")
    if time:
        args += II(",timebin='$time'")
    if field:
        args += II(",field='%s'" % list2str(field))
    if spw:
        args += II(",spw='%s'" % list2str(spw))
    column = column.lower()
    std.runcasapy(
        """split(vis='$msname',outputvis='$output',datacolumn='$column'$args);"""
    )
Example #5
0
def virtconcat(output="concat.MS", thorough=False, subtables=False):
    """Virtually concatenates the MSs given by MS_List into an output MS."""
    output, options = interpolate_locals("output options")
    auxfile = II("${output}.dat")
    if not v.MS_List:
        abort("MS_List must be set before calling ms.virtconcat()")
    if len(v.MS_List) != len(set([os.path.basename(x) for x in v.MS_List])):
        abort(
            "ms.virtconcat: MSs to be concatenated need to have unique basenames. Please rename your MSs accordingly."
        )
    cmd = ""
    if thorough:
        cmd = """ms.open("%s", nomodify=False)\n""" % v.MS_List[0]
        for msl in v.MS_List[1:]:
            cmd += II(
                """ms.virtconcatenate("$msl","$auxfile",'1GHz','1arcsec')\n""")
        cmd += II("""ms.close()\nos.remove('$auxfile')\n""")
    cmd += """if not ms.createmultims('$output',["%s"],
  [],
  True, # nomodify  
  False,# lock  
  $subtables): # copysubtables from first to all other members  
  os._exit(1);
ms.close();
""" % '","'.join(v.MS_List)
    std.runcasapy(cmd)
    info("virtually concatenated %d inputs MSs into $output" % len(v.MS_List))
Example #6
0
File: ms.py Project: SpheMakh/pyxis
def fixuvw (msname="$MS",fix=True,rowstep=100000):
  """Fixes the UVW column of an MS by recomputing it from scratch. If fix=False, only prints differences with current 
  UVW column at every rowstep-th row"""
  # these are parameters for the CASA script given by 
  msname = interpolate_locals("msname");
  write_uvw = fix;
  std.runcasapy(_utils.casa_scripts.fixuvw_casa,content="_utils.casa_scripts.fixuvw_casa");
  if fix:
    info("updated UVWs have been written to $msname");
  else:
    info("fix=False, updated UVWs not written out");
Example #7
0
def fixuvw(msname="$MS", fix=True, rowstep=100000):
    """Fixes the UVW column of an MS by recomputing it from scratch. If fix=False, only prints differences with current 
  UVW column at every rowstep-th row"""
    # these are parameters for the CASA script given by
    msname = interpolate_locals("msname")
    write_uvw = fix
    std.runcasapy(_utils.casa_scripts.fixuvw_casa,
                  content="_utils.casa_scripts.fixuvw_casa")
    if fix:
        info("updated UVWs have been written to $msname")
    else:
        info("fix=False, updated UVWs not written out")
Example #8
0
File: ms.py Project: SpheMakh/pyxis
def concat (output="concat.MS",thorough=False,subtables=False,freqtol='1MHz',dirtol='1arcsec'):
  """Concatenates the MSs given by MS_List into an output MS."""
  output,freqtol,dirtol = interpolate_locals("output freqtol dirtol");
  info("concatenating",v.MS_List,"into $output");
  if not v.MS_List:
    abort("MS_List must be set before calling ms.concat()");
  if len(v.MS_List) != len(set([os.path.basename(name) for name in v.MS_List])):
    abort("ms.virtconcat: MSs to be concatenated need to have unique basenames. Please rename your MSs accordingly.");
  x.sh("cp -a "+v.MS_List[0]+" "+output);
  cmd = """ms.open("%s", nomodify=False)\n"""%output;
  for msl in v.MS_List[1:]:
    cmd += II("""ms.concatenate("$msl",freqtol='$freqtol',dirtol='$dirtol')\n""");  
  cmd += II("""ms.close()\n""");
  std.runcasapy(cmd);
  info("concatenated %d inputs MSs into $output"%len(v.MS_List));
Example #9
0
File: ms.py Project: SpheMakh/pyxis
def split_rebin (msname="$MS",output="$MSOUT",chan=None,time=None,field=None,spw=None,column="DATA"):
  """Splits and/or resamples MS in frequency with the given channel stepping size, and/or in time
  with the give time bin size (e.g. '5s'), and/or breaks out the specified fields and spws""";
  msname,output = interpolate_locals("msname output");
  args = ""
  def list2str (arg):
    return ",".join(map(str,stg)) if isinstance(arg,(list,tuple)) else str(arg);
  if chan:
    args += II(",width=[$chan]");
  if time:
    args += II(",timebin='$time'");
  if field:
    args += II(",field='%s'"%list2str(field));
  if spw:
    args += II(",spw='%s'"%list2str(spw));
  column = column.lower();
  std.runcasapy("""split(vis='$msname',outputvis='$output',datacolumn='$column'$args);""");
Example #10
0
def concat(output="concat.MS",
           thorough=False,
           subtables=False,
           freqtol='1MHz',
           dirtol='1arcsec'):
    """Concatenates the MSs given by MS_List into an output MS."""
    output, freqtol, dirtol = interpolate_locals("output freqtol dirtol")
    info("concatenating", v.MS_List, "into $output")
    if not v.MS_List:
        abort("MS_List must be set before calling ms.concat()")
    if len(v.MS_List) != len(
            set([os.path.basename(name) for name in v.MS_List])):
        abort(
            "ms.virtconcat: MSs to be concatenated need to have unique basenames. Please rename your MSs accordingly."
        )
    x.sh("cp -a " + v.MS_List[0] + " " + output)
    cmd = """ms.open("%s", nomodify=False)\n""" % output
    for msl in v.MS_List[1:]:
        cmd += II(
            """ms.concatenate("$msl",freqtol='$freqtol',dirtol='$dirtol')\n""")
    cmd += II("""ms.close()\n""")
    std.runcasapy(cmd)
    info("concatenated %d inputs MSs into $output" % len(v.MS_List))
Example #11
0
File: ms.py Project: SpheMakh/pyxis
def virtconcat (output="concat.MS",thorough=False,subtables=False):
  """Virtually concatenates the MSs given by MS_List into an output MS."""
  output,options = interpolate_locals("output options");
  auxfile = II("${output}.dat");
  if not v.MS_List:
    abort("MS_List must be set before calling ms.virtconcat()");
  if len(v.MS_List) != len(set([os.path.basename(x) for x in v.MS_List])):
    abort("ms.virtconcat: MSs to be concatenated need to have unique basenames. Please rename your MSs accordingly.");
  cmd = "";
  if thorough:
    cmd = """ms.open("%s", nomodify=False)\n"""%v.MS_List[0];
    for msl in v.MS_List[1:]:
      cmd += II("""ms.virtconcatenate("$msl","$auxfile",'1GHz','1arcsec')\n""");  
    cmd += II("""ms.close()\nos.remove('$auxfile')\n""");
  cmd += """if not ms.createmultims('$output',["%s"],
  [],
  True, # nomodify  
  False,# lock  
  $subtables): # copysubtables from first to all other members  
  os._exit(1);
ms.close();
"""%'","'.join(v.MS_List); 
  std.runcasapy(cmd);
  info("virtually concatenated %d inputs MSs into $output"%len(v.MS_List));
Example #12
0
File: ms.py Project: SpheMakh/pyxis
def summary (msname="$MS"):
  msname = interpolate_locals("msname");
  std.runcasapy("listobs('$msname')");
Example #13
0
def summary(msname="$MS"):
    msname = interpolate_locals("msname")
    std.runcasapy("listobs('$msname')")
Example #14
0
def rebin_freq (msname="$MS",output="$MSOUT",step=1):
  """Resamples MS in frequency with the given step size""";
  msname,output = interpolate_locals("msname output");
  std.runcasapy("""ms.open("$msname"); ms.split(outputms='$output',step=$step);""");
Example #15
0
def from_uvfits (fitsfile,msname="$MS"):
  fitsfile,msname = interpolate_locals("fitsfile msname");
  if not msname:
    msname = fitsfile+".MS";
  std.runcasapy("""ms.fromfits(msfile='$msname',fitsfile='$fitsfile')""");