示例#1
0
def main(msfileslist,
         hdf5fileName,
         hdf5_dir='.',
         instrument='/instrument',
         solsetName=None,
         compression=5):
    tmp_msfiles = msfileslist.lstrip('[').rstrip(']').split(',')
    msfiles = [MS.strip("\' \"") for MS in tmp_msfiles]
    hdf5File = os.path.join(hdf5_dir, hdf5fileName)
    compression = int(compression)  #doesn't hurt if it is already an int
    instrument = instrument.strip()

    # Check is all the necessary files are available
    antennaFile = os.path.join(msfiles[0], 'ANTENNA')
    if not os.path.isdir(antennaFile):
        logging.critical('Missing ANTENNA table.')
        sys.exit(1)
    fieldFile = os.path.join(msfiles[0], 'FIELD')
    if not os.path.isdir(fieldFile):
        logging.critical('Missing FIELD table.')
        sys.exit(1)
    skydbFile = os.path.join(msfiles[0], 'sky')
    if not os.path.isdir(skydbFile):
        logging.warning(
            'No sky table found. (Direction-dependent parameters will not work.)'
        )
        skydbFile = 'None'

    #generate list of parmDB-filenames
    parmDBnames = [MS + instrument for MS in msfiles]

    ##create and fill the hdf5-file:
    #solset = parmDBs2h5parm(hdf5File, parmDBnames, antennaFile, fieldFile, skydbFile, compression=compression, solsetName=solsetName)
    # call the create_h5parm function from losoto (will put a stupid create message in the h5parm file)
    create_h5parm(parmDBnames, antennaFile, fieldFile, skydbFile, hdf5File,
                  compression, solsetName)

    ## Add CREATE entry to history
    #h5parmDB = h5parm(hdf5File, readonly = False)
    #soltabs = h5parmDB.getSoltabs(solset=solset)
    #for st in soltabs:
    #    sw = solWriter(soltabs[st])
    #    sw.addHistory('CREATE (by losotoImporter from %s / %s - %s)' % (os.path.abspath(''),
    #                               os.path.basename(parmDBnames[0]), os.path.basename(parmDBnames[-1]) ) )
    #h5parmDB.close()

    result = {}
    result['h5parm'] = hdf5File
    return result
示例#2
0
        except:
            logging.critical('Loading failed')
    else:
        globaldbFile = input_file
        if not os.path.exists(globaldbFile):
            logging.critical('Input globaldb/SB file not found.')
            sys.exit(1)
        logging.info("globaldb filename = "+globaldbFile)
        
        # Load the path of the files
        antennaFile = os.path.join(globaldbFile,'ANTENNA')
        fieldFile = os.path.join(globaldbFile,'FIELD')
        skydbFile = os.path.join(globaldbFile,'sky')

        # Make a list of all available instrument tables (only 1 for a standard MS)
        instrumentdbFiles = [ instrumentdbFile for instrumentdbFile in \
            glob.glob(os.path.join(globaldbFile,options.instrument)) \
            if os.path.isdir(instrumentdbFile) ]

    # Check antennaFile and fieldFile
    if not os.path.isdir(antennaFile):
        logging.critical('Missing ANTENNA table.')
        sys.exit(1)
    if not os.path.isdir(fieldFile):
        logging.critical('Missing FIELD table.')
        sys.exit(1)
    
    # Call the method that creates the h5parm file
    create_h5parm(instrumentdbFiles, antennaFile, fieldFile, skydbFile,
                  h5parmFile, complevel, solsetName, globaldbFile=globaldbFile,verbose=options.verbose)
示例#3
0
        except:
            logging.critical('Loading failed')
    else:
        globaldbFile = input_file
        if not os.path.exists(globaldbFile):
            logging.critical('Input globaldb/SB file not found.')
            sys.exit(1)
        logging.info("globaldb filename = "+globaldbFile)
        
        # Load the path of the files
        antennaFile = os.path.join(globaldbFile,'ANTENNA')
        fieldFile = os.path.join(globaldbFile,'FIELD')
        skydbFile = os.path.join(globaldbFile,'sky')

        # Make a list of all available instrument tables (only 1 for a standard MS)
        instrumentdbFiles = [ instrumentdbFile for instrumentdbFile in \
            glob.glob(os.path.join(globaldbFile,options.instrument)) \
            if os.path.isdir(instrumentdbFile) ]

    # Check antennaFile and fieldFile
    if not os.path.isdir(antennaFile):
        logging.critical('Missing ANTENNA table.')
        sys.exit(1)
    if not os.path.isdir(fieldFile):
        logging.critical('Missing FIELD table.')
        sys.exit(1)
    
    # Call the method that creates the h5parm file
    create_h5parm(instrumentdbFiles, antennaFile, fieldFile, skydbFile,
                  h5parmFile, complevel, solsetName, globaldbFile=globaldbFile,verbose=options.verbose)
