How to use the astroquery.query.BaseQuery function in astroquery

To help you get started, we’ve selected a few astroquery examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github astropy / astroquery / astroquery / nist / core.py View on Github external
table : str
       table to strip as a string

    Returns
    -------
    single string joined by newlines.
    """
    numbersletters = re.compile("[0-9A-Za-z]")
    if isinstance(table, str):
        table = table.split('\n')
    table = [line for line in table if numbersletters.search(line)]
    return "\n".join(table)


@async_to_sync
class NistClass(BaseQuery):
    URL = conf.server
    TIMEOUT = conf.timeout
    unit_code = {'Angstrom': 0,
                 'nm': 1,
                 'um': 2}
    energy_level_code = {'cm-1': 0, 'invcm': 0, 'cm': 0,
                         'ev': 1, 'eV': 1, 'EV': 1, 'electronvolt': 1,
                         'R': 2, 'Rydberg': 2, 'rydberg': 2}
    order_out_code = {'wavelength': 0,
                      'multiplet': 1}
    wavelength_unit_code = {'vacuum': 3,
                            'vac+air': 4}

    def _args_to_payload(self, *args, **kwargs):
        """
        Serves the same purpose as `~NistClass.query` but returns
github astropy / astroquery / astroquery / heasarc / core.py View on Github external
from six import BytesIO
from astropy.table import Table
from astropy.io import fits
from astropy import coordinates
from astropy import units as u
from ..query import BaseQuery
from ..utils import commons
from ..utils import async_to_sync
from ..exceptions import InvalidQueryError
from . import conf

__all__ = ['Heasarc', 'HeasarcClass']


@async_to_sync
class HeasarcClass(BaseQuery):

    """
    HEASARC query class.

    For a list of available HEASARC mission tables, visit:
        https://heasarc.gsfc.nasa.gov/cgi-bin/W3Browse/w3catindex.pl
    """

    URL = conf.server
    TIMEOUT = conf.timeout
    coord_systems = ['fk5', 'fk4', 'equatorial', 'galactic']

    def query_async(self, request_payload, cache=True, url=conf.server):
        """
        Submit a query based on a given request_payload. This allows detailed
        control of the query to be submitted.
github astropy / astroquery / astroquery / ibe / core.py View on Github external
import webbrowser
from bs4 import BeautifulSoup

import astropy.coordinates as coord
from astropy.table import Table
import six

from ..exceptions import InvalidQueryError
from ..query import BaseQuery
from ..utils import commons
from . import conf

__all__ = ['Ibe', 'IbeClass']


class IbeClass(BaseQuery):
    URL = conf.server
    MISSION = conf.mission
    DATASET = conf.dataset
    TABLE = conf.table
    TIMEOUT = conf.timeout

    def query_region(
            self, coordinate=None, where=None, mission=None, dataset=None,
            table=None, columns=None, width=None, height=None,
            intersect='OVERLAPS', most_centered=False):
        """
        For certain missions, this function can be used to search for image and
        catalog files based on a point, a box (bounded by great circles) and/or
        an SQL-like ``where`` clause.

        If ``coordinates`` is specified, then the optional ``width`` and
github astropy / astroquery / astroquery / jplsbdb / core.py View on Github external
import json
from collections import OrderedDict

from numpy import fromstring, isnan, array
import astropy.units as u

from ..query import BaseQuery
from ..utils import commons
from ..utils import async_to_sync
from . import conf

__all__ = ['SBDB', 'SBDBClass']


