VOSDatabase¶
- class astroquery.vo_conesearch.vos_catalog.VOSDatabase(tree)[source]¶
Bases:
VOSBase
A class to represent a collection of
VOSCatalog
.- Parameters:
- treeJSON tree
- Raises:
- VOSError
If given
tree
does not have ‘catalogs’ key or catalog is invalid.
Attributes Summary
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 an empty database of VO services.
delete_catalog
(name)Delete a catalog from database with given name.
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.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)[source]¶
Add a catalog to database.
- Parameters:
- namestr
Primary key for the catalog.
- cat
VOSCatalog
Catalog to add.
- allow_duplicate_urlbool
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)[source]¶
Like
add_catalog()
but the catalog is created with only the given name and access URL.- Parameters:
- namestr
Primary key for the catalog.
- urlstr
Access URL of the service. This is used to build queries.
- kwargsdict
Keywords accepted by
add_catalog()
.
- classmethod create_empty()[source]¶
Create an empty database of VO services.
Empty database format:
{ "__version__": 1, "catalogs" : { } }
- Returns:
- db
VOSDatabase
Empty database.
- db
- delete_catalog(name)[source]¶
Delete a catalog from database with given name.
- Parameters:
- namestr
Primary key identifying the catalog.
- Raises:
- MissingCatalog
If catalog is not found.
- delete_catalog_by_url(url)[source]¶
Like
delete_catalog()
but using access URL. On multiple matches, all matches are deleted.
- classmethod from_json(filename, **kwargs)[source]¶
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:
- filenamestr
JSON file.
- kwargsdict
Keywords accepted by
get_readable_fileobj()
.
- Returns:
- db
VOSDatabase
Database from given file.
- db
- classmethod from_registry(registry_url, timeout=60, **kwargs)[source]¶
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_urlstr
URL of VO registry that returns a VO Table. For example, see
astroquery.vo_conesearch.validator.conf.cs_mstr_list
. Pedantic is automatically set toFalse
for parsing.- timeoutnumber
Temporarily set
astropy.utils.data.conf.remote_timeout
to this value to avoid time out error while reading the entire registry.- kwargsdict
Keywords accepted by
get_readable_fileobj()
.
- Returns:
- db
VOSDatabase
Database from given registry.
- db
- Raises:
- VOSError
Invalid VO registry.
- get_catalog(name)[source]¶
Get one catalog of given name.
- Parameters:
- namestr
Primary key identifying the catalog.
- Returns:
- obj
VOSCatalog
- obj
- Raises:
- MissingCatalog
If catalog is not found.
- get_catalog_by_url(url)[source]¶
Like
get_catalog()
but using access URL look-up. On multiple matches, only first match is returned.
- get_catalogs_by_url(url)[source]¶
Like
get_catalogs()
but using access URL look-up.
- list_catalogs(pattern=None, sort=True)[source]¶
List catalog names.
- Parameters:
- patternstr 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.- sortbool
Sort output in alphabetical order. If not sorted, the order depends on dictionary hashing. Default is
True
.
- patternstr or
- Returns:
- out_arrlist of str
List of catalog names.
- list_catalogs_by_url(pattern=None, sort=True)[source]¶
Like
list_catalogs()
but using access URL.
- merge(other, **kwargs)[source]¶
Merge two database together.
- Parameters:
- other
VOSDatabase
The other database to merge.
- kwargsdict
Keywords accepted by
add_catalog()
.
- other
- Returns:
- db
VOSDatabase
Merged database.
- db
- Raises:
- VOSError
Invalid database or incompatible version.