How to use the astroquery.utils.commons.coord_to_radec 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 / gaia / tapplus / tap.py View on Github external
output_file : str, optional, default None
            file name where the results are saved if dumpToFile is True. 
            If this parameter is not provided, the jobid is used instead
        output_format : str, optional, default 'votable'
            results format
        verbose : bool, optional, default 'False' 
            flag to display information about the process
        dump_to_file : bool, optional, default 'False'
            if True, the results are saved in a file instead of using memory

        Returns
        -------
        A Job object
        """
        coord = self.__getCoordInput(coordinate, "coordinate")
        raHours, dec = commons.coord_to_radec(coord)
        ra = raHours * 15.0 # Converts to degrees
        if radius is not None:
            radiusQuantity = self.__getQuantityInput(radius, "radius")
            radiusDeg = commons.radius_to_unit(radiusQuantity, unit='deg')
        query = "SELECT DISTANCE(POINT('ICRS',"+str(MAIN_GAIA_TABLE_RA)+","\
            +str(MAIN_GAIA_TABLE_DEC)+"), \
            POINT('ICRS',"+str(ra)+","+str(dec)+")) AS dist, * \
            FROM "+str(MAIN_GAIA_TABLE)+" WHERE CONTAINS(\
            POINT('ICRS',"+str(MAIN_GAIA_TABLE_RA)+","+str(MAIN_GAIA_TABLE_DEC)+"),\
            CIRCLE('ICRS',"+str(ra)+","+str(dec)+", "+str(radiusDeg)+"))=1 \
            ORDER BY dist ASC"
        if async:
            return self.launch_job_async(query=query, 
                                         output_file=output_file, 
                                         output_format=output_format, 
                                         verbose=verbose, 
github astropy / astroquery / astroquery / gaia / core.py View on Github external
If this parameter is not provided, the jobid is used instead
        output_format : str, optional, default 'votable'
            results format
        verbose : bool, optional, default 'False'
            flag to display information about the process
        dump_to_file : bool, optional, default 'False'
            if True, the results are saved in a file instead of using memory
        columns: list, optional, default []
            if empty, all columns will be selected

        Returns
        -------
        A Job object
        """
        coord = self.__getCoordInput(coordinate, "coordinate")
        raHours, dec = commons.coord_to_radec(coord)
        ra = raHours * 15.0  # Converts to degrees
        if radius is not None:
            radiusQuantity = self.__getQuantityInput(radius, "radius")
            radiusDeg = commons.radius_to_unit(radiusQuantity, unit='deg')

        if columns:
            columns = ','.join(map(str, columns))
        else:
            columns = "*"

        query = """
                SELECT
                  {columns},
                  DISTANCE(
                    POINT('ICRS', {ra_column}, {dec_column}),
                    POINT('ICRS', {ra}, {dec})
github astropy / astroquery / astroquery / esa / esa_hubble / core.py View on Github external
def cone_search(self, coordinates, radius=0.0, filename=None,
                    output_format='votable', cache=True):
        """
        """
        coord = self._getCoordInput(coordinates, "coordinate")
        radiusInGrades = float(radius/60)  # Converts to degrees

        raHours, dec = commons.coord_to_radec(coord)
        ra = raHours * 15.0  # Converts to degrees
        payload = {"RESOURCE_CLASS": "OBSERVATION",
                   "ADQLQUERY": "SELECT DISTINCT OBSERVATION,OBSERVATION.TYPE,"
                   "TARGET.MOVING_TARGET"
                   ",TARGET.TARGET_NAME,TARGET.TARGET_DESCRIPTION,PROPOSAL."
                   "PROPOSAL_ID,PROPOSAL.PI_"
                   "NAME,PROPOSAL.PROPOSAL_TITLE,INSTRUMENT.INSTRUMENT_NAME,"
                   "PLANE.METADATA_PROVENANCE"
                   ",PLANE.DATA_PRODUCT_TYPE,PLANE.SOFTWARE_VERSION,POSITION"
                   ".RA,POSITION.DEC,POSITION."
                   "GAL_LAT,POSITION.GAL_LON,POSITION.ECL_LAT,POSITION.ECL_LON"
                   ",POSITION.FOV_SIZE,ENERGY."
                   "WAVE_CENTRAL,ENERGY.WAVE_BANDWIDTH,ENERGY.WAVE_MAX,ENERGY"
                   ".WAVE_MIN,ENERGY.FILTER FROM"
                   " FIELD_NOT_USED  WHERE OBSERVATION.COLLECTION='HST'  AND  "
                   "PLANE.MAIN_SCIENCE_PLANE="
github astropy / astroquery / astroquery / ogle / core.py View on Github external
Parameters
        ----------
        coord : list-like
        coord_sys : string

        Returns
        -------
        lon : list
            Longitude coordinate values
        lat : list
            Latitude coordinate values
        """
        if not isinstance(coord, list):
            # single astropy coordinate
            try:
                ra, dec = commons.coord_to_radec(coord)
                lon = [ra]
                lat = [dec]
                return lon, lat
            except ValueError:
                raise CoordParseError()
        elif isinstance(coord, list):
            shape = np.shape(coord)
            # list of astropy coordinates
            if len(shape) == 1:
                try:
                    radec = [commons.coord_to_radec(co) for co in coord]
                    lon, lat = list(zip(*radec))
                    return lon, lat
                except ValueError:
                    raise CoordParseError()
            # list-like of values
