Example #1
0
def script_data_prep(parameters, project_dict, comments, template):
    """Write the data prepration portion of the script ie scriptForImaging_Prep.py contents"""
    # some short commands we'll need:
    singleex = "concatvis = vislist[0]\n"
    multipleex = "concatvis='calibrated.ms'\n"
    vishead = "vishead(vis=concatvis)\n"

    template_comments = ["#>>> If you haven't regridded:\n","#>>> If you have regridded:\n"]
    noregrid = "os.system('mv -i ' + sourcevis + ' ' + 'calibrated_final.ms')\n"
    regrid = "os.system('mv -i ' + regridvis + ' ' + 'calibrated_final.ms')\n\n"

    backup = "# At this point you should create a backup of your final data set in\n\
# case the ms you are working with gets corrupted by clean.\n\n\
os.system('cp -ir calibrated_final.ms calibrated_final.ms.backup')\n\n"

    if comments == False:
        script = com.header_brief() + sc.check_casa() + com.glob_list() + sc.get_vislist(project_dict) + sc.flag_bad_data()
    elif template == False:
        script = com.header() + sc.check_casa() + com.glob_list()  + sc.get_vislist(project_dict)+ sc.flag_bad_data()
    else: 
        script = com.header() + sc.check_casa_default() + com.glob_list()  + sc.get_vislist(project_dict)+ sc.flag_bad_data()

    if parameters['mosaic'] == 'true': # remove pointing tables if mosaic
        script = script + com.pointing() + sc.pointing_table()

    # to concat or not concat?
    if (project_dict['project_type'] == 'Imaging' and parameters['nms'] > 1 or template == True):
        if template == True:
            script = script + com.combine() + com.combine_warning() + sc.concat_setup() +com.split() + com.split_single() + singleex + com.split_multiple()+ multipleex + vishead + com.vishead() + sc.split_science() + com.check_split() + sc.checksplit() + com.regrid() + sc.regrid()
        elif comments == False: 
            script = script + com.combine_header() + sc.concat_setup() +com.split()  + multipleex + vishead + sc.split_science() + sc.checksplit() 
        else:
            script = script + com.combine() + com.combine_warning() + sc.concat_setup() +com.split() +  multipleex + vishead + com.vishead() + sc.split_science() + com.check_split() + sc.checksplit() 
    elif project_dict['project_type'] == 'Manual':
        os.chdir(project_dict['project_path'])
        os.chdir('Imaging')
        if  os.path.isdir('calibrated.ms') == True: # need concatvis = 'calibrated.ms' but no split
            if comments == False: 
                script = script + com.split() + multipleex + vishead + sc.split_science() + sc.checksplit() 
            else:
                script = script + com.split()+ multipleex + vishead + com.vishead() + sc.split_science() + com.check_split() + sc.checksplit() 
        else:
            if comments == False:
                script = script + com.split() + singleex + vishead + sc.split_science() + sc.checksplit() 
            else:
                script = script + com.split() + singleex + vishead + com.vishead() + sc.split_science() + com.check_split() + sc.checksplit() 
        os.chdir('../')
    else:
        if comments == False:
            script = script + com.split() + singleex + vishead + sc.split_science() + sc.checksplit() 
        else:
             script = script + com.split() + singleex + vishead + com.vishead() + sc.split_science() + com.check_split() + sc.checksplit() 

    if template == True:
        script = script + com.backup() + template_comments[0] + noregrid + template_comments[1] + regrid+ backup
    else:
        #if you need to regrid your velocities... build this in later
        script = script + com.backup() + noregrid + backup
    return script
def script_data_prep(parameters, project_dict, comments):

    # some short commands we'll need:
    singleex = "concatvis = vislist[0]\n"
    multipleex = "concatvis='calibrated.ms'\n"
    vishead = "vishead(vis=concatvis)\n"

    noregrid = "os.system('mv -i ' + sourcevis + ' ' + 'calibrated_final.ms')\n"
    regrid = "os.system('mv -i ' + regridvis + ' ' + 'calibrated_final.ms')\n"

    backup = "os.system('cp -ir calibrated_final.ms calibrated_final.ms.backup')\n\n"

    if comments == False:
        script = com.header_brief() + sc.check_casa(project_dict) + com.glob_list() + sc.get_vislist(project_dict)
    else:
        script = com.header() + sc.check_casa(project_dict) + com.glob_list()  + sc.get_vislist(project_dict)

    if parameters['mosaic'] == 'true': # remove pointing tables if mosaic
        script = script + com.pointing() + sc.pointing_table()

    # to concat or not concat?
    if parameters['nms'] > 1:
        if comments == False: 
            script = script + com.combine_header() + sc.concat_setup() +com.split()  + multipleex + vishead + sc.split_science() + sc.checksplit() 
        else:
            script = script + com.combine() + sc.concat_setup() +com.split() +  multipleex + vishead + com.vishead() + sc.split_science() + com.check_split() + sc.checksplit() 
  
    os.chdir(project_dict['project_path'])
    if project_dict['project_type'] == 'Manual':
        os.chdir('Imaging')
        if  os.path.isdir('calibrated.ms') == True: # need concatvis = 'calibrated.ms' but no split
            if comments == False: 
                script = script + com.split() + multipleex + vishead + sc.split_science() + sc.checksplit() 
            else:
                script = script + com.split()+ multipleex + vishead + com.vishead() + sc.split_science() + com.check_split() + sc.checksplit() 
        os.chdir('../')

    else: # you only have one EB!
        if comments == False:
            script = script + com.split() + singleex + vishead + sc.split_science() + sc.checksplit() 
        else:
             script = script + com.split() + singleex + vishead + com.vishead() + sc.split_science() + com.check_split() + sc.checksplit() 
  
    #if you need to regrid your velocities... build this in later

    script = script + com.backup() + noregrid + backup
    return script