def get_VLASS_images(position, radius, showgrid=False, savefile=''):

    cadc = Cadc()
    result = cadc.query_region(position, collection='VLASS')
    if len(result) == 0:
        print('No Data at CADC at position: {}'.format(
            position.to_string('hmsdms')))
    else:
        urls = cadc.get_data_urls(result)
        for url in urls:
            cutout_url = construct_cadc_url(url, position, radius)
            plot_http_fits(cutout_url, showgrid, savefile)
    def test_query_region(self):
        cadc = Cadc()
        result = cadc.query_region('08h45m07.5s +54d18m00s', collection='CFHT')
        # do some manipulation of the results. Below it's filtering out based
        # on target name but other manipulations are possible.
        assert len(result) > 0
        urls = cadc.get_data_urls(result[result['target_name'] == 'Nr3491_1'])
        assert len(urls) > 0
        # urls are a subset of the results that match target_name==Nr3491_1
        assert len(result) >= len(urls)
        urls_data_only = len(urls)
        # now get the auxilary files too
        urls = cadc.get_data_urls(result[result['target_name'] == 'Nr3491_1'],
                                  include_auxiliaries=True)
        assert urls_data_only <= len(urls)

        # the same result should be obtained by querying the entire region
        # and filtering out on the CFHT collection
        result2 = cadc.query_region('08h45m07.5s +54d18m00s')
        assert len(result) == len(result2[result2['collection'] == 'CFHT'])

        # search for a target
        results = cadc.query_region(SkyCoord.from_name('M31'), radius=0.016)
        assert len(results) > 20
示例#3
0
    def test_query_region(self):
        cadc = Cadc()
        result = cadc.query_region('08h45m07.5s +54d18m00s', collection='CFHT')
        # do some manipulation of the results. Below it's filtering out based
        # on target name but other manipulations are possible.
        assert len(result) > 0
        urls = cadc.get_data_urls(result[result['target_name'] == 'Nr3491_1'])
        assert len(urls) > 0
        # urls are a subset of the results that match target_name==Nr3491_1
        assert len(result) >= len(urls)
        urls_data_only = len(urls)
        # now get the auxilary files too
        urls = cadc.get_data_urls(result[result['target_name'] == 'Nr3491_1'],
                                  include_auxiliaries=True)
        assert urls_data_only <= len(urls)

        # the same result should be obtained by querying the entire region
        # and filtering out on the CFHT collection
        result2 = cadc.query_region('08h45m07.5s +54d18m00s')
        assert len(result) == len(result2[result2['collection'] == 'CFHT'])

        # search for a target
        results = cadc.query_region(SkyCoord.from_name('M31'))
        assert len(results) > 20
示例#4
0
parser.add_argument("dec",
                    help="DEC of the source in +00d00m00.00s format",
                    type=str)
parser.add_argument("radius",
                    help="radius around ra dec center",
                    type=str,
                    default="3 arcmin")
args = parser.parse_args()

ra = args.ra
dec = args.dec
radius = args.radius

cadc = Cadc()
coords = ra + " " + dec
results = cadc.query_region(coords, radius, collection='VLASS')
image_list = cadc.get_image_list(results, coords, radius)

if (len(image_list) > 1):
    print("The coordinates entered are present in more than one field!")
    for i in range(len(image_list)):
        print(i, " : ", image_list[i])
    field_id = input("Enter field you would like to download : ")
    field_id = int(field_id)
    sel_image = image_list[field_id]
    filename = sel_image.split("/")[-1].split("&")[0][21:]
    print(filename)
    print("Downloading VLASS image : ", filename)
    urlretrieve(sel_image, filename)
else:
    sel_image = image_list[0]
示例#5
0
##--------------------------------------------------------------------------##

for nn, tinfo in enumerate(targets, 1):
    targ, tname = tinfo
    sys.stderr.write("%s\n" % fulldiv)
    sys.stderr.write("Target %d of %d: %s\n" % (nn, len(targets), tname))

    # ensure output folder exists:
    save_dir = os.path.join(context.output_dir, tname)
    if not os.path.isdir(save_dir):
        os.mkdir(save_dir)

    # retrieve query results
    sys.stderr.write("Querying CFHT database ... ")
    #hits = cadc.query(coord=targ, size=context.search_rad_deg, dataset=1)
    hits = cadc.query_region(targ, radius=srch_deg, collection='CFHT')
    hits.sort('productID')
    sys.stderr.write("done.\n")

    # select useful subset:
    sys.stderr.write("Selecting useful subset ... ")
    useful = pick_favorites(hits)
    useful['ibase'] = ['%s.fits.fz' % x for x in useful['productID']]
    useful['isave'] = [os.path.join(save_dir, x) for x in useful['ibase']]
    sys.stderr.write("done. Identified %d images.\n" % len(useful))

    # exclude images already retrieved:
    already_have = np.array([os.path.isfile(x) for x in useful['isave']])
    nfound = np.sum(already_have)
    sys.stderr.write("Excluding %d already-retrieved images.\n" % nfound)
    useful = useful[~already_have]