astro query:docs

- Index
- Modules

### Navigation

- next »
- « previous |
- astroquery v0.4.11 »
- VO Simple Cone Search (`astroquery.vo_conesearch`) »
- VOSDatabase

# VOSDatabase

class astroquery.vo_conesearch.vos_catalog.VOSDatabase(tree)

  Bases: `VOSBase`

  A class to represent a collection of `VOSCatalog`.

  Parameters:
    tree JSON tree
  Raises:
    VOSError

      If given `tree` does not have ‘catalogs’ key or catalog is invalid.

  Attributes Summary

  `version` | Database version number.

  Methods Summary

  `add_catalog`(name, cat, *[, allow_duplicate_url]) | Add a catalog to database.
  `add_catalog_by_url`(name, url, **kwargs) | Like `add_catalog()` but the catalog is created with only the given name and access URL.
  `create_empty`() | Create an empty database of VO services.
  `delete_catalog`(name) | Delete a catalog from database with given name.
  `delete_catalog_by_url`(url) | Like `delete_catalog()` but using access URL.
  `from_json`(filename, **kwargs) | Create a database of VO services from a JSON file.
  `from_registry`(registry_url, *[, timeout]) | Create a database of VO services from VO registry URL.
  `get_catalog`(name) | Get one catalog of given name.
  `get_catalog_by_url`(url) | Like `get_catalog()` but using access URL look-up.
  `get_catalogs`() | Iterator to get all catalogs.
  `get_catalogs_by_url`(url) | Like `get_catalogs()` but using access URL look-up.
  `list_catalogs`([pattern, sort]) | List catalog names.
  `list_catalogs_by_url`(*[, pattern, sort]) | Like `list_catalogs()` but using access URL.
  `merge`(other, **kwargs) | Merge two database together.
  `to_json`(filename, *[, overwrite]) | Write database content to a JSON file.

  Attributes Documentation

  version

    Database version number.

  Methods Documentation

  add_catalog(name, cat, *, allow_duplicate_url=False)

    Add a catalog to database.

    Parameters:
      name str

        Primary key for the catalog.

      cat `VOSCatalog`

        Catalog to add.

      allow_duplicate_url bool

        Allow catalog with duplicate access URL?

    Raises:
      VOSError

        Invalid catalog.

      DuplicateCatalogName

        Catalog with given name already exists.

      DuplicateCatalogURL

        Catalog with given access URL already exists.

  add_catalog_by_url(name, url, **kwargs)

    Like `add_catalog()` but the catalog is created with only the given name and access URL.

    Parameters:
      name str

        Primary key for the catalog.

      url str

        Access URL of the service. This is used to build queries.

      kwargs dict

        Keywords accepted by `add_catalog()`.

  classmethod create_empty()

    Create an empty database of VO services.

    Empty database format:

        {
            "__version__": 1,
            "catalogs" : {
            }
        }

    Returns:
      db `VOSDatabase`

        Empty database.

  delete_catalog(name)

    Delete a catalog from database with given name.

    Parameters:
      name str

        Primary key identifying the catalog.

    Raises:
      MissingCatalog

        If catalog is not found.

  delete_catalog_by_url(url)

    Like `delete_catalog()` but using access URL. On multiple matches, all matches are deleted.

  classmethod from_json(filename, **kwargs)

    Create a database of VO services from a JSON file.

    Example JSON format for Cone Search:

        {
            "__version__": 1,
            "catalogs" : {
                "My Cone Search": {
                    "capabilityClass": "ConeSearch",
                    "title": "My Cone Search",
                    "url": "http://foo/cgi-bin/search?CAT=bar&",
                    ...
                },
                "Another Cone Search": {
                    ...
                }
            }
        }

    Parameters:
      filename str

        JSON file.

      kwargs dict

        Keywords accepted by `get_readable_fileobj()`.

    Returns:
      db `VOSDatabase`

        Database from given file.

  classmethod from_registry(registry_url, *, timeout=60, **kwargs)

    Create a database of VO services from VO registry URL.

    This is described in detail in Building the Database from Registry, except for the `validate_xxx` keys that are added by the validator itself.

    Parameters:
      registry_url str

        URL of VO registry that returns a VO Table. For example, see `astroquery.vo_conesearch.validator.conf.cs_mstr_list`. Pedantic is automatically set to `False` for parsing.

      timeout number

        Temporarily set `astropy.utils.data.conf.remote_timeout` to this value to avoid time out error while reading the entire registry.

      kwargs dict

        Keywords accepted by `get_readable_fileobj()`.

    Returns:
      db `VOSDatabase`

        Database from given registry.

    Raises:
      VOSError

        Invalid VO registry.

  get_catalog(name)

    Get one catalog of given name.

    Parameters:
      name str

        Primary key identifying the catalog.

    Returns:
      obj `VOSCatalog`
    Raises:
      MissingCatalog

        If catalog is not found.

  get_catalog_by_url(url)

    Like `get_catalog()` but using access URL look-up. On multiple matches, only first match is returned.

  get_catalogs()

    Iterator to get all catalogs.

  get_catalogs_by_url(url)

    Like `get_catalogs()` but using access URL look-up.

  list_catalogs(pattern=None, sort=True)

    List catalog names.

    Parameters:
      pattern str or `None`

        If given string is anywhere in a catalog name, it is considered a matching catalog. It accepts patterns as in `fnmatch` and is case-insensitive. By default, all catalogs are returned.

      sort bool

        Sort output in alphabetical order. If not sorted, the order depends on dictionary hashing. Default is `True`.

    Returns:
      out_arr list of str

        List of catalog names.

  list_catalogs_by_url(*, pattern=None, sort=True)

    Like `list_catalogs()` but using access URL.

  merge(other, **kwargs)

    Merge two database together.

    Parameters:
      other `VOSDatabase`

        The other database to merge.

      kwargs dict

        Keywords accepted by `add_catalog()`.

    Returns:
      db `VOSDatabase`

        Merged database.

    Raises:
      VOSError

        Invalid database or incompatible version.

  to_json(filename, *, overwrite=False)

    Write database content to a JSON file.

    Parameters:
      filename str

        JSON file.

      overwrite bool

        If `True`, overwrite the output file if it exists.

    Raises:
      OSError

        If the file exists and `overwrite` is `False`.