예제 #1
0
def find_objects_by_phot(family_name, aperture, thresh, imagetype):
    """
    For a given family name and object name, preforms photometry and identifies object in the image.
    If only a family name is given, does the same for all objects in that family
    """

    # get CADC authentification
    username = raw_input("CADC username: "******"CADC password: "******"\n {} --- Searching for asteroid {} in image {} ".format(row, table['Object'][row], table['Image'][row])

        expnum = (table['Image'][row]).strip('{}'.format(imagetype))
        if expnum in tkbad_list:
            print '-- Bad exposure'

        else:
            postage_stamp_filename = "{}_{}_{:8f}_{:8f}.fits".format(table['Object'][row], table['Image'][row],
                                                                     table['RA'][row], table['DEC'][row])

            if not storage.exists('{}/{}'.format(vos_dir, postage_stamp_filename)):
                print '-- Cutout not found, creating new cutout'
                get_stamps.cutout(username, password, family_name, table['Object'][row], table['Image'][row],
                                  table['RA'][row], table['DEC'][row], _RADIUS)
            if not storage.exists('{}/{}'.format(vos_dir, postage_stamp_filename)):
                with open('{}/{}/{}'.format(_OUTPUT_DIR, family_name, _OUTPUT_VOS_ERR), 'a') as outfile:
                    outfile.write('{} {}\n'.format(table['Object'][row], table['Image'][row]))
            else:
                success = False
                attempts = 0
                while (success is False) and (attempts < 3):
                    success = iterate_thru_images(family_name, str(table['Object'][row]), table['Image'][row], username,
                                                  password, aperture, thresh)
                    attempts += 1
                    if attempts == 3:
                        print ' >>>> Last attempt \n'
예제 #2
0
def main():
    parser = argparse.ArgumentParser(
        description='For a given set of fits images: preforms photometry, identifies a specific object, and returns \
                        the orbital elements of the object')
    parser.add_argument("--family", '-f',
                        action="store",
                        default='all',
                        help="Asteroid family name. Usually the asteroid number of the largest member.")
    parser.add_argument("--aperture", '-ap',
                        action='store',
                        default=10.0,
                        help='aperture (degree) of circle for photometry.')
    parser.add_argument("--thresh", '-t',
                        action='store',
                        default=3.,
                        help='threshold value for photometry (sigma above background).')
    parser.add_argument("--object", '-o',
                        action='store',
                        default=None,
                        help='The object to be identified.')
    parser.add_argument("--expnum", '-x',
                        action='store',
                        default=None,
                        help='The exposure that the object is in.')
    parser.add_argument('--type',
                        default='p',
                        choices=['o', 'p', 's'],
                        help="restrict type of image (unprocessed, reduced, calibrated)")

    args = parser.parse_args()

    if args.object is None:
        find_objects_by_phot(args.family, float(args.aperture), float(args.thresh), args.type)
    else:
        assert args.expnum.endswith('p') or args.expnum.endswith('o'), "Must include 'p' or 'o' in expnum"
        image_list_path = '{}/{}_{}'.format(_IMAGE_LISTS, args.family, _INPUT_FILE)
        table = pd.read_table(image_list_path, sep='\t', dtype={'Object': object, 'Image': object}, index_col=False)
        lines = table[(table.Object == args.object) & (table.Image == args.expnum)]
        print lines
        username = raw_input("CADC username: "******"CADC password: "******"{}_{}_{:8f}_{:8f}.fits".format(args.object, args.expnum, float(lines.RA.values[0]),
                                                                 float(lines.DEC.values[0]))
        if not storage.exists('{}/all/{}'.format(_VOS_DIR, postage_stamp_filename)):
            print '-- Cutout not found, creating new cutout'
            get_stamps.cutout(username, password, args.family, args.object, args.expnum, lines.RA.values[0],
                              lines.DEC.values[0], _RADIUS)
        assert storage.exists('{}/all/{}'.format(_VOS_DIR, postage_stamp_filename)), 'Error: Cutout not found'
        iterate_thru_images(args.family, args.object, args.expnum, username, password, float(args.aperture),
                            float(args.thresh))