0 votes

Thank you very much for the quick reply. However, this does not seem to work. The code in the new notebook appears identical to the old one. The code snippet below fails to produce a cutout:

from pyvo.dal import sia
import numpy as np
DEF_ACCESS_URL = "https://datalab.noao.edu/sia/des_dr1"
svc = sia.SIAService(DEF_ACCESS_URL)
def download_deepest_images(ra,dec,fov=0.01,bands=list('gri')):
    imgTable = svc.search((ra,dec), (fov/np.cos(dec*np.pi/180), fov), verbosity=2).to_table() #.votable #.get_first_table()
    print("The full image list contains {:d} entries.".format(len(imgTable)))
    sel0 = (imgTable['proctype'] == b'Stack') & (imgTable['prodtype']==b'image') # basic selection
    images = []
    for band in bands:
        print("Band {:s}: ".format(band), end='')
        sel = sel0 & (imgTable['obs_bandpass'] == band.encode()) # add 'band' to selection
        Table = imgTable[sel] # select
        row = Table[np.argmax(Table['exptime'].data.data.astype('float'))] # pick image with longest exposure time
        url = row['access_url'] # get the download URL
        print('downloading deepest stacked image...')
        img = io.fits.getdata(utils.data.download_file(url.decode(),cache=True,show_progress=False,timeout=120)) # .decode() b/c in Python 3 url is of "byte" type and getdata() expects "string" type
    print("Downloaded {:d} images.".format(len(images)))
    return images
img = download_deepest_images(ra,dec,fov=0.01,bands=['r'])

asked Aug 16 by cerusu (170 points) | 23 views

1 Answer

+1 vote
Best answer
Hi again, this should work now, we (aka Mike) fixed a bug on our end. Please give it another try.
Thank you very much for taking the time to report the issue.
Best regards,
Robert for the DL team
answered Aug 17 by datalab (9,120 points)
selected Aug 18 by cerusu

198 questions

195 answers


1,364 users

Welcome to Data Lab Help Desk, where you can ask questions and receive answers from other members of the community.