/saga

code to access, create and edit SAGA data catalogs

Primary LanguagePythonMIT LicenseMIT

SAGA

This package contains code to access, create and edit SAGA data catalogs.

See the SAGA Survey website for details about SAGA.

Installation

To install the code, run:

pip install https://github.com/sagasurvey/saga/archive/master.zip

To force an update, run

pip install --upgrade --no-deps --force-reinstall https://github.com/sagasurvey/saga/archive/master.zip

The code is designed to be 2-3 compatible, but has mainly been tested with Python 3.6.

Dependencies

All required dependencies will be installed automatically. There are two optional dependencies that require manual installation:

  1. casjobs OR sciservevr

    You need to install casjobs or sciservevr to download SDSS catalogs.

    • To install casjobs:

      pip install https://github.com/dfm/casjobs/archive/master.zip 

      (Note: Do NOT use pip install casjobs)

    • To install sciservevr:

      pip install -e "git+https://github.com/sciserver/SciScript-Python.git#egg=SciServer-1.10.2&subdirectory=py3"

    In both cases you need to set environmental variables to store your credentials. (CASJOBS_WSID and CASJOBS_PW for casjobs; SCISERVER_USER and SCISERVER_PASS for sciserver).

  2. kcorrect

    You need kcorrect to calculate stellar masses. You need to install both the C code and the Python wrapper.

Example Usage

See more examples at https://github.com/sagasurvey/examples/tree/master/notebooks

import SAGA
from SAGA import ObjectCuts as C

saga_database = SAGA.Database('/path/to/saga/dropbox/folder', '/path/to/saga/local/folder')
saga_host_catalog = SAGA.HostCatalog(saga_database)
saga_object_catalog = SAGA.ObjectCatalog(saga_database)

# load host list (all)
hosts = saga_host_catalog.load('all')

# load host list (no flags, i.e. has SDSS)
hosts_no_flag = saga_host_catalog.load('flag0')

# load all (Paper 1) specs with some basic cuts
specs = saga_object_catalog.load(has_spec=True, cuts=C.basic_cut, version='paper1')

# load base catalogs for all paper1 hosts with the same basic cuts into a list:
base_paper1 = saga_object_catalog.load(hosts='paper1', cuts=C.basic_cut, return_as='list', version='paper1')

# count number of satellites
for base in base_paper1:
    print(base['HOST_NSAID'][0], '# of satellites', C.is_sat.count(base))

# load all base catalogs with the same basic cuts into a list
base_all = saga_object_catalog.load('flag0', cuts=C.basic_cut, return_as='list', version='paper1')