Exemple #1
0
 def make_airmass_model(self):
     print "### start to calibrate the inst mag with apparent mag in catalog I/329"
     filter_ = self.filter_
     if filter_ != 'V' and filter_ != 'B' and filter_ != 'R':
         print "This photometry doesn't this filter."
         return 1
     # Choose the 10 brightest stars
     self.index_INST_MAG = TAT_env.obs_data_titles.index('INST_MAG')
     self.index_E_INST_MAG = TAT_env.obs_data_titles.index('E_INST_MAG')
     inst_mag_array = np.array(self.stars[:,self.index_INST_MAG], dtype = float)
     mag_order_stars = self.stars[inst_mag_array.argsort()]
     print ('The number of sources: {0}'.format(len(mag_order_stars)))
     picking = np.arange(10)
     mag_order_stars = mag_order_stars[picking] 
     mag_delta_list = []
     for star in mag_order_stars: 
         #-------------------------------------------------
         # Find the info of the source from catalog I/329
         index_RA = TAT_env.obs_data_titles.index('RA')
         index_DEC = TAT_env.obs_data_titles.index('`DEC`')
         RA = float(star[index_RA])
         DEC = float(star[index_DEC])
         failure, match_stars = get_catalog(RA, DEC, TAT_env.URAT_1, TAT_env.index_URAT_1) 
         if failure:
             continue
         # Find the apparent magnitude to the found source
         failure, app_mag = get_app_mag(match_stars, filter_)
         if failure:
             continue
         inst_mag = float(star[self.index_INST_MAG])
         mag_delta = app_mag - inst_mag
         print "INST_MAG = {0}, CATA_MAG = {1}, delta = {2}".format(inst_mag, app_mag, mag_delta)
         mag_delta_list.append(mag_delta)
     # Check if the number of source is enough or not.
     if len(mag_delta_list) == 0:
         print "No enough source found in catalogue for comparison"
         return 1
     mag_delta_list = get_rid_of_exotic(mag_delta_list)
     if len(mag_delta_list) < 3:
         print "No enough source found in catalogue for comparison"
         return 1
     # remove np.nan
     mag_delta_array = np.array(mag_delta_list)
     mag_delta_array = mag_delta_array[~np.isnan(mag_delta_array)]
     # Find the median of the delta of the magnitude, and apply the result on all sources.
     self.median_mag_delta = np.median(mag_delta_array)
     return 0
def show_cata_mag(mag, ra, dec, VERBOSE=1):
    # Load the index of columes
    reduce_data = np.transpose(np.array([mag, ra, dec], dtype=float))
    reduce_data = reduce_data[mag.argsort()]
    reduce_data = reduce_data[~np.isnan(reduce_data[:, 0])]
    # Pick 50 brightest stars from the data
    reduce_data = reduce_data[:20]
    world = reduce_data[:, 1:]
    #--------------------------------------------------
    # Find the catalog magnitude.
    # Query data from vizier
    mag_delta_list = []
    filter_ = 'V'
    for i in xrange(len(reduce_data)):
        inst_mag = reduce_data[i, 0]
        RA = float(world[i, 0])
        DEC = float(world[i, 1])
        failure, match_star = get_catalog(RA, DEC, TAT_env.URAT_1,
                                          TAT_env.index_URAT_1)
        if failure:
            continue
        failure, app_mag = get_app_mag(match_star, filter_)
        if failure:
            continue
        if np.isnan(inst_mag):
            continue
        mag_delta = app_mag - inst_mag
        if VERBOSE == 1:
            print "INST_MAG = {0}, CATA_MAG = {1}, delta = {2}".format(
                inst_mag, app_mag, mag_delta)
        mag_delta_list.append(mag_delta)
    # Find the average of delta_mag
    # Check if the number of source is enough or not.
    if len(mag_delta_list) == 0:
        print "No enough source found in catalogue for comparison"
        return 1
    mag_delta_list = get_rid_of_exotic(mag_delta_list)
    if len(mag_delta_list) < 3:
        print "No enough source found in catalogue for comparison"
        return 1
    # remove np.nan
    mag_delta_array = np.array(mag_delta_list)
    mag_delta_array = mag_delta_array[~np.isnan(mag_delta_array)]
    # Find the median of the delta of the magnitude, and apply the result on all sources.
    median_mag_delta = np.median(mag_delta_array)
    app_mag = mag + median_mag_delta
    return 0, app_mag
Exemple #3
0
def show_mini_mag(se_table, VERBOSE=0):
    # Load the index of columes
    index_mag = TAT_env.SE_table_titles.index('MAG_AUTO')
    index_x = TAT_env.SE_table_titles.index('X_IMAGE')
    index_y = TAT_env.SE_table_titles.index('Y_IMAGE')
    # Take the minimum magnitude in INST_MAG
    mag = se_table[:, index_mag]
    mini_mag = np.amax(mag)
    if VERBOSE > 0: print 'instrumental minimum mag: {0}'.format(mini_mag)
    xcenter = se_table[:, index_x]
    ycenter = se_table[:, index_y]
    reduce_data = np.transpose(np.array([mag, xcenter, ycenter]))
    reduce_data = reduce_data[mag.argsort()]
    # Pick 10 brightest stars from the data
    reduce_data = reduce_data[:50]
    pixcrd = reduce_data[:, 1:]
    try:
        header_wcs = pyfits.getheader("stacked_image.wcs")
    except:
        print "WCS not found"
        return 1, None
    w = wcs.WCS(header_wcs)
    world = w.wcs_pix2world(pixcrd, 1)
    #--------------------------------------------------
    # Find the catalog magnitude.
    # Query data from vizier
    mag_delta_list = []
    filter_ = 'V'
    for i in xrange(len(reduce_data)):
        inst_mag = reduce_data[i, 0]
        RA = float(world[i, 0])
        DEC = float(world[i, 1])
        failure, match_star = get_catalog(RA, DEC, TAT_env.URAT_1,
                                          TAT_env.index_URAT_1)
        if failure:
            continue
        failure, app_mag = get_app_mag(match_star, filter_)
        if failure:
            continue
        mag_delta = app_mag - inst_mag
        if VERBOSE == 1:
            print "INST_MAG = {0}, CATA_MAG = {1}, delta = {2}".format(
                inst_mag, app_mag, mag_delta)
        mag_delta_list.append(mag_delta)
    # Find the average of delta_mag
    # Check if the number of source is enough or not.
    if len(mag_delta_list) == 0:
        print "No enough source found in catalogue for comparison"
        return 1
    mag_delta_list = get_rid_of_exotic(mag_delta_list)
    if len(mag_delta_list) < 3:
        print "No enough source found in catalogue for comparison"
        return 1
    # remove np.nan
    mag_delta_array = np.array(mag_delta_list)
    mag_delta_array = mag_delta_array[~np.isnan(mag_delta_array)]
    # Find the median of the delta of the magnitude, and apply the result on all sources.
    median_mag_delta = np.median(mag_delta_array)
    app_mag = mag + median_mag_delta
    app_mini_mag = mini_mag + median_mag_delta
    return 0, app_mag, app_mini_mag