コード例 #1
0
def main(project_dict=False, AOT=False):
    """Asks the user for project information or reads the information from the provided dictionaries to write to the README"""
    if project_dict == False:
        project_dict = project_info.main()
    if AOT == False:
        AOT_dict = OT_info.getOTinfo(project_dict['SB_name'], AOTpath=False)
    else:
        AOT_dict = OT_info.getOTinfo(project_dict['SB_name'],AOTpath=AOT)
    AOTdir = AOT_dict[0]
    readme_info = getInfo(project_dict,AOT_dict)
    write2Readme(project_dict['project_type'], project_dict['project_path'], readme_info, project_dict['casa_version']) # why won't this write??
    #fill_README.testwrite()
    cleanup(AOTdir['AOT'])
コード例 #2
0
ファイル: script_generator.py プロジェクト: elastufka/DR
def get_parameters(project_dict=False, OT_dict=False):
    """gets the parameter dictionary from list_imparameters_CASA.py """
    if project_dict == False:
        project_dict = pi.main() #will query the user for project details. Should never happen when running the generate() method, this is mainly for testing purposes
    if OT_dict == False:
	OT_dict = OT_info.getOTinfo(project_dict['SB_name'])
    XMLroots=OT_dict[1]
    science_root = XMLroots['science_root']
    namespaces = XMLroots['namespaces']
    nms = li.getnum_ms(project_dict['project_type'], project_dict['project_path'])
    listobs = li.getListobs()
    line = listobs[0]
    index = listobs[1]
    nspws = li.getNspw(line, index)
    cell = li.getCell(line)
    scifld = li.getScienceFields(line, index)
    #specinfo = li.getLines(index, int(nspws[0]))

    spwdict = li.getSpwInfo(science_root, namespaces, nspws[1])
    rfreqHz = li.getRestFreq(science_root, namespaces)
    vwidth = li.getVelWidth(science_root, namespaces, rfreqHz=rfreqHz)
    rframe = li.getRefFrame(science_root, namespaces)
    sg = OT_dict[0]
    AOT = OT_dict[0]['AOT']
    sName = li.sourceName(science_root, namespaces, project_dict['SB_name'])
    mosaic = li.mosaicBool(namespaces, XMLroots['science_root'], sName)
    if mosaic == 'true':
        pc = li.getPhasecenter(science_root, namespaces)
    else: 
        pc = 'N/A'

    # fill dictionary
    pc = li.getPhasecenter(science_root, namespaces)
    lastfield = scifld[scifld.rfind(',')+1:]

    parameters = {'project_number': project_dict['project_number'],'SB_name': project_dict['SB_name'],'nms':nms,'mosaic': mosaic, 'scifields': scifld,'scifield0': str(scifld[0]), 'scifield1': str(lastfield), 'cellsize': cell[0], 'imsize':cell[1], 'rframe':rframe, 'vwidth':vwidth[0], 'rwidth': vwidth[1], 'rwidthunit': vwidth[2], 'spw_dict': spwdict, 'rfreq':str(float(rfreqHz)*1e-9), 'plotcmd': '', 'sourceName': sName, 'phasecenter': pc, 'AOT': AOT}
    print parameters
    return parameters
コード例 #3
0
def get_parameters(project_dict=False, OT_dict=False):
    if project_dict == False:
        project_dict = pi.main()
    if OT_dict == False:
	OT_dict = OT_info.getOTinfo(project_dict['SB_name'])
    XMLroots=OT_dict[1]
    science_root = XMLroots['science_root']
    namespaces = XMLroots['namespaces']
    nms = li.getnum_ms(project_dict['project_type'], project_dict['project_path'])
    listobs = li.getListobs()
    line = listobs[0]
    index = listobs[1]
    nspws = li.getNspw(line, index)
    cell = li.getCell(line)
    scifld = li.getScienceFields(line, index)
    specinfo = li.getLines(index, int(nspws[0]))
    spwdict = li.getSpwInfo(science_root, namespaces, nspws[1])
    rfreqHz = li.getRestFreq(science_root, namespaces)
    vwidth = li.getVelWidth(science_root, namespaces, rfreqHz=rfreqHz)
    rframe = li.getRefFrame(science_root, namespaces)
    sg = OT_dict[0]
    AOT = OT_dict[0]['AOT']
    sName = li.sourceName(science_root, namespaces, project_dict['SB_name'])
    #mosaic = li.mosaicBool(namespaces, XMLroots['proj_root'], sg['science_goal'])
    mosaic = li.mosaicBool(namespaces, XMLroots['science_root'], sName)
    if mosaic == 'true':
        pc = li.getPhasecenter(science_root, namespaces)
    else: 
        pc = 'N/A'

    # fill dictionary
    pc = li.getPhasecenter(science_root, namespaces)
    lastfield = scifld[scifld.rfind(' ')-1:]

    parameters = {'project_number': project_dict['project_number'],'SB_name': project_dict['SB_name'],'nms':nms, 'specinfo':specinfo,'mosaic': mosaic, 'scifields': scifld,'scifield0': scifld[0], 'scifield1': lastfield, 'cellsize': cell[0], 'imsize':cell[1], 'rframe':rframe, 'vwidth':vwidth[0], 'rwidth': vwidth[1], 'rwidthunit': vwidth[2], 'spw_dict': spwdict, 'rfreq':str(float(rfreqHz)*1e-9), 'plotcmd': '', 'sourceName': sName, 'phasecenter': pc, 'AOT': AOT}
    return parameters
