CosmoSimClass

class astroquery.cosmosim.CosmoSimClass[source]

Bases: astroquery.query.QueryWithLogin

Attributes Summary

QUERY_URL

SCHEMA_URL

TIMEOUT

USERNAME

Methods Summary

abort_job([jobid])

check_all_jobs([phase, regex, sortby])

Public function which builds a dictionary whose keys are each jobid for a given set of user credentials and whose values are the phase status (e.g.

check_job_status([jobid])

A public function which sends an http GET request for a given jobid, and checks the server status.

check_login_status()

Public function which checks the status of a user login attempt.

completed_job_info([jobid, output])

A public function which sends an http GET request for a given jobid with phase COMPLETED.

delete_all_jobs([phase, regex])

A public function which deletes any/all jobs from the server in any phase and/or with its tablename matching any desired regular expression.

delete_job([jobid, squash])

A public function which deletes a stored job from the server in any phase.

download([jobid, filename, format, cache])

A public function to download data from a job with COMPLETED phase.

explore_db([db, table, col])

A public function which allows for the exploration of any simulation and its tables within the database.

general_job_info([jobid, output])

A public function which sends an http GET request for a given jobid in any phase.

login([username, password, store_password, ...])

Login to the CosmoSim database.

logout([deletepw])

Public function which allows the user to logout of their cosmosim credentials.

run_sql_query(query_string[, tablename, ...])

Public function which sends a POST request containing the sql query string.

Attributes Documentation

QUERY_URL = 'https://www.cosmosim.org/uws/query'
SCHEMA_URL = 'https://www.cosmosim.org/query/account/databases/json'
TIMEOUT = 60.0
USERNAME = ''

Methods Documentation

abort_job(jobid=None)[source]
check_all_jobs(phase=None, regex=None, sortby=None)[source]

Public function which builds a dictionary whose keys are each jobid for a given set of user credentials and whose values are the phase status (e.g. - EXECUTING,COMPLETED,PENDING,ERROR).

Parameters
phaselist

A list of phase(s) of jobs to be checked on. If nothing provided, all are checked.

regexstring

A regular expression to match all tablenames to. Matching table names will be included. Note - Only tables/starttimes are associated with jobs which have phase COMPLETED.

sortbystring

An option to sort jobs (after phase and regex criteria have been taken into account) by either the execution start time (starttime), or by the table name ('tablename').

Returns
checkalljobsResponse object

The requests response for the GET request for finding all existing jobs.

check_job_status(jobid=None)[source]

A public function which sends an http GET request for a given jobid, and checks the server status. If no jobid is provided, it uses the most recent query (if one exists).

Parameters
jobidstring

The jobid of the sql query. If no jobid is given, it attempts to use the most recent job (if it exists in this session).

Returns
resultcontent of Response object

The requests response phase

check_login_status()[source]

Public function which checks the status of a user login attempt.

completed_job_info(jobid=None, output=False)[source]

A public function which sends an http GET request for a given jobid with phase COMPLETED. If output is True, the function prints a dictionary to the screen, while always generating a global dictionary response_dict_current. If no jobid is provided, a visual of all responses with phase COMPLETED is generated.

Parameters
jobidstring

The jobid of the sql query.

outputbool

Print output of response(s) to the terminal

delete_all_jobs(phase=None, regex=None)[source]

A public function which deletes any/all jobs from the server in any phase and/or with its tablename matching any desired regular expression.

Parameters
phaselist

A list of job phases to be deleted. If nothing provided, all are deleted.

regexstring

A regular expression to match all tablenames to. Matching table names will be deleted.

delete_job(jobid=None, squash=None)[source]

A public function which deletes a stored job from the server in any phase. If no jobid is given, it attempts to use the most recent job (if it exists in this session). If jobid is specified, then it deletes the corresponding job, and if it happens to match the existing current job, that variable gets deleted.

Parameters
jobidstring

The jobid of the sql query. If no jobid is given, it attempts to use the most recent job (if it exists in this session).

outputbool

Print output of response(s) to the terminal

Returns
resultlist

A list of response object(s)

download(jobid=None, filename=None, format=None, cache=True)[source]

A public function to download data from a job with COMPLETED phase.

Parameters
jobid

Completed jobid to be downloaded

filenamestr

If left blank, downloaded to the terminal. If specified, data is written out to file (directory can be included here).

formatstr

The format of the data to be downloaded. Options are 'csv', 'votable', 'votableB1', and 'votableB2'.

cachebool

Whether to cache the data. By default, this is set to True.

Returns
headers, datalist, list
explore_db(db=None, table=None, col=None)[source]

A public function which allows for the exploration of any simulation and its tables within the database. This function is meant to aid the user in constructing sql queries.

Parameters
dbstring

The database to explore.

tablestring

The table to explore.

colstring

The column to explore.

general_job_info(jobid=None, output=False)[source]

A public function which sends an http GET request for a given jobid in any phase. If no jobid is provided, a summary of all jobs is generated.

Parameters
jobidstring

The jobid of the sql query.

outputbool

Print output of response(s) to the terminal

login(username=None, password=None, store_password=False, reenter_password=False)

Login to the CosmoSim database.

Parameters
usernamestr, optional

Username to the CosmoSim database. If not given, it should be specified in the config file.

store_passwordbool, optional

Stores the password securely in your keyring. Default is False.

reenter_passwordbool, optional

Asks for the password even if it is already stored in the keyring. This is the way to overwrite an already stored passwork on the keyring. Default is False.

logout(deletepw=False)[source]

Public function which allows the user to logout of their cosmosim credentials.

Parameters
deletepwbool

A hard logout - delete the password to the associated username from the keychain. The default is True.

Returns
run_sql_query(query_string, tablename=None, queue=None, mail=None, text=None, cache=True)[source]

Public function which sends a POST request containing the sql query string.

Parameters
query_stringstring

The sql query to be sent to the CosmoSim.org server.

tablenamestring

The name of the table for which the query data will be stored under. If left blank or if it already exists, one will be generated automatically.

queuestring

The short/long queue option. Default is short.

mailstring

The user’s email address for receiving job completion alerts.

textstring

The user’s cell phone number for receiving job completion alerts.

cachebool

Whether to cache the query locally

Returns
resultjobid

The jobid of the query