from casatools import ms, table
from casatasks import casalog
from .mstools import write_history
def importfitsidi(fitsidifile,vis,constobsid=None,scanreindexgap_s=None,specframe=None,coordframe=None):
"""Convert FITS-IDI visibility file into a CASA visibility file (MS).
fitsidifile -- Name(s) of input FITS IDI file(s)
default: None; example='3C273XC1.IDI' or ['3C273XC1.IDI1', '3C273XC1.IDI2']
vis -- Name of output visibility file (MS)
default: None; example: vis='3C273XC1.ms'
constobsid -- If True a constant obs id == 0 of is given to all input files
default = False (new obs id for each input file)
scanreindexgap_s -- if > 0., a new scan is started whenever the gap between two
integrations is > the given value (seconds) or when a new field starts
or when the ARRAY_ID changes.
default = 0. (no reindexing)
specframe -- this frame will be used to set the spectral reference frame
for all spectral windows in the output MS
default = GEO (geocentric), other options: TOPO, LSRK, BARY
NOTE: if specframe is set to TOPO, the reference location will be taken from
the Observatories table in the CASA data repository for the given name of
the observatory. You can edit that table and add new rows.
coordframe -- this frame will be used to set the reference frame
for all source positions in the output MS
default = '' (set based on opeoch/equinox),
other options: ICRS, B1950, J2000
NOTE: if the epoch/equinox is set to J2000 in the FITS-IDI file,
the reference frame will be set to ICRS. To use FK5/J2000 as the
reference frame, set coordframe to J2000.
casalog.origin('importfitsidi')
if type(specframe)==str and not specframe=='':
myspecframe=specframe.upper()
refframes = {'REST': 0, 'LSRK': 1, 'LSRD': 2, 'BARY': 3, 'GEO': 4, 'TOPO': 5}
if myspecframe not in refframes:
raise ValueError('Value '+myspecframe+' of parameter specframe invalid. Possible values are REST, LSRK, LSRD, BARY, GEO, TOPO')
if type(coordframe)==str and not coordframe=='':
mycoordframe=coordframe.upper()