Skip to content

Instantly share code, notes, and snippets.

@MatthewJA
Created September 27, 2017 07:51
Show Gist options
  • Save MatthewJA/f563746f6c85a368a26baafcec6cf3a0 to your computer and use it in GitHub Desktop.
Save MatthewJA/f563746f6c85a368a26baafcec6cf3a0 to your computer and use it in GitHub Desktop.
Get FIRST cutouts.
import io
import warnings
import requests
def get_first(coord: 'SkyCoord', size: 'arcmin'=5) -> 'FITS image':
data = {
'RA': coord.to_string(style='hmsdms', sep=' '),
'Dec': '',
'Equinox': 'J2000',
'ImageSize': size,
'ImageType': 'FITS Image',
'MaxInt': 10,
'Epochs': '',
'Fieldname': '',
'.submit': 'Extract the Cutout ',
'.cgifields': 'ImageType',
}
url = 'https://third.ucllnl.org/cgi-bin/firstcutout'
with warnings.catch_warnings():
warnings.simplefilter("ignore")
# This is insecure - prefer verifying if you've got the certs.
response = requests.post(url, data=data, stream=False, verify=False)
if response.text.startswith('<PRE>'):
# Location not in FIRST.
return
return astropy.io.fits.open(io.BytesIO(response.content))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment