class_docstr: Data storage and retrieval functionality for Earthlab.
  
  An object of this class is available upon importing earthpy as
  ``earthpy.data`` that writes data files to the path:
  ``~/earth-analytics/data/``.
  
  Parameters
  ----------
  path : string | None
      The path where data is stored. NOTE: this defaults to the directory
      ``~/earth-analytics/data/``.
  
  Examples
  --------
  List datasets that are available for download, using default object:
  
      >>> import earthpy as et
      >>> et.data
      Available Datasets: ['california-rim-fire', ...]
  
  Specify a custom directory for data downloads:
  
      >>> et.data.path = "."
      >>> et.data
      Available Datasets: ['california-rim-fire', ...]
docstr: Retrieve the data for a given week and return its path.
  
  This will retrieve data from the internet if it isn't already
  downloaded, otherwise it will only return a path to that dataset.
  
  Parameters
  ----------
  key : str
      The dataset to retrieve. Possible options can be found in
      ``self.data_keys``. Note: ``key`` and ``url`` are mutually
      exclusive.
  url : str
      A URL to fetch into the data directory. Use this for ad-hoc dataset
      downloads. Note: ``key`` and ``url`` are mutually exclusive.
  replace : bool
      Whether to replace the data for this key if it is
      already downloaded.
  verbose : bool
      Whether to print verbose output while downloading files.
  
  Returns
  -------
  path_data : str
      The path to the downloaded data.
  
  Examples
  --------
  Download a dataset using a key:
  
      >>> et.data.get_data('california-rim-fire') # doctest: +SKIP
  
  Or, download a dataset using a figshare URL:
  
      >>> url = 'https://ndownloader.figshare.com/files/12395030'
      >>> et.data.get_data(url=url)  # doctest: +SKIP
docstr_tok: ["Retrieve","the","data","for","a","given","week","and","return","its","path",".","This","will","retrieve","data","from","the","internet","if","it","is","n't","already","downloaded",",","otherwise","it","will","only","return","a","path","to","that","dataset",".","Parameters","--","--","--","--","--","key",":","str","The","dataset","to","retrieve",".","Possible","options","can","be","found","in","``","self.data_keys","``",".","Note",":","``","key","``","and","``","url","``","are","mutually","exclusive",".","url",":","str","A","URL","to","fetch","into","the","data","directory",".","Use","this","for","ad-hoc","dataset","downloads",".","Note",":","``","key","``","and","``","url","``","are","mutually","exclusive",".","replace",":","bool","Whether","to","replace","the","data","for","this","key","if","it","is","already","downloaded",".","verbose",":","bool","Whether","to","print","verbose","output","while","downloading","files",".","Returns","--","--","--","-","path_data",":","str","The","path","to","the","downloaded","data",".","Examples","--","--","--","--","Download","a","dataset","using","a","key",":",">",">",">","et.data.get_data","(","'california-rim-fire","'",")","#","doctest",":","+SKIP","Or",",","download","a","dataset","using","a","figshare","URL",":",">",">",">","url","=","'https",":","\/\/ndownloader.figshare.com\/files\/12395030'",">",">",">","et.data.get_data","(","url=url",")","#","doctest",":","+SKIP"]
code: def get_data(self, key=None, url=None, replace=False, verbose=True):
      """
      Retrieve the data for a given week and return its path.
  
      This will retrieve data from the internet if it isn't already
      downloaded, otherwise it will only return a path to that dataset.
  
      Parameters
      ----------
      key : str
          The dataset to retrieve. Possible options can be found in
          ``self.data_keys``. Note: ``key`` and ``url`` are mutually
          exclusive.
      url : str
          A URL to fetch into the data directory. Use this for ad-hoc dataset
          downloads. Note: ``key`` and ``url`` are mutually exclusive.
      replace : bool
          Whether to replace the data for this key if it is
          already downloaded.
      verbose : bool
          Whether to print verbose output while downloading files.
  
      Returns
      -------
      path_data : str
          The path to the downloaded data.
  
      Examples
      --------
      Download a dataset using a key:
  
          >>> et.data.get_data('california-rim-fire') # doctest: +SKIP
  
      Or, download a dataset using a figshare URL:
  
          >>> url = 'https://ndownloader.figshare.com/files/12395030'
          >>> et.data.get_data(url=url)  # doctest: +SKIP
  
      """
      if key is not None and url is not None:
          raise ValueError(
              "The `url` and `key` parameters can not both be "
              "set at the same time."
          )
      if key is None and url is None:
          print(self.__repr__())
          return
  
      if key is not None:
          if key not in DATA_URLS:
              pretty_keys = ", ".join(repr(k) for k in self.data_keys)
              raise KeyError(
                  "Key '"
                  + key
                  + "' not found in earthpy.io.DATA_URLS. "
                  "Choose one of: {}".format(pretty_keys)
              )
  
          this_data = DATA_URLS[key]
          this_root = op.join(str(self.path), key)
  
      if url is not None:
          with requests.head(url) as r:
              if "content-disposition" in r.headers.keys():
                  content = r.headers["content-disposition"]
                  fname = re.findall("filename=(.+)", content)[0]
              else:
                  fname = url.split("/")[-1]
              if fname.endswith('"') and fname.startswith('"'):
                  fname = fname[1:-1]
  
          # Determine filetype using file name extension
          file_type = "file"
          for ext in ALLOWED_FILE_TYPES:
              if fname.endswith(ext):
                  file_type = ext
  
          # remove extension for pretty download paths
          fname = re.sub("\\.{}$".format(file_type), "", fname)
  
          this_data = (url, fname, file_type)
          this_root = op.join(str(self.path), "earthpy-downloads")
  
      if not isinstance(this_data, list):
          this_data = [this_data]
  
      data_paths = []
      for url, name, kind in this_data:
          if kind not in ALLOWED_FILE_TYPES:
              raise ValueError(
                  "kind must be one of {}, got {}".format(
                      ALLOWED_FILE_TYPES, kind
                  )
              )
  
          this_path = self._download(
              url=url,
              path=os.path.join(this_root, name),
              kind=kind,
              replace=replace,
              verbose=verbose,
          )
          data_paths.append(this_path)
      if len(data_paths) == 1:
          data_paths = data_paths[0]
      return data_paths
  
file_path: earthpy/earthpy/io.py
imports: import io
  import os
  import os.path
  import re
  import requests
  import tarfile
  import zipfile
  import earthpy
label_desc: Use image node_id 3 for calling the Data obj's underlying member method code with example usage: obj.get_data(key, url, replace, verbose) and returns: data_paths