Created
September 27, 2017 07:51
-
-
Save MatthewJA/f563746f6c85a368a26baafcec6cf3a0 to your computer and use it in GitHub Desktop.
Get FIRST cutouts.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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