Exemplo n.º 1
0
 def __init__(self, coord, radius, mission, **kwargs):
     surveycoord.SurveyCoord.__init__(self, coord, radius, **kwargs)
     #
     self.survey = None
     self.mission = mission
     # Instantiate astroquery object
     self.skyview = SkyView()
Exemplo n.º 2
0
    def _get_skyview_cutout(self):
        """Fetch cutout data via SkyView API."""

        sv = SkyView()
        path = cutout_cache + self.survey + '/{:.3f}arcmin_{:.3f}_{:.3f}.fits'
        path = path.format(self.radius * 60, self.ra, self.dec)
        progress = self.kwargs.get('progress', False)

        if not os.path.exists(path):
            skyview_key = SURVEYS.loc[self.survey].sv
            try:
                hdul = sv.get_images(position=self.position,
                                     survey=[skyview_key],
                                     radius=self.radius * u.deg,
                                     show_progress=progress)[0][0]
            except IndexError:
                raise FITSException('Skyview image list returned empty.')
            except ValueError:
                raise FITSException(
                    f'{self.survey} is not a valid SkyView survey.')
            except HTTPError:
                raise FITSException('No response from Skyview server.')

            with open(path, 'wb') as f:
                hdul.writeto(f)

        with fits.open(path) as hdul:
            self.header, self.data = hdul[0].header, hdul[0].data
            self.wcs = WCS(self.header, naxis=2)

            try:
                self.mjd = Time(self.header['DATE']).mjd
            except KeyError:
                try:
                    self.epoch = self.kwargs.get('epoch')
                    msg = "Could not detect epoch, PM correction disabled."
                    assert self.epoch is not None, msg
                    self.mjd = self.epoch if self.epoch > 3000 else Time(
                        self.epoch, format='decimalyear').mjd
                except AssertionError as e:
                    if self.kwargs.get('pm'):
                        self.logger.warning(e)
                    self.mjd = None

            self.data *= 1000
Exemplo n.º 3
0
def main():
    ap = argparse.ArgumentParser(description='Get contextual imagery')
    ap.add_argument('--size',
                    type=float,
                    default=1000.,
                    help='The size of the images to fetch, in arcseconds.')
    ap.add_argument('surveys',
                    help='Comma-separated list of surveys to query.')
    ap.add_argument(
        'outdir',
        help='The directory in which to save the downloaded FITS files.')

    settings = ap.parse_args()
    surveys = settings.surveys.split(',')

    sv = SkyView()

    for name, ra_deg, dec_deg in TARGETS:
        for survey in surveys:
            print(name, survey, '...')

            hdulists = sv.get_images(
                position=f'{ra_deg} {dec_deg}',
                survey=survey,
                projection='Tan',
                width=settings.size * u.arcsec,
                height=settings.size * u.arcsec,
                #pixels = 300 # which produces JPEG images of 40 KB
                #pixels = 1000 # which produces JPEG images of 300 KB
                pixels=
                2000  #which produces JPEG images of 300 KB to 1.2 MB depending on the richness of the region
            )

            if len(hdulists) == 0:
                print(f'warning: no images for {name}', file=sys.stderr)
                continue

            if len(hdulists) > 1:
                print(f'warning: multiple images for {name}', file=sys.stderr)

            hdulists[0].writeto(
                os.path.join(settings.outdir, f'{name}_{survey}.fits'))
Exemplo n.º 4
0
from tkinter import *
from PIL import Image, ImageTk
from astroquery.skyview import SkyView
import numpy

from skymap.database import SkyMapDatabase

if __name__ == "__main__":
    sv = SkyView()

    db = SkyMapDatabase()
    res = db.query_one(
        """SELECT * FROM ngc_ngc2000 WHERE Name=(SELECT name FROM ngc_names WHERE object LIKE '%{}%')"""
        .format("M 104"))
    rah = res['RAh']
    ram = res['RAm']
    ra = rah * 15.0 + 15 * ram / 60.0

    des = res['DE-']
    ded = res['DEd']
    dem = res['DEm']

    dec = ded + dem / 60.0
    if des == "-":
        dec *= -1
    print("{}h {}m -> {}".format(rah, ram, ra))
    print("{}{}deg {}m -> {}".format(des, ded, dem, dec))

    image = sv.get_images(position="{}, {}".format(ra, dec),
                          survey="DSS",
                          pixels=(1000, 1000),