Exemplo n.º 1
0
 def get_ext_table_async_mockreturn(self,
                                    coordinate,
                                    radius=None,
                                    timeout=IrsaDust.TIMEOUT,
                                    show_progress=True):
     return (commons.FileContainer(self.data(EXT_TBL),
                                   show_progress=show_progress))
Exemplo n.º 2
0
    def get_spectra_async(self,
                          object_name,
                          get_query_payload=False,
                          show_progress=True):
        """
        Serves the same purpose as `~NedClass.get_spectra` but returns
        file-handlers to the remote files rather than downloading them.

        Parameters
        ----------
        object_name : str
            name of the identifier to query.
        get_query_payload : bool, optional
            if set to `True` then returns the dictionary sent as the HTTP
            request.  Defaults to `False`

        Returns
        --------
        A list of context-managers that yield readable file-like objects

        """
        image_urls = self.get_image_list(object_name,
                                         item='spectra',
                                         get_query_payload=get_query_payload)
        if get_query_payload:
            return image_urls
        return [
            commons.FileContainer(U,
                                  encoding='binary',
                                  show_progress=show_progress)
            for U in image_urls
        ]
Exemplo n.º 3
0
 def get_images_async_mockreturn(self, coordinate, radius=None,
                                 image_type=None, timeout=IrsaDust.TIMEOUT,
                                 get_query_payload=False,
                                 show_progress=True):
     readable_obj = commons.FileContainer(self.data(IMG_FITS),
                                          encoding='binary',
                                          show_progress=show_progress)
     return [readable_obj]
Exemplo n.º 4
0
    def get_images_async(self,
                         coordinate,
                         radius=None,
                         image_type=None,
                         timeout=TIMEOUT,
                         get_query_payload=False,
                         show_progress=True):
        """
        A query function similar to
        `astroquery.ipac.irsa.irsa_dust.IrsaDustClass.get_images` but returns
        file-handlers to the remote files rather than downloading
        them. Useful for asynchronous queries so that the actual download
        may be performed later.

        Parameters
        ----------
        coordinate : str
            Can be either the name of an object or a coordinate string
            If a name, must be resolvable by NED, SIMBAD, 2MASS, or SWAS.
            Examples of acceptable coordinate strings, can be found `here.
            <https://irsa.ipac.caltech.edu/applications/DUST/docs/coordinate.html>`_
        radius : str / `~astropy.units.Quantity`, optional
            The size of the region to include in the dust query, in radian,
            degree or hour as per format specified by
            `~astropy.coordinates.Angle` or `~astropy.units.Quantity`.
            Defaults to 5 degrees.
        image_type : str, optional
            When missing returns for all the images. Otherwise returns only
            for image of the specified type which must be one of
            ``'temperature'``, ``'ebv'``, ``'100um'``. Defaults to `None`.
        timeout : int, optional
            Time limit for establishing successful connection with remote
            server. Defaults to `~astroquery.ipac.irsa.irsa_dust.IrsaDustClass.TIMEOUT`.
        get_query_payload : bool, optional
            If `True` then returns the dictionary of query parameters, posted
            to remote server. Defaults to `False`.

        Returns
        -------
        list : list
            A list of context-managers that yield readable file-like objects.
        """

        if get_query_payload:
            return self._args_to_payload(coordinate, radius=radius)
        image_urls = self.get_image_list(coordinate,
                                         radius=radius,
                                         image_type=image_type,
                                         timeout=timeout)

        # Images are assumed to be FITS files
        # they MUST be read as binary for python3 to parse them
        return [
            commons.FileContainer(U,
                                  encoding='binary',
                                  show_progress=show_progress)
            for U in image_urls
        ]
Exemplo n.º 5
0
    def get_extinction_table_async(self,
                                   coordinate,
                                   radius=None,
                                   timeout=TIMEOUT,
                                   show_progress=True):
        """
        A query function similar to
        `astroquery.ipac.irsa.irsa_dust.IrsaDustClass.get_extinction_table` but
        returns a file-handler to the remote files rather than downloading
        it.  Useful for asynchronous queries so that the actual download may
        be performed later.

        Parameters
        ----------
        coordinate : str
            Can be either the name of an object or a coordinate string
            If a name, must be resolvable by NED, SIMBAD, 2MASS, or SWAS.
            Examples of acceptable coordinate strings, can be found `here.
            <https://irsa.ipac.caltech.edu/applications/DUST/docs/coordinate.html>`_
        radius : str, optional
            The size of the region to include in the dust query, in radian,
            degree or hour as per format specified by
            `~astropy.coordinates.Angle`. Defaults to 5 degrees.
        timeout : int, optional
            Time limit for establishing successful connection with remote
            server. Defaults to `~astroquery.ipac.irsa.irsa_dust.IrsaDustClass.TIMEOUT`.

        Returns
        -------
        result : A context manager that yields a file like readable object.
        """
        url = self.DUST_SERVICE_URL
        request_payload = self._args_to_payload(coordinate, radius=radius)
        response = self._request("POST",
                                 url,
                                 data=request_payload,
                                 timeout=timeout)
        xml_tree = utils.xml(response.text)
        result = SingleDustResult(xml_tree, coordinate)
        return commons.FileContainer(result.ext_detail_table(),
                                     show_progress=show_progress)