astroquery/esa/hsa/core.py
def download_data(self, *, retrieval_type="OBSERVATION", observation_id=None,
                      instrument_name=None, filename=None, observation_oid=None,
                      instrument_oid=None, product_level=None, verbose=False,
                      download_dir="", cache=True, **kwargs):
        """
        Download data from Herschel

        Parameters
        ----------
        observation_id : string, optional
            id of the observation to be downloaded
            The identifies of the observation we want to retrieve, 10 digits
            example: 1342195355
        retrieval_type : string, optional, default 'OBSERVATION'
            The type of product that we want to retrieve
            values: OBSERVATION, PRODUCT, POSTCARD, POSTCARDFITS, REQUESTFILE_XML, STANDALONE, UPDP, HPDP
        instrument_name : string, optional, default 'PACS'
            values: PACS, SPIRE, HIFI
            The instrument name, by default 'PACS' if the retrieval_type is 'OBSERVATION'
        filename : string, optional, default None
            If the filename is not set it will use the observation_id as filename
            file name to be used to store the file
        verbose : bool, optional, default False
            flag to display information about the process
        observation_oid : string, optional
            Observation internal identifies. This is the database identifier
        instrument_oid : string, optional
            The database identifies of the instrument
            values: 1, 2, 3
        product_level : string, optional
            level to download
            values: ALL, AUXILIARY, CALIBRATION, LEVEL0, LEVEL0_5, LEVEL1, LEVEL2, LEVEL2_5, LEVEL3, ALL-LEVEL3
        download_dir : string, optional
            The directory in which the file will be downloaded

        Returns
        -------
        File name of downloaded data
        """
        if filename is not None:
            filename = os.path.splitext(filename)[0]

        params = {'retrieval_type': retrieval_type}
        if observation_id is not None:
            params['observation_id'] = observation_id

        if retrieval_type == "OBSERVATION" and instrument_name is None:
            instrument_name = "PACS"

        if instrument_name is not None:
            params['instrument_name'] = instrument_name

        if observation_oid is not None:
            params['observation_oid'] = observation_oid

        if instrument_oid is not None:
            params['instrument_oid'] = instrument_oid

        if product_level is not None:
            params['product_level'] = product_level

        link = self.data_url + "".join(f"&{key}={val}" for key, val in params.items())

        link += "".join(f"&{key}={val}" for key, val in kwargs.items())

        if verbose:
            log.info(link)

        response = self._request('HEAD', link, save=False, cache=cache)
        if response.status_code == 401:
            error = "Data protected by proprietary rights. Please check your credentials"
            raise LoginError(error)

        response.raise_for_status()

        if filename is None:
            if observation_id is not None:
                filename = observation_id
            else:
                error = "Please set either 'obervation_id' or 'filename' for the output"
                raise ValueError(error)

        _, res_params = cgi.parse_header(response.headers['Content-Disposition'])

        r_filename = res_params["filename"]
        suffixes = Path(r_filename).suffixes

        if len(suffixes) > 1 and suffixes[-1] == ".jpg":
            filename += suffixes[-1]
        else:
            filename += "".join(suffixes)

        filename = os.path.join(download_dir, filename)

        self._download_file(link, filename, head_safe=True, cache=cache)

        if verbose:
            log.info(f"Wrote {link} to {filename}")

        return filename

        Download data from Herschel

        Parameters
        ----------
        observation_id : string, optional
            id of the observation to be downloaded
            The identifies of the observation we want to retrieve, 10 digits
            example: 1342195355
        retrieval_type : string, optional, default 'OBSERVATION'
            The type of product that we want to retrieve
            values: OBSERVATION, PRODUCT, POSTCARD, POSTCARDFITS, REQUESTFILE_XML, STANDALONE, UPDP, HPDP
        instrument_name : string, optional, default 'PACS'
            values: PACS, SPIRE, HIFI
            The instrument name, by default 'PACS' if the retrieval_type is 'OBSERVATION'
        filename : string, optional, default None
            If the filename is not set it will use the observation_id as filename
            file name to be used to store the file
        verbose : bool, optional, default False
            flag to display information about the process
        observation_oid : string, optional
            Observation internal identifies. This is the database identifier
        instrument_oid : string, optional
            The database identifies of the instrument
            values: 1, 2, 3
        product_level : string, optional
            level to download
            values: ALL, AUXILIARY, CALIBRATION, LEVEL0, LEVEL0_5, LEVEL1, LEVEL2, LEVEL2_5, LEVEL3, ALL-LEVEL3
        download_dir : string, optional
            The directory in which the file will be downloaded

        Returns
        -------
        File name of downloaded data
        
Download data from Herschel
Parameters



Returns

