sdss_brain Reference¶
Config¶
Multi-Modal Access (MMA)¶
-
class
sdss_brain.mma.MMAMixIn(data_input=None, filename=None, objectid=None, mode=None, release=None, download=None, ignore_db=False, use_db=None)[source]¶ Bases:
abc.ABCMixin for implementing multi-modal data access
This is a mixin class that adds multi-modal data access to any class that subclasses from this one. The MMA allows toggling between local and remote data access modes, or leaving it on automatic. Local mode access tries to load data via a database, if one exists, otherwise it loads data via a local filepath. Remote mode will try to load data over an API. When the mode is set to “auto”, it automatically tries to first load things locally, and then remotely. Depending on the mode and logic, the MMA will set data_origin to either
file,db, orapi.- This mixin contains two abstractmethods you must override when subclassing.
_set_access_path_params: sets the arguments needed by
sdss_access_parse_inputs: provides logic to parse
data_inputinto either filename or objectid
- Parameters
data_input (str) – The file or name of target data to load
filename (str) – The absolute filepath to data to load
objectid (str) – The object identifier of the data to load
mode (str) – The operating mode: auto, local, or remote
release (str) – The data release of the object, e.g. “DR16”
download (bool) – If True, downloads the object locally with sdss_access
ignore_db (bool) – If True, ignores any database connection for local access
use_db (sdssdb.DatabaseConnection) – a database connection to override the default with
- Variables
-
get_full_path(url=None)[source]¶ Returns the full path of the file in the tree.
- Parameters
url (bool) – If True, specifies the url location rather than the local file location
- Returns
The full path as built by sdss_access
-
property
access¶ Returns an instance of
sdss_access.Access
-
property
release¶ Returns the release.
-
class
sdss_brain.core.Brain(data_input=None, filename=None, objectid=None, mode=None, data=None, release=None, download=None, ignore_db=None, use_db=None)[source]¶ Bases:
sdss_brain.core.Base,sdss_brain.mma.MMAMixInConvenience class for utilizing the MMA mixin
This is a convenience class with the
MMAMixInalready implemented. This class initializes theMMAMixInand provides logic to load data based on the data_origin. It also provides a simplerepr.- This class contains three abstractmethods you must override when subclassing.
_load_object_from_file: defines data load/handling from a local file
_load_object_from_db: defines data load/handling from a local database
_load_object_from_api: defines data load/handling from a remote API
- Parameters
data_input (str) – The file or name of target data to load
filename (str) – The absolute filepath to data to load
objectid (str) – The object identifier of the data to load
mode (str) – The operating mode: auto, local, or remote
release (str) – The data release of the object, e.g. “DR16”
data (object) – Optional data to instantiate the object with
download (bool) – If True, downloads the object locally with sdss_access
ignore_db (bool) – If True, ignores any database connection for local access
use_db (sdssdb.DatabaseConnection) – a database connection to override the default with
- Variables
_db (sdssdb.DatabaseConnection) – A relevant sdssdb database connection for the object
mapped_version (str) – The name of survey/category in the mapped_versions dictionary
-
mapped_version= None¶
Helpers¶
-
sdss_brain.helpers.get_mapped_version(name, release=None, key=None)[source]¶ Get a version id mapped to a release number
For a given named category, looks up the “mapped_versions” attribute from the configuration yaml file and returns a version number that has been mapped to a specific release. For example, for manga, DR16 maps to drpver=’v2_4_3’ and dapver=’2.2.1’. This can be useful when needing to specify certain versions when defining paths to files.
- Parameters
Example
>>> # access the MaNGA versions for release DR16 >>> get_mapped_version('manga', release='DR16') >>> {'drpver': 'v2_4_3', 'dapver': '2.2.1'} >>> >>> # access specific key >>> get_mapped_version('manga', release='DR16', key='drpver') >>> 'v2_4_3'