示例#4
0
def plugin_main(args, **kwargs):
    fileid = kwargs['mapfile_in']
    datamap = DataMap.load(fileid)
    hdf5File = os.path.join(kwargs['hdf5_dir'], kwargs['hdf5file'])
    if kwargs.has_key('instrument'):
        instrument = kwargs['instrument']
    else:
        instrument = '/instrument'
    if kwargs.has_key('compression'):
        compression = int(kwargs['compression'])
    else:
        compression = 5
    if kwargs.has_key('solset'):
        solsetName = kwargs['solset']
    else:
        solsetName = None

    # Check is all the necessary files are available
    antennaFile = os.path.join(datamap[0].file, 'ANTENNA')
    if not os.path.isdir(antennaFile):
        logging.critical('Missing ANTENNA table.')
        sys.exit(1)
    fieldFile = os.path.join(datamap[0].file, 'FIELD')
    if not os.path.isdir(fieldFile):
        logging.critical('Missing FIELD table.')
        sys.exit(1)
    skydbFile = os.path.join(datamap[0].file, 'sky')
    if not os.path.isdir(skydbFile):
        logging.warning(
            'No sky table found. (Direction-dependent parameters will not work.)'
        )
        skydbFile = 'None'

    #generate list of parmDB-filenames
    parmDBnames = [MS.file + instrument for MS in datamap]

    ##create and fill the hdf5-file:
    #solset = parmDBs2h5parm(hdf5File, parmDBnames, antennaFile, fieldFile, skydbFile, compression=compression, solsetName=solsetName)
    # call the create_h5parm function from losoto (will put a stupid create message in the h5parm file)
    create_h5parm(parmDBnames, antennaFile, fieldFile, skydbFile, hdf5File,
                  compression, solsetName)

    ## Add CREATE entry to history
    #h5parmDB = h5parm(hdf5File, readonly = False)
    #soltabs = h5parmDB.getSoltabs(solset=solset)
    #for st in soltabs:
    #    sw = solWriter(soltabs[st])
    #    sw.addHistory('CREATE (by PipelineStep_losotoImporter from %s / %s - %s)' % (os.path.abspath(''),
    #                               os.path.basename(parmDBnames[0]), os.path.basename(parmDBnames[-1]) ) )
    #h5parmDB.close()

    #generate mapfile and wrap up
    mapfileentry = {}
    mapfileentry['host'] = 'localhost'
    mapfileentry['file'] = hdf5File
    mapfileentry['skip'] = False
    outfileid = os.path.join(kwargs['mapfile_dir'], kwargs['filename'])
    outmap = open(outfileid, 'w')
    outmap.write(repr([mapfileentry]))
    outmap.close()
    result = {}
    result['mapfile'] = outfileid
    return result
示例#5
0
        logging.critical('Missing ANTENNA table.')
        sys.exit(1)
    fieldFile = os.path.join(inMSs[0], 'FIELD')
    if not os.path.isdir(fieldFile):
        logging.critical('Missing FIELD table.')
        sys.exit(1)
    skydbFile = os.path.join(inMSs[0], 'sky')
    if not os.path.isdir(skydbFile):
        logging.warning(
            'No sky table found. (Direction-dependent parameters will not work.)'
        )
        skydbFile = 'None'

    #generate list of parmDB-filenames
    parmDBnames = [MS.rstrip('/') + instrument for MS in inMSs]

    ##create and fill the hdf5-file:
    #solset = parmDBs2h5parm(hdf5File, parmDBnames, antennaFile, fieldFile, skydbFile, compression=compression, solsetName=solsetName)
    # call the create_h5parm function from losoto (will put a stupid create message in the h5parm file)
    create_h5parm(parmDBnames, antennaFile, fieldFile, skydbFile, hdf5File,
                  compression, solsetName)

    ## Add CREATE entry to history
    #h5parmDB = h5parm(hdf5File, readonly = False)
    #soltabs = h5parmDB.getSoltabs(solset=solset)
    #for st in soltabs:
    #    sw = solWriter(soltabs[st])
    #    sw.addHistory('CREATE (by PipelineStep_losotoImporter from %s / %s - %s)' % (os.path.abspath(''),
    #                               os.path.basename(parmDBnames[0]), os.path.basename(parmDBnames[-1]) ) )
    #h5parmDB.close()