File name of downloaded data
Download data from Herschel Parameters Returns File name of downloaded data
def download_data(self, *, retrieval_type="OBSERVATION", observation_id=None,
                      instrument_name=None, filename=None, observation_oid=None,
                      instrument_oid=None, product_level=None, verbose=False,
                      download_dir="", cache=True, **kwargs):
        if filename is not None:
            filename = os.path.splitext(filename)[0]
        params = {'retrieval_type': retrieval_type}
        if observation_id is not None:
            params['observation_id'] = observation_id
        if retrieval_type == "OBSERVATION" and instrument_name is None:
            instrument_name = "PACS"
        if instrument_name is not None:
            params['instrument_name'] = instrument_name
        if observation_oid is not None:
            params['observation_oid'] = observation_oid
        if instrument_oid is not None:
            params['instrument_oid'] = instrument_oid
        if product_level is not None:
            params['product_level'] = product_level
        link = self.data_url + "".join(f"&{key}={val}" for key, val in params.items())
        link += "".join(f"&{key}={val}" for key, val in kwargs.items())
        if verbose:
            log.info(link)
        response = self._request('HEAD', link, save=False, cache=cache)
        if response.status_code == 401:
            error = "Data protected by proprietary rights. Please check your credentials"
            raise LoginError(error)
        response.raise_for_status()
        if filename is None:
            if observation_id is not None:
                filename = observation_id
            else:
                error = "Please set either 'obervation_id' or 'filename' for the output"
                raise ValueError(error)
        _, res_params = cgi.parse_header(response.headers['Content-Disposition'])
        r_filename = res_params["filename"]
        suffixes = Path(r_filename).suffixes
        if len(suffixes) > 1 and suffixes[-1] == ".jpg":
            filename += suffixes[-1]
        else:
            filename += "".join(suffixes)
        filename = os.path.join(download_dir, filename)
        self._download_file(link, filename, head_safe=True, cache=cache)
        if verbose:
            log.info(f"Wrote {link} to {filename}")
        return filename
def download_data ( self , * , retrieval_type = "OBSERVATION" , observation_id = None , instrument_name = None , filename = None , observation_oid = None , instrument_oid = None , product_level = None , verbose = False , download_dir = "" , cache = True , ** kwargs ) : if filename is not None : filename = os . path . splitext ( filename ) [ 0 ] params = { 'retrieval_type' : retrieval_type } if observation_id is not None : params [ 'observation_id' ] = observation_id if retrieval_type == "OBSERVATION" and instrument_name is None : instrument_name = "PACS" if instrument_name is not None : params [ 'instrument_name' ] = instrument_name if observation_oid is not None : params [ 'observation_oid' ] = observation_oid if instrument_oid is not None : params [ 'instrument_oid' ] = instrument_oid if product_level is not None : params [ 'product_level' ] = product_level link = self . data_url + "" . join ( f"&{key}={val}" for key , val in params . items ( ) ) link += "" . join ( f"&{key}={val}" for key , val in kwargs . items ( ) ) if verbose : log . info ( link ) response = self . _request ( 'HEAD' , link , save = False , cache = cache ) if response . status_code == 401 : error = "Data protected by proprietary rights. Please check your credentials" raise LoginError ( error ) response . raise_for_status ( ) if filename is None : if observation_id is not None : filename = observation_id else : error = "Please set either 'obervation_id' or 'filename' for the output" raise ValueError ( error ) _ , res_params = cgi . parse_header ( response . headers [ 'Content-Disposition' ] ) r_filename = res_params [ "filename" ] suffixes = Path ( r_filename ) . suffixes if len ( suffixes ) > 1 and suffixes [ - 1 ] == ".jpg" : filename += suffixes [ - 1 ] else : filename += "" . join ( suffixes ) filename = os . path . join ( download_dir , filename ) self . _download_file ( link , filename , head_safe = True , cache = cache ) if verbose : log . info ( f"Wrote {link} to {filename}" ) return filename
Download data from Herschel
Parameters
Download data from Herschel Parameters
"""
        Download data from Herschel

        Parameters
        ----------
        observation_id : string, optional
            id of the observation to be downloaded
            The identifies of the observation we want to retrieve, 10 digits
            example: 1342195355
        retrieval_type : string, optional, default 'OBSERVATION'
            The type of product that we want to retrieve
            values: OBSERVATION, PRODUCT, POSTCARD, POSTCARDFITS, REQUESTFILE_XML, STANDALONE, UPDP, HPDP
        instrument_name : string, optional, default 'PACS'
            values: PACS, SPIRE, HIFI
            The instrument name, by default 'PACS' if the retrieval_type is 'OBSERVATION'
        filename : string, optional, default None
            If the filename is not set it will use the observation_id as filename
            file name to be used to store the file
        verbose : bool, optional, default False
            flag to display information about the process
        observation_oid : string, optional
            Observation internal identifies. This is the database identifier
        instrument_oid : string, optional
            The database identifies of the instrument
            values: 1, 2, 3
        product_level : string, optional
            level to download
            values: ALL, AUXILIARY, CALIBRATION, LEVEL0, LEVEL0_5, LEVEL1, LEVEL2, LEVEL2_5, LEVEL3, ALL-LEVEL3
        download_dir : string, optional
            The directory in which the file will be downloaded

        Returns
        -------
        File name of downloaded data
        """
self
retrieval_type
observation_id
instrument_name
filename
observation_oid
instrument_oid
product_level
verbose
download_dir
cache