Download Digitized Sky Survey images

    https://archive.stsci.edu/cgi-bin/dss_form    
    https://archive.stsci.edu/cgi-bin/dss_search

    Image is in celestial orientation (RA increases to the right)
    https://archive.stsci.edu/dss/script_usage.html

    ra (r) - right ascension
    dec (d) - declination
    equinox (e) - equinox (B1950 or J2000; default: J2000)
    height (h) - height of image (arcminutes; default: 15.0)
    width (w) - width of image (arcminutes; default: 15.0)
    format (f) - image format (FITS or GIF; default: FITS)
    compression (c) - compression (UNIX, GZIP, or NONE; default: NONE; compression 
         applies to FITS only)
    version (v)  - Which version of the survey to use:
         1  - First Generation survey (garden variety)
         2  - Second generation survey (incomplete)
         3  - Check the 2nd generation; if no image is available,
              then go to the 1st generation.
         4  - The Quick V survey (whence came the Guide Stars Catalog;
              used mostly for Phase II proposal submission)
    save (s)  - Save the file to disk instead of trying to display.
         (ON (or anything) or not defined; default: not defined.)

    For the skyview service, see:
    https://skyview.gsfc.nasa.gov/current/docs/batchpage.html

def getDSSImage(ra,dec,radius=1.0,xsize=800,**kwargs):
    """
    Download Digitized Sky Survey images

    https://archive.stsci.edu/cgi-bin/dss_form    
    https://archive.stsci.edu/cgi-bin/dss_search

    Image is in celestial orientation (RA increases to the right)
    https://archive.stsci.edu/dss/script_usage.html

    ra (r) - right ascension
    dec (d) - declination
    equinox (e) - equinox (B1950 or J2000; default: J2000)
    height (h) - height of image (arcminutes; default: 15.0)
    width (w) - width of image (arcminutes; default: 15.0)
    format (f) - image format (FITS or GIF; default: FITS)
    compression (c) - compression (UNIX, GZIP, or NONE; default: NONE; compression 
         applies to FITS only)
    version (v)  - Which version of the survey to use:
         1  - First Generation survey (garden variety)
         2  - Second generation survey (incomplete)
         3  - Check the 2nd generation; if no image is available,
              then go to the 1st generation.
         4  - The Quick V survey (whence came the Guide Stars Catalog;
              used mostly for Phase II proposal submission)
    save (s)  - Save the file to disk instead of trying to display.
         (ON (or anything) or not defined; default: not defined.)

    For the skyview service, see:
    https://skyview.gsfc.nasa.gov/current/docs/batchpage.html
    """
    import subprocess
    import tempfile
    service = 'skyview'

    if service == 'stsci':
        url="https://archive.stsci.edu/cgi-bin/dss_search?"
        scale = 2.0 * radius * 60.
        params=dict(ra='%.3f'%ra,dec='%.3f'%dec,width=scale,height=scale,
                    format='gif',version=1)
        #v='poss2ukstu_red'
    elif service == 'skyview':
        url="https://skyview.gsfc.nasa.gov/cgi-bin/images?"
        params=dict(survey='DSS',position='%.3f,%.3f'%(ra,dec),scaling='Linear',
                    Return='GIF',size=2*radius,projection='Car',pixels=xsize)
    else:
        raise Exception("Unrecognized service.")

    query='&'.join("%s=%s"%(k,v) for k,v in params.items())
    
    tmp = tempfile.NamedTemporaryFile(suffix='.gif')
    cmd='wget --progress=dot:mega -O %s "%s"'%(tmp.name,url+query)
    subprocess.call(cmd,shell=True)
    im = plt.imread(tmp.name)
    tmp.close()
    if service == 'stsci' and xsize: 
        im = scipy.misc.imresize(im,size=(xsize,xsize))
    return im