def main(SB_name = False, project_path = False): 
    if project_path == False:
        project_path = os.getcwd()
    dictionaries = project_info.most_info(SBname = SB_name, project_path = project_path)
    OT_dict = dictionaries[1]
    project_dict = dictionaries[0]
    #readme_info = fill_README.getInfo(dictionaries[0], OT_dict)
    XMLroots=OT_dict[1]
    science_root = XMLroots['science_root']
    namespaces = XMLroots['namespaces']

    nms = getnum_ms(project_dict['project_type'],project_dict['project_path'])
    #IPython.embed()
    listobs = getListobs()
    line = listobs[0]
    index = listobs[1]
    nspws = getNspw(line, index)
    cell = getCell(line)
    scifld = getScienceFields(line, index)
    specinfo = getLines(index, int(nspws[0]))
    spwinfo = getSpwInfo(science_root, namespaces, nspws[1])
    rfreqHz = getRestFreq(science_root, namespaces)
    vwidth = getVelWidth(science_root, namespaces, rfreqHz=rfreqHz)
    rframe = getRefFrame(science_root, namespaces)
    #plotcmd = genPlotMS(spwinfo, rframe)
    plotcmd = ''
    sg = OT_dict[0]
    sName = sourceName(science_root, namespaces, project_dict['SB_name'])
    mbool = mosaicBool(namespaces, science_root, sName)
    mosaic = ismosaic(mbool, scifld[0], scifld[scifld.rfind(' ')-1:])
    if mbool == 'true':
        pc = getPhasecenter(science_root, namespaces)
    else: 
        pc = 'N/A'
    # get stuff from readme
    readme_dict = fill_README.getInfo(dictionaries[0], OT_dict)

    # fill dictionary
    parameters = {'project_number': project_dict['project_number'],'SB_name': project_dict['SB_name'],'PI_name': readme_dict['PI_name'],'title': readme_dict['title'],'nms':nms, 'specinfo':specinfo,'mosaic': mosaic[0], 'pointings': mosaic[1], 'scifields': scifld, 'scifield0': scifld[0], 'scifield1': scifld[scifld.rfind(' ')-1:], 'cellsize': cell[0], 'imsize':cell[1], 'rframe':rframe,  'vwidth':vwidth[0], 'rwidth': vwidth[1], 'rwidthunit': vwidth[2], 'spw_dict': spwinfo, 'plotcmd': plotcmd, 'rms': readme_dict['rms'], 'rms_unit': readme_dict['rms_unit'], 'rfreq':str(float(rfreqHz)*1e-9), 'phasecenter': pc}
    param = openFile()
    info = fillInfo(parameters) #! re-work this one too
    writeText(param, info)
    print 'The file imaging_parameters.txt is now in %s' % os.getcwd()
    # remove temp files
    fill_README.cleanup(OT_dict[0]['tempdir'])   
예제 #2
0
def generate(SB_name, project_path = False, comments = True, template=False, split=True): #template to get template, split for generating 2 scripts instead of 1
    """Main method. Options are: project_path ='directory_where_project_lives', comments=True/False ie verbose or non-verbose, template = True/False, split = True/False ie two scripts or one"""
    if (SB_name == 'Template' or SB_name == 'template'):
        template = True
    if project_path == False:
        project_path = os.getcwd()    
    if template == True:
        parameters = template_parameters()
        project_dict = {'project_path': project_path, 'project_type': 'Imaging', 'casa_version': '4.4.0'}
        flagchannels = '2:1201~2199,3:1201~2199' #whatever is in the example
        print 'this option not completely ready yet!'
    else:
        dictionaries = pi.most_info(SB_name, project_path=project_path)     
        project_dict = dictionaries[0]
        OT_dict = dictionaries[1]
        os.chdir(project_path)
        flagchannels=False
        parameters = get_parameters(project_dict = project_dict, OT_dict = OT_dict) #skip up to here
        #print parameters['vwidth']
    script = script_data_prep(parameters, project_dict, comments, template) 
    if split == True:
        prep_script = script
        script = ''
        #print prep_script
    spws = sort_spws(parameters) #skip this?
    continfo = spws[0] #and this
    lineinfo = spws[1] #and this
    linespws = spws[2] # and this ... but check first
    script = make_continuum(script,parameters, project_dict, continfo, comments, template, flagchannels)
    script = image_setup(script,parameters, comments, template) 
    script = cont_image(script,parameters, comments, template) 
    if lineinfo != []:
        script = contsub(script,parameters, continfo, linespws, comments)
        script = line_image(script,parameters, lineinfo, comments)
        print parameters['vwidth']
    script = pbcor_fits(script)
    if split == True:
       write_script(prep_script,project_dict, template, filename = 'scriptForImaging_Prep.py')
       write_script(script,project_dict, template, filename = 'scriptForImaging.py')
    else:
        write_script(script,project_dict, template) #, filename = 'scriptForImaging_test.py') #diff filename for template
    # cleanup temp files
    if template == False:
        OT_info.cleanup(parameters['AOT']) # don't need this for template
예제 #3
0
def generate(SB_name, project_path = False, comments = True):
    if project_path == False:
        project_path = os.getcwd()    
    dictionaries = pi.most_info(SB_name, project_path=project_path)    
    project_dict = dictionaries[0]
    OT_dict = dictionaries[1]
    os.chdir(project_path)
    parameters = get_parameters(project_dict = project_dict, OT_dict = OT_dict) 
    script = script_data_prep(parameters, project_dict, comments)
    spws = sort_spws(parameters)
    continfo = spws[0]
    lineinfo = spws[1]
    linespws = spws[2]
    script = make_continuum(script,parameters, project_dict, continfo, comments, flagchannels=False)
    script = image_setup(script,parameters, comments)
    script = cont_image(script,parameters, comments)
    if lineinfo != []:
        script = contsub(script,parameters, continfo, linespws, comments)
        script = line_image(script,parameters, lineinfo, comments)
    script = pbcor_fits(script)
    write_script(script,project_dict, filename = 'scriptForImaging_test.py')
    # cleanup temp files
    OT_info.cleanup(parameters['AOT'])