コード例 #4
0
ファイル: mypre_imaging.py プロジェクト: elastufka/DR
def main(lbc=False): # will ask for the OT file twice ... fix that
    """For imaging: 
	    Asks the user to enter information about the project, downloads and untars data from pipetemp, runs ASDMExportLight and the pipeline, applies fixes to the piperestore script, copies the flagtemplate files over, gets the imaging script, untars the weblog, fills the readme, and generates the file imaging_parameters.txt
For manual reduction:
        Creates the directory tree, runs ASDMExportLight and generates calibration script, fills the readme, asks the user whether or not to run the script through once and generate weblog plots in a pdf
    """
    project_dict = pi.main()
    OTfile = OT_info.getAOT(project_number=project_dict['project_number']) 
    makeDirectories(project_dict)
    if project_dict['project_type'] == 'Imaging':
        untarStuff(project_dict)
        os.chdir('%s/sg_ouss_id/group_ouss_id/member_ouss_id/' % project_dict['project_path'])
        project_dict['casa_version'] = pi.casa_version()
        if project_dict['casa_version'] != '4.3.1':
            pipelineChanges()
        downloadASDM(project_dict,lbc=lbc)
        '''
        #input array is: ['project_type','asdm','lbc']
        input_array = []
        for asdm in project_dict['asdm']:
            input_array.append([project_dict['project_type'], asdm, lbc])
        pool_size = multiprocessing.cpu_count() * 4
        pool = multiprocessing.Pool(processes=pool_size, initializer=start_process,)
        pool_outputs= pool.map(downloadASDM_parallel, input_array)
        '''
        copyFiles(project_dict) #don't actually do this yet
        #project_dict['casa_version'] = pi.casa_version()
        runPipeline(project_dict)
        #getScript(project_dict) #don't need this if we're generating the script
        untarWeblog()
        OT_dict = fillReadme(project_dict, AOT=OTfile)
        #OT_dict = OT_info.getOTinfo(project_dict['SB_name'], AOTpath = OTfile) # just fill the dictionary instead....
        #li.main(project_dict=project_dict, OT_dict = OT_dict)
        generate_script(project_dict, OT_dict)
    else : 
        os.chdir('%s' % project_dict['project_path'])
        script_name = downloadASDM(project_dict)
        '''
        pool_size = multiprocessing.cpu_count() * 4
        pool = multiprocessing.Pool(processes=pool_size, initializer=start_process,)
        pool_outputs= pool.map(downloadASDM_parallel, project_dict[asdm], lbc=lbc)
        script_name=pool_outputs
        '''
        #getScript(project_dict)
        OT_dict = fillReadme(project_dict, AOT=OTfile)
        '''
	for asdm in project_dict['asdm']:
	    os.chdir('%s/Calibration_%s' % (project_dict['project_path'],str(asdm[asdm.rfind('X'):]).lstrip()))
	    ms_name = glob.glob('*.ms')
	    snr = subprocess.Popen(["casa", "-c", "au.gaincalSNR(\'%s\')" % ms_name[0]], shell=False,stdout=subprocess.PIPE, stderr=subprocess.STDOUT) #this doesn't work yet for some reason...
	    snr.wait()
            print 'The results of running au.gaincalSNR are in %s/gaincalSNR.txt' % os.getcwd()
	    gaincal = snr.communicate()
            if os.path.isfile('gaincalSNR.txt') == False:
                os.mknod('gaincalSNR.txt')
            text = open('gaincalSNR.txt','w')
            text.writelines(gaincal[0])
            text.close()
        '''
        #runscript = raw_input('Run calibration script through and check the visibilities by generating a pdf of the weblog plots? Warning - this will take a while and do it for all the asdms!')
        #os.chdir('../')
        #if runscript == 'Y':
        #     for asdm in project_dict['asdm']:
	#         os.chdir('%s/Calibration_%s' % (project_dict['project_path'],str(asdm[-4:])))
        #         script_name = glob.glob('*.py')
        #         script = open(script_name, 'rw+') # insert line mysteps = [] at beginning of script...
        #         steps = script.readlines()
        #         steps[1] = 'mysteps = []\n'
        #         script.writelines(steps)
        #         script.close() 
        #         subprocess.call(["casa", "-c", "'%s'" % script_name[0]])
        #         script = open(script_name, 'rw+') # remove line mysteps = [] 
        #         steps = script.readlines() 
        #         steps[1] = '\n'
        #         script.writelines(steps)
        #         script.close() 
                 
        #         subprocess.call(["casa", "-c", "/lustre/naasc/elastufk/Python/checkvispdf.py"]) # does this need the path?
        #os.chdir('../')
        print 'Make sure to run the script generator once your calibrated or combined ms is in the Imaging/ directory!'