github astropy / astroquery / astroquery / ned / core.py View on Github external
# if its a name then query near name
        if not commons._is_coordinate(coordinates):
            request_payload['objname'] = coordinates
            request_payload['search_type'] = 'Near Name Search'
            request_payload['radius'] = coord.Angle(radius).arcmin
        else:
            try:
                c = commons.parse_coordinates(coordinates)
                if c.frame.name == 'galactic':
                    request_payload['in_csys'] = 'Galactic'
                    request_payload['lon'] = c.l.degree
                    request_payload['lat'] = c.b.degree
                # for any other, convert to ICRS and send
                else:
                    request_payload['in_csys'] = 'Equatorial'
                    ra, dec = commons.coord_to_radec(c)
                    request_payload['lon'] = ra
                    request_payload['lat'] = dec
                request_payload['search_type'] = 'Near Position Search'
                request_payload['in_equinox'] = equinox
                request_payload['radius'] = coord.Angle(radius).arcmin
            except (u.UnitsError, TypeError):
                raise TypeError("Coordinates not specified correctly")
        if get_query_payload:
            return request_payload
        response = self._request("GET", url=Ned.OBJ_SEARCH_URL,
                                 params=request_payload, timeout=Ned.TIMEOUT)
        return response
github astropy / astroquery / astroquery / gaiatap / tapplus / tap.py View on Github external
async : bool, optional, default 'False'
            executes the query (job) in asynchronous/synchronous mode (default 
            synchronous)
        verbose : bool, optional, default 'False' 
            flag to display information about the process

        Returns
        -------
        The job results (astropy.table).
        """
        coord = self.__getCoordInput(coordinate, "coordinate")
        job = None
        if radius is not None:
            job = self.cone_search(coord, radius, async=async, verbose=verbose)
        else:
            raHours, dec = commons.coord_to_radec(coord)
            ra = raHours * 15.0 # Converts to degrees
            widthQuantity = self.__getQuantityInput(width, "width")
            heightQuantity = self.__getQuantityInput(height, "height")
            widthDeg = widthQuantity.to(units.deg)
            heightDeg = heightQuantity.to(units.deg)
            query = "SELECT DISTANCE(POINT('ICRS',"+str(MAIN_GAIA_TABLE_RA)+","\
                +str(MAIN_GAIA_TABLE_DEC)+"), \
                POINT('ICRS',"+str(ra)+","+str(dec)+")) AS dist, * \
                FROM "+str(MAIN_GAIA_TABLE)+" WHERE CONTAINS(\
                POINT('ICRS',"+str(MAIN_GAIA_TABLE_RA)+","\
                +str(MAIN_GAIA_TABLE_DEC)+"),\
                BOX('ICRS',"+str(ra)+","+str(dec)+", "+str(widthDeg.value)+", "\
                +str(heightDeg.value)+"))=1 \
                ORDER BY dist ASC"
            job = self.launch_job(query, async=async, verbose=verbose)
        return job.get_results()