예제 #1
0
def __prerequisites():
    """
    Fetch the basic proposal data depending on the CYCLE_ID
    This is basically stage0
    :return:
    """
    CYCLE_ID = Pipeline().pipeline_configuration()["cycle_id"]
    CYCLE_PATH = Pipeline().pipeline_configuration()["cycle_path"]
    CYCLE_ID = str(CYCLE_ID)

    sql_query = "select distinct o.observation_no, p.proposal_id, g.file_path, p.backend_type from " \
                "gmrt.proposal p inner join das.observation o on p.proposal_id = o.proj_code " \
                "inner join das.scangroup g on g.observation_no = o.observation_no " \
                "inner join das.scans s on s.scangroup_id = g.scangroup_id " \
                "inner join gmrt.sourceobservationtype so on p.proposal_id = so.proposal_id " \
                "where p.cycle_id ='" + CYCLE_ID + "' " \
                                                   "and so.obs_type not like 'pulsar%' " \
                                                   "and so.obs_type not like 'phased array'" \
                                                   "and s.sky_freq1=s.sky_freq2 " \
                                                   "and s.sky_freq1 < 900000000 " \
                                                   "and s.chan_width >= 62500 " \
                                                   "and o.proj_code not like '16_279' " \
                                                   "and o.proj_code not like '17_072' " \
                                                   "and o.proj_code not like '18_031' " \
                                                   "and o.proj_code not like '19_043' " \
                                                   "and o.proj_code not like '20_083' " \
                                                   "and o.proj_code not like '21_057';"

    dbutils = DBUtils()

    data = dbutils.select_query(sql_query)
    gadpudata = {}
    for each_row in data:
        gadpudata[each_row[0]] = {
            "proposal_id": each_row[1],
            "file_path": each_row[2],
            "backend_type": each_row[3],
            "cycle_id": CYCLE_ID
        }
    return (gadpudata, CYCLE_PATH)
예제 #2
0
    def __prerequisites_ghb(self):
        CYCLE_ID = 15
        CYCLE_PATH = '/GARUDATA/IMAGING15/CYCLE15/'
        CYCLE_ID = str(CYCLE_ID)

        sql_query = "select distinct o.observation_no, p.proposal_id, g.file_path, p.backend_type from " \
                    "gmrt.proposal p inner join das.observation o on p.proposal_id = o.proj_code " \
                    "inner join das.scangroup g on g.observation_no = o.observation_no " \
                    "inner join das.scans s on s.scangroup_id = g.scangroup_id " \
                    "inner join gmrt.sourceobservationtype so on p.proposal_id = so.proposal_id " \
                    "where p.cycle_id ='" + CYCLE_ID + "' " \
                                                       "and so.obs_type not like 'pulsar%' " \
                                                       "and so.obs_type not like 'phased array'" \
                                                       "and s.sky_freq1=s.sky_freq2 " \
                                                       "and s.sky_freq1 < 900000000 " \
                                                       "and s.chan_width >= 62500 " \
                                                       "and o.proj_code not like '16_279' " \
                                                       "and o.proj_code not like '17_072' " \
                                                       "and o.proj_code not like '18_031' " \
                                                       "and o.proj_code not like '19_043' " \
                                                       "and o.proj_code not like '20_083' " \
                                                       "and o.proj_code not like '23_066' " \
                                                       "and o.proj_code not like '26_063' " \
                                                       "and o.proj_code not like 'ddtB014' " \
                                                       "and o.proj_code not like 'ddtB015' " \
                                                       "and o.proj_code not like 'ddtB028' " \
                                                       "and o.proj_code not like '21_057';"
        dbutils = DBUtils()
        data = dbutils.select_query(sql_query)
        gadpudata = {}
        for each_row in data:
            gadpudata[each_row[0]] = {
                "proposal_id": each_row[1],
                "file_path": each_row[2],
                "backend_type": each_row[3],
                "cycle_id": CYCLE_ID
            }
        return (gadpudata, CYCLE_PATH)
예제 #3
0

jpeg_images_path = '/GARUDATA/jpeg_images/'

data = dbutils.select_gadpu_query(sql_query)
counter=0
for each_row in data:
    counter+=1
    base_path = each_row[0]
    observation_no = each_row[1]
    jpeg_img_file = each_row[2].replace('.FITS','.jpeg')
    source_name = jpeg_img_file.split('.')[0]
    jpeg_img_path = base_path+'/FITS_IMAGE/'+jpeg_img_file
    if os.path.exists(jpeg_img_path):
        sql_query = "select distinct scan_id, observation_no, source from das.scans where observation_no = "+str(observation_no)+" and  source like '"+source_name+"'"
        scans_data = dbutils.select_query(sql_query)
        # print(int(observation_no), source_name, jpeg_img_path)
        if scans_data:
            cycle_dir = base_path.split('/')[3]
            images_path = jpeg_images_path+cycle_dir+'/'+str(observation_no)
            if not os.path.exists(images_path):
                os.system("mkdir -p "+images_path)
            copying = os.system("cp "+jpeg_img_path+" "+images_path+"/")
            for each_scan in scans_data:
                scan_id = each_scan[0]
                scans_update_data = {
                    "set": {
                        "jpeg_img_path": str(images_path+'/'+jpeg_img_file).replace('GARUDATA','data')
                    },
                    "where": {
                        "scan_id": int(scan_id)