@async_to_sync
class SBDBClass(BaseQuery):

    """
    A class for querying the `JPL Small-Body Database Browser
    `_ service.
    """

    # internal flag whether to return the raw reponse
    _return_raw = False

    # actual query uri
    _uri = None

    def query_async(self, targetid, id_type='search',
                    neo_only=False,
                    alternate_id=False,
                    full_precision=False,
github astropy / astroquery / astroquery / gama / core.py View on Github external
# Licensed under a 3-clause BSD style license - see LICENSE.rst
"""Download GAMA data"""
import re
import os
from astropy.table import Table
from ..query import BaseQuery
from ..utils import commons, async_to_sync

__all__ = ['GAMA', 'GAMAClass']


@async_to_sync
class GAMAClass(BaseQuery):
    """
    TODO: document
    """

    request_url = 'http://www.gama-survey.org/dr3/query/'
    timeout = 60

    def query_sql_async(self, *args, **kwargs):
        """
        Query the GAMA database

        Returns
        -------
        url : The URL of the FITS file containing the results.
        """
github astropy / astroquery / astroquery / oac / core.py View on Github external
import json
import csv

import astropy.units as u
from astropy.table import Column, Table

from . import conf
from ..query import BaseQuery
from ..utils import async_to_sync, commons

__all__ = ['OAC', 'OACClass']


@async_to_sync
class OACClass(BaseQuery):
    """OAC class."""

    URL = conf.server
    TIMEOUT = conf.timeout
    HEADERS = {'Content-type': 'application/json', 'Accept': 'text/plain'}
    FORMAT = None

    def query_object_async(self,
                           event,
                           quantity=None,
                           attribute=None,
                           argument=None,
                           data_format='csv',
                           get_query_payload=False, cache=True):
        """
        Retrieve object(s) asynchronously.
github astropy / astroquery / astroquery / irsa_dust / core.py View on Github external
STATISTICS = "statistics"
REF_PIXEL_VALUE = "refPixelValue"
REF_COORDINATE = "refCoordinate"
MEAN_VALUE = "meanValue"
STD = "std"
MAX_VALUE = "maxValue"
MIN_VALUE = "minValue"
SANDF = "SandF"
SFD = "SFD"

DATA_IMAGE = "./data/image"
DATA_TABLE = "./data/table"


class IrsaDustClass(BaseQuery):

    DUST_SERVICE_URL = conf.server
    TIMEOUT = conf.timeout
    image_type_to_section = {
        'temperature': 't',
        'ebv': 'r',
        '100um': 'e'
    }

    def get_images(self, coordinate, radius=None,
                   image_type=None, timeout=TIMEOUT, get_query_payload=False,
                   show_progress=True):
        """
        A query function that performs a coordinate-based query to acquire
        Irsa-Dust images.
github astropy / astroquery / astroquery / esa / esa_hubble / core.py View on Github external
table = modelutils.read_results_table_from_file(filename,
                                                        str(output_format))
        return table

    def request(self, t="GET", link=None, params=None,
                cache=None,
                timeout=None):
        return self._request(method=t, url=link,
                             params=params, cache=cache,
                             timeout=timeout)


Handler = ESAHubbleHandler()


class ESAHubbleClass(BaseQuery):

    data_url = conf.DATA_ACTION
    metadata_url = conf.METADATA_ACTION
    TIMEOUT = conf.TIMEOUT

    def __init__(self, url_handler=None, tap_handler=None):
        super(ESAHubbleClass, self).__init__()
        if url_handler is None:
            self._handler = Handler
        else:
            self._handler = url_handler

        if tap_handler is None:
            self._tap = TapPlus(url="http://hst.esac.esa.int"
                                    "/tap-server/tap/")
        else:
github astropy / astroquery / astroquery / vo_conesearch / core.py View on Github external
from astropy.io.votable import table

from .exceptions import ConeSearchError, InvalidAccessURL
from .vos_catalog import vo_tab_parse
from ..query import BaseQuery
from ..utils import commons

# Import configurable items declared in __init__.py
from . import conf

__all__ = ['ConeSearch', 'ConeSearchClass']

__doctest_skip__ = ['ConeSearchClass']


class ConeSearchClass(BaseQuery):
    """
    The class for querying the Virtual Observatory (VO)
    Cone Search web service.

    Examples
    --------
    >>> from astropy import units as u
    >>> from astropy.coordinates import SkyCoord
    >>> from astroquery.vo_conesearch import ConeSearch
    >>> ConeSearch.query_region(SkyCoord.from_name('M31'), 5 * u.arcsecond)
    
        objID           gscID2      ... compassGSC2id   Mag
                                    ...                 mag
        int64           object      ...     object    float32
    -------------- ---------------- ... ------------- -------
    23323175812944 00424433+4116085 ... 6453800072293      --<table length="6"></table>
github astropy / astroquery / astroquery / mpc / core.py View on Github external
from astropy.time import Time
from astropy.table import Table, Column
import astropy.units as u
from astropy.coordinates import EarthLocation, Angle

from ..query import BaseQuery
from . import conf
from ..utils import async_to_sync, class_or_instance
from ..exceptions import InvalidQueryError


__all__ = ['MPCClass']


@async_to_sync
class MPCClass(BaseQuery):
    MPC_URL = 'https://' + conf.web_service_server + '/web_service'
    # The authentication credentials for the MPC web service are publicly
    # available and can be openly viewed on the documentation page at
    # https://minorplanetcenter.net/web_service/
    MPC_USERNAME = 'mpc_ws'
    MPC_PASSWORD = 'mpc!!ws'

    MPES_URL = 'https://' + conf.mpes_server + '/cgi-bin/mpeph2.cgi'
    OBSERVATORY_CODES_URL = ('https://' + conf.web_service_server +
                             '/iau/lists/ObsCodes.html')
    TIMEOUT = conf.timeout

    _ephemeris_types = {
        'equatorial': 'a',
        'heliocentric': 's',
        'geocentric': 'G'