from __future__ import absolute_import
from casatasks.private.casa_transition import *
from casatasks import casalog
from casatools import atcafiller
from .mstools import write_history
from taskinit import casac, casalog
from mstools import write_history
atcafiller = casac.atcafiller
"""Convert an RPFITS file into a CASA visibility file (MS).
The conversion of the RPFITS format into a measurement set.
This version has been tested for both old ATCA and CABB data.
files -- Name of input RPFITS file(s)
default: none; example: file='2010-01-02_1234.c999'
.... vis -- Output ms name, note a postfix (.ms) is NOT appended to this name
.... options -- Processing options, comma separated list
birdie - flag parts of spectrum known to be bad
reweight - (pre-CABB) reweight lag spectrum to avoid ringing
noautoflag - don't apply automatic flags (e.g. pointing scans)
noxycorr - don't apply xyphase correction
fastmosaic - use for large mosaics to speed up data access
hires - turn time binned data into fast sampled data
notsys - undo online Tsys calibration
noac - don't load autocorrelations
.... spw -- specify the input spectral windows to use. For CABB the order is
first continuum, 2nd continuum, then any zooms for first band,
followed by zooms for 2nd band. Pre-CABB data just has 0 and 1.
The output may have more spectral windows if there are frequency
.... nscans -- Number of scans to skip followed by number of scans to read
.... default: 0,0 (read all)
.... lowfreq -- Lowest reference frequency to select
.... highfreq -- highest reference frequency to select
.... fields -- List of field names to select