Database Schema

SkyPortal uses a PostgreSQL database to manage persistent state. This section documents the schema of the database and describes how the application interacts with it.

SQLAlchemy Model API Documentation

The SkyPortal Python backend interacts with the PostgreSQL backend using the SQLAlchemy object relational mapper. Each database table is represented by a Python class, and each table Column is represented by a class attribute. This Section documents each of the SkyPortal and baselayer classes that are mapped to database tables.

class skyportal.models.Allocation(**kwargs)

An allocation of observing time on a robotic instrument.

Attributes
created_at

UTC time of insertion of object’s row into the database.

end_date

The UTC end date of the allocation.

group

The Group the allocation is associated with.

group_id

The ID of the Group the allocation is associated with.

hours_allocated

The number of hours allocated.

id

Unique object identifier.

instrument

The Instrument the allocation is associated with.

instrument_id

The ID of the Instrument the allocation is associated with.

modified

UTC time the object’s row was last modified in the database.

pi

The PI of the allocation’s proposal.

proposal_id

The ID of the proposal associated with this allocation.

requests

The requests made against this allocation.

start_date

The UTC start date of the allocation.

Methods

create_or_get(id)

Return a new cls if an instance with the specified primary key does not exist, else return the existing instance.

get_if_owned_by(ident, user_or_token[, options])

Return an object from the database if the requesting User or Token has access to read the object.

is_owned_by(user_or_token)

Generic ownership logic for any skyportal ORM model.

to_dict()

Serialize this object to a Python dictionary.

created_at

UTC time of insertion of object’s row into the database.

end_date

The UTC end date of the allocation.

group

The Group the allocation is associated with.

group_id

The ID of the Group the allocation is associated with.

hours_allocated

The number of hours allocated.

id

Unique object identifier.

instrument

The Instrument the allocation is associated with.

instrument_id

The ID of the Instrument the allocation is associated with.

modified

UTC time the object’s row was last modified in the database.

pi

The PI of the allocation’s proposal.

proposal_id

The ID of the proposal associated with this allocation.

requests

The requests made against this allocation.

start_date

The UTC start date of the allocation.

class skyportal.models.ArrayOfEnum(item_type, as_tuple=False, dimensions=None, zero_indexes=False)
Attributes
hashable

bool(x) -> bool

python_type

Return the Python type object expected to be returned by instances of this type, if known.

Methods

Comparator(expr)

Define comparison operations for ARRAY.

adapt(cls, **kw)

Produce an “adapted” form of this type, given an “impl” class to work with.

bind_expression(bindvalue)

“Given a bind value (i.e.

bind_processor(dialect)

Return a conversion function for processing bind values.

coerce_compared_value(op, value)

Suggest a type for a ‘coerced’ Python value in an expression.

column_expression(colexpr)

Given a SELECT column expression, return a wrapping SQL expression.

comparator_factory

alias of sqlalchemy.dialects.postgresql.array.ARRAY.Comparator

compare_against_backend(dialect, conn_type)

Compare this type against the given backend type.

compare_values(x, y)

Compare two values for equality.

compile([dialect])

Produce a string-compiled form of this TypeEngine.

dialect_impl(dialect)

Return a dialect-specific implementation for this TypeEngine.

evaluates_none()

Return a copy of this type which has the should_evaluate_none flag set to True.

get_dbapi_type(dbapi)

Return the corresponding type object from the underlying DB-API, if any.

literal_processor(dialect)

Return a conversion function for processing literal values that are to be rendered directly without using binds.

result_processor(dialect, coltype)

Return a conversion function for processing result row values.

with_variant(type_, dialect_name)

Produce a new type object that will utilize the given type when applied to the dialect of the given name.

copy

copy_value

bind_expression(bindvalue)

“Given a bind value (i.e. a BindParameter instance), return a SQL expression in its place.

This is typically a SQL function that wraps the existing bound parameter within the statement. It is used for special data types that require literals being wrapped in some special database function in order to coerce an application-level value into a database-specific format. It is the SQL analogue of the TypeEngine.bind_processor() method.

The method is evaluated at statement compile time, as opposed to statement construction time.

Note that this method, when implemented, should always return the exact same structure, without any conditional logic, as it may be used in an executemany() call against an arbitrary number of bound parameter sets.

See also

types_sql_value_processing

result_processor(dialect, coltype)

Return a conversion function for processing result row values.

Returns a callable which will receive a result row column value as the sole positional argument and will return a value to return to the user.

If processing is not necessary, the method should return None.

Parameters
  • dialect – Dialect instance in use.

  • coltype – DBAPI coltype argument received in cursor.description.

class skyportal.models.ClassicalAssignment(**kwargs)

Assignment of an Obj to an Observing Run as a target.

Attributes
comment

A comment on the assignment. Typically a justification for the request, or instructions for taking the data.

created_at

UTC time of insertion of object’s row into the database.

id

Unique object identifier.

last_modified_by
last_modified_by_id
modified

UTC time the object’s row was last modified in the database.

obj

The assigned Obj.

obj_id

ID of the assigned Obj.

photometry

Photometry produced by the assignment.

priority

Priority of the request (1 = lowest, 5 = highest).

requester

The User who created this assignment.

requester_id

The ID of the User who created this assignment.

rise_time

The UTC time at which the object rises on this run.

run

The ObservingRun this target was assigned to.

run_id

ID of the ObservingRun this target was assigned to.

set_time

The UTC time at which the object sets on this run.

spectra

Spectra produced by the assignment.

status

Status of the assignment [done, not done, pending].

Methods

create_or_get(id)

Return a new cls if an instance with the specified primary key does not exist, else return the existing instance.

get_if_owned_by(ident, user_or_token[, options])

Return an object from the database if the requesting User or Token has access to read the object.

is_owned_by(user_or_token)

Generic ownership logic for any skyportal ORM model.

to_dict()

Serialize this object to a Python dictionary.

comment

A comment on the assignment. Typically a justification for the request, or instructions for taking the data.

created_at

UTC time of insertion of object’s row into the database.

id

Unique object identifier.

instrument

The instrument in use on the assigned ObservingRun.

modified

UTC time the object’s row was last modified in the database.

obj

The assigned Obj.

obj_id

ID of the assigned Obj.

photometry

Photometry produced by the assignment.

priority

Priority of the request (1 = lowest, 5 = highest).

requester

The User who created this assignment.

requester_id

The ID of the User who created this assignment.

property rise_time

The UTC time at which the object rises on this run.

run

The ObservingRun this target was assigned to.

run_id

ID of the ObservingRun this target was assigned to.

property set_time

The UTC time at which the object sets on this run.

spectra

Spectra produced by the assignment.

status

Status of the assignment [done, not done, pending].

class skyportal.models.Classification(**kwargs)

Classification of an Obj.

Attributes
author

The User that made this classification.

author_id

ID of the User that made this Classification

author_name

User.username or Token.id of the Classification’s author.

classification

The assigned class.

created_at

UTC time of insertion of object’s row into the database.

groups

Groups that can access this Classification.

id

Unique object identifier.

modified

UTC time the object’s row was last modified in the database.

obj

The Classification’s Obj.

obj_id

ID of the Classification’s Obj.

probability

User-assigned probability of belonging to this class

taxonomy

Taxonomy in which this Classification was made.

taxonomy_id

ID of the Taxonomy in which this Classification was made.

Methods

create_or_get(id)

Return a new cls if an instance with the specified primary key does not exist, else return the existing instance.

get_if_owned_by(ident, user_or_token[, options])

Return an object from the database if the requesting User or Token has access to read the object.

is_owned_by(user_or_token)

Generic ownership logic for any skyportal ORM model.

to_dict()

Serialize this object to a Python dictionary.

author

The User that made this classification.

author_id

ID of the User that made this Classification

author_name

User.username or Token.id of the Classification’s author.

classification

The assigned class.

created_at

UTC time of insertion of object’s row into the database.

groups

Groups that can access this Classification.

id

Unique object identifier.

modified

UTC time the object’s row was last modified in the database.

obj

The Classification’s Obj.

obj_id

ID of the Classification’s Obj.

probability

User-assigned probability of belonging to this class

taxonomy

Taxonomy in which this Classification was made.

taxonomy_id

ID of the Taxonomy in which this Classification was made.

class skyportal.models.Comment(**kwargs)

A comment made by a User or a Robot (via the API) on a Source.

Attributes
attachment_bytes

Binary representation of the attachment.

attachment_name

Filename of the attachment.

attachment_type

Attachment extension, (e.g., pdf, png).

author

Comment’s author.

author_id

ID of the Comment author’s User instance.

created_at

UTC time of insertion of object’s row into the database.

ctype

Comment type. Can be one of ‘text’ or ‘redshift’.

groups

Groups that can see the comment.

id

Unique object identifier.

modified

UTC time the object’s row was last modified in the database.

obj

The Comment’s Obj.

obj_id

ID of the Comment’s Obj.

origin

Comment origin.

text

Comment body.

Methods

create_or_get(id)

Return a new cls if an instance with the specified primary key does not exist, else return the existing instance.

get_if_owned_by(ident, user[, options])

Return an object from the database if the requesting User or Token has access to read the object.

is_owned_by(user_or_token)

Generic ownership logic for any skyportal ORM model.

to_dict()

Serialize this object to a Python dictionary.

construct_author_info_dict

attachment_bytes

Binary representation of the attachment.

attachment_name

Filename of the attachment.

attachment_type

Attachment extension, (e.g., pdf, png).

author

Comment’s author.

author_id

ID of the Comment author’s User instance.

created_at

UTC time of insertion of object’s row into the database.

ctype

Comment type. Can be one of ‘text’ or ‘redshift’.

classmethod get_if_owned_by(ident, user, options=[])

Return an object from the database if the requesting User or Token has access to read the object. If the requesting User or Token does not have access, raise an AccessError.

Parameters
identinteger or string

Primary key of the requested object.

user_or_tokenbaselayer.app.models.User or baselayer.app.models.Token

The requesting User or Token object.

optionslist of `sqlalchemy.orm.MapperOption`s

Options that wil be passed to options() in the loader query.

Returns
objbaselayer.app.models.Base

The requested entity.

groups

Groups that can see the comment.

id

Unique object identifier.

modified

UTC time the object’s row was last modified in the database.

obj

The Comment’s Obj.

obj_id

ID of the Comment’s Obj.

origin

Comment origin.

text

Comment body.

class skyportal.models.Filter(**kwargs)

An alert filter that operates on a Stream. A Filter is associated with exactly one Group, and a Group may have multiple operational Filters.

Attributes
created_at

UTC time of insertion of object’s row into the database.

group

The Filter’s Group.

group_id

ID of the Filter’s Group.

id

Unique object identifier.

modified

UTC time the object’s row was last modified in the database.

name

Filter name.

stream

The Filter’s Stream.

stream_id

ID of the Filter’s Stream.

Methods

create_or_get(id)

Return a new cls if an instance with the specified primary key does not exist, else return the existing instance.

get_if_owned_by(ident, user_or_token[, options])

Return an object from the database if the requesting User or Token has access to read the object.

is_owned_by(user_or_token)

Generic ownership logic for any skyportal ORM model.

to_dict()

Serialize this object to a Python dictionary.

created_at

UTC time of insertion of object’s row into the database.

group

The Filter’s Group.

group_id

ID of the Filter’s Group.

id

Unique object identifier.

modified

UTC time the object’s row was last modified in the database.

name

Filter name.

stream

The Filter’s Stream.

stream_id

ID of the Filter’s Stream.

class skyportal.models.FollowupRequest(**kwargs)

A request for follow-up data (spectroscopy, photometry, or both) using a robotic instrument.

Attributes
allocation
allocation_id
created_at

UTC time of insertion of object’s row into the database.

id

Unique object identifier.

instrument
modified

UTC time the object’s row was last modified in the database.

obj

The target Obj.

obj_id

ID of the target Obj.

payload

Content of the followup request.

photometry
requester

The User who requested the follow-up.

requester_id

ID of the User who requested the follow-up.

spectra
status

The status of the request.

transactions

Methods

create_or_get(id)

Return a new cls if an instance with the specified primary key does not exist, else return the existing instance.

get_if_owned_by(ident, user_or_token[, options])

Return an object from the database if the requesting User or Token has access to read the object.

is_owned_by(user_or_token)

Return a boolean indicating whether a FollowupRequest belongs to an allocation that is accessible to the given user or token.

to_dict()

Serialize this object to a Python dictionary.

created_at

UTC time of insertion of object’s row into the database.

id

Unique object identifier.

is_owned_by(user_or_token)

Return a boolean indicating whether a FollowupRequest belongs to an allocation that is accessible to the given user or token.

Parameters
user_or_token: `baselayer.app.models.User` or `baselayer.app.models.Token`

The User or Token to check.

Returns
owned: bool

Whether the FollowupRequest belongs to an Allocation that is accessible to the given user or token.

modified

UTC time the object’s row was last modified in the database.

obj

The target Obj.

obj_id

ID of the target Obj.

payload

Content of the followup request.

requester

The User who requested the follow-up.

requester_id

ID of the User who requested the follow-up.

status

The status of the request.

class skyportal.models.Group(**kwargs)

A user group. Group`s controls `User access to Filter`s and serve as targets for data sharing requests. `Photometry and Spectra shared with a Group will be visible to all its members. Group`s maintain specific `Stream permissions. In order for a User to join a Group, the User must have access to all of the Group’s data `Stream`s.

Attributes
allocations

Allocations made to this group.

created_at

UTC time of insertion of object’s row into the database.

filters

All filters (not just active) associated with a group.

group_users

Elements of a join table mapping Users to Groups.

id

Unique object identifier.

modified

UTC time the object’s row was last modified in the database.

name

Name of the group.

observing_runs

The observing runs associated with this group.

photometry

The photometry visible to this group.

single_user_group

Flag indicating whether this group is a singleton group for one user only.

spectra

The spectra visible to this group.

streams

Stream access required for a User to become a member of the Group.

users

The members of this group.

Methods

create_or_get(id)

Return a new cls if an instance with the specified primary key does not exist, else return the existing instance.

get_if_owned_by(ident, user_or_token[, options])

Return an object from the database if the requesting User or Token has access to read the object.

is_owned_by(user_or_token)

Generic ownership logic for any skyportal ORM model.

to_dict()

Serialize this object to a Python dictionary.

allocations

Allocations made to this group.

created_at

UTC time of insertion of object’s row into the database.

filters

All filters (not just active) associated with a group.

group_users

Elements of a join table mapping Users to Groups.

id

Unique object identifier.

modified

UTC time the object’s row was last modified in the database.

name

Name of the group.

observing_runs

The observing runs associated with this group.

photometry

The photometry visible to this group.

single_user_group

Flag indicating whether this group is a singleton group for one user only.

spectra

The spectra visible to this group.

streams

Stream access required for a User to become a member of the Group.

users

The members of this group.

class skyportal.models.Instrument(**kwargs)

An instrument attached to a telescope.

Attributes
allocations
api_class
api_classname

Name of the instrument’s API class.

band

The spectral band covered by the instrument (e.g., Optical, IR).

created_at

UTC time of insertion of object’s row into the database.

does_imaging

Return a boolean indicating whether the instrument is capable of performing imaging.

does_spectroscopy

Return a boolean indicating whether the instrument is capable of performing spectroscopy.

filters

List of filters on the instrument (if any).

id

Unique object identifier.

listener_class
listener_classname

Name of the instrument’s listener class.

modified

UTC time the object’s row was last modified in the database.

name

Instrument name.

observing_runs

List of ObservingRuns on the Instrument.

photometry

The Photometry produced by this instrument.

spectra

The Spectra produced by this instrument.

telescope

The Telescope that hosts the Instrument.

telescope_id

The ID of the Telescope that hosts the Instrument.

type

Instrument type, one of Imager, Spectrograph, or Imaging Spectrograph.

Methods

create_or_get(id)

Return a new cls if an instance with the specified primary key does not exist, else return the existing instance.

get_if_owned_by(ident, user_or_token[, options])

Return an object from the database if the requesting User or Token has access to read the object.

is_owned_by(user_or_token)

Generic ownership logic for any skyportal ORM model.

to_dict()

Serialize this object to a Python dictionary.

api_classname

Name of the instrument’s API class.

band

The spectral band covered by the instrument (e.g., Optical, IR).

created_at

UTC time of insertion of object’s row into the database.

property does_imaging

Return a boolean indicating whether the instrument is capable of performing imaging.

property does_spectroscopy

Return a boolean indicating whether the instrument is capable of performing spectroscopy.

filters

List of filters on the instrument (if any).

id

Unique object identifier.

listener_classname

Name of the instrument’s listener class.

modified

UTC time the object’s row was last modified in the database.

name

Instrument name.

observing_runs

List of ObservingRuns on the Instrument.

photometry

The Photometry produced by this instrument.

spectra

The Spectra produced by this instrument.

telescope

The Telescope that hosts the Instrument.

telescope_id

The ID of the Telescope that hosts the Instrument.

type

Instrument type, one of Imager, Spectrograph, or Imaging Spectrograph.

class skyportal.models.NumpyArray(*args, **kwargs)

SQLAlchemy representation of a NumPy array.

Attributes
comparator_factory

Base class for custom comparison operations defined at the type level.

python_type

Return the Python type object expected to be returned by instances of this type, if known.

Methods

Comparator(expr)

A TypeEngine.Comparator that is specific to TypeDecorator.

adapt(cls, **kw)

Produce an “adapted” form of this type, given an “impl” class to work with.

bind_expression(bindparam)

“Given a bind value (i.e.

bind_processor(dialect)

Provide a bound value processing function for the given Dialect.

coerce_compared_value(op, value)

Suggest a type for a ‘coerced’ Python value in an expression.

column_expression(column)

Given a SELECT column expression, return a wrapping SQL expression.

compare_against_backend(dialect, conn_type)

Compare this type against the given backend type.

compare_values(x, y)

Given two values, compare them for equality.

compile([dialect])

Produce a string-compiled form of this TypeEngine.

copy(**kw)

Produce a copy of this TypeDecorator instance.

dialect_impl(dialect)

Return a dialect-specific implementation for this TypeEngine.

evaluates_none()

Return a copy of this type which has the should_evaluate_none flag set to True.

get_dbapi_type(dbapi)

Return the DBAPI type object represented by this TypeDecorator.

literal_processor(dialect)

Provide a literal processing function for the given Dialect.

load_dialect_impl(dialect)

Return a TypeEngine object corresponding to a dialect.

process_bind_param(value, dialect)

Receive a bound parameter value to be converted.

process_literal_param(value, dialect)

Receive a literal parameter value to be rendered inline within a statement.

process_result_value(value, dialect)

Receive a result-row column value to be converted.

result_processor(dialect, coltype)

Provide a result value processing function for the given Dialect.

type_engine(dialect)

Return a dialect-specific TypeEngine instance for this TypeDecorator.

with_variant(type_, dialect_name)

Produce a new type object that will utilize the given type when applied to the dialect of the given name.

copy_value

process_result_value(value, dialect)

Receive a result-row column value to be converted.

Subclasses should implement this method to operate on data fetched from the database.

Subclasses override this method to return the value that should be passed back to the application, given a value that is already processed by the underlying TypeEngine object, originally from the DBAPI cursor method fetchone() or similar.

The operation could be anything desired to perform custom behavior, such as transforming or serializing data. This could also be used as a hook for validating logic.

Parameters
  • value – Data to operate upon, of any type expected by this method in the subclass. Can be None.

  • dialect – the Dialect in use.

This operation should be designed to be reversible by the “process_bind_param” method of this class.

class skyportal.models.Obj(**kwargs)

A record of an astronomical Object and its metadata, such as position, positional uncertainties, name, and redshift. Permissioning rules, such as group ownership, user visibility, etc., are managed by other entities, namely Source and Candidate.

Attributes
altdata

Misc. alternative metadata stored in JSON format, e.g. {‘gaia’: {‘info’: {‘Teff’: 5780}}}

assignments

Assignments of the object to classical observing runs.

candidates

Instances in which this Obj passed a group’s filter.

cartesian

Convert to Cartesian coordinates.

x, y, zfloat

A tuple of the x, y, and z coordinates.

classifications

Classifications of the object.

comments

Comments posted about the object.

created_at

UTC time of insertion of object’s row into the database.

dec
dec_dis

J2000 Declination at discovery time [deg].

dec_err

Error on J2000 Declination at discovery time [deg].

desi_dr8_url

Construct URL for public DESI DR8 cutout.

detect_photometry_count

How many times the object was detected above \(S/N = 5\).

dist_nearest_source

Distance to the nearest Obj [arcsec].

e_mag_nearest_source

Error on magnitude of the nearest Obj [mag].

followup_requests

Robotic follow-up requests of the object.

gal_lat_deg

Get the galactic latitute of this object

gal_lon_deg

Get the galactic longitude of this object

id

Name of the object.

internal_key

Internal key used for secure websocket messaging.

is_roid

Boolean indicating whether the object is a moving object.

last_detected

UTC ISO date at which the object was last detected above a S/N of 5.

mag_nearest_source

Magnitude of the nearest Obj [AB].

modified

UTC time the object’s row was last modified in the database.

offset

Offset from nearest static object [arcsec].

origin

Origin of the object.

photometry

Photometry of the object.

ra
ra_dis

J2000 Right Ascension at discovery time [deg].

ra_err

Error on J2000 Right Ascension at discovery time [deg].

redshift

Redshift.

score

Machine learning score.

sdss_url

Construct URL for public Sloan Digital Sky Survey (SDSS) cutout.

sources

Instances in which a group saved this Obj.

spectra

Spectra of the object.

target

Representation of the RA and Dec of this Obj as an astroplan.FixedTarget.

thumbnails

Thumbnails of the object.

transient

Boolean indicating whether the object is an astrophysical transient.

users
varstar

Boolean indicating whether the object is a variable star.

Methods

add_linked_thumbnails()

Determine the URLs of the SDSS and DESI DR8 thumbnails of the object, insert them into the Thumbnails table, and link them to the object.

airmass(telescope, time[, below_horizon])

Return the airmass of the object at a given time.

altitude(telescope, time)

Return the altitude of the object at a given time.

create_or_get(id)

Return a new cls if an instance with the specified primary key does not exist, else return the existing instance.

get_classifications_owned_by(user_or_token)

Query the database and return the Classifications on this Obj that are accessible to any of the User or Token owner’s accessible Groups.

get_comments_owned_by(user_or_token)

Query the database and return the Comments on this Obj that are accessible to any of the User or Token owner’s accessible Groups.

get_if_owned_by(user_or_token[, options])

Return an Obj from the database if the Obj is either a Source or a Candidate in at least one of the requesting User or Token owner’s accessible Groups.

get_photometry_owned_by_user(user_or_token)

Query the database and return the Photometry for this Obj that is shared with any of the User or Token owner’s accessible Groups.

get_spectra_owned_by(user_or_token)

Query the database and return the Spectra for this Obj that are shared with any of the User or Token owner’s accessible Groups.

is_owned_by(user_or_token)

Generic ownership logic for any skyportal ORM model.

to_dict()

Serialize this object to a Python dictionary.

within(other, radius)

Test if this point is within a given radius of another point.

add_linked_thumbnails()

Determine the URLs of the SDSS and DESI DR8 thumbnails of the object, insert them into the Thumbnails table, and link them to the object.

airmass(telescope, time, below_horizon=inf)

Return the airmass of the object at a given time. Uses the Pickering (2002) interpolation of the Rayleigh (molecular atmosphere) airmass.

The Pickering interpolation tends toward 38.7494 as the altitude approaches zero.

Parameters
telescopeskyportal.models.Telescope

The telescope to use for the airmass calculation

timeastropy.time.Time or list of astropy.time.Time`

The time or times at which to calculate the airmass

below_horizonscalar, Numeric

Airmass value to assign when an object is below the horizon. An object is “below the horizon” when its altitude is less than zero degrees.

Returns
airmassndarray

The airmass of the Obj at the requested times

altdata

Misc. alternative metadata stored in JSON format, e.g. {‘gaia’: {‘info’: {‘Teff’: 5780}}}

altitude(telescope, time)

Return the altitude of the object at a given time.

Parameters
telescopeskyportal.models.Telescope

The telescope to use for the altitude calculation

timeastropy.time.Time

The time or times at which to calculate the altitude

Returns
altastropy.coordinates.AltAz

The altitude of the Obj at the requested times

assignments

Assignments of the object to classical observing runs.

candidates

Instances in which this Obj passed a group’s filter.

classifications

Classifications of the object.

comments

Comments posted about the object.

created_at

UTC time of insertion of object’s row into the database.

dec_dis

J2000 Declination at discovery time [deg].

dec_err

Error on J2000 Declination at discovery time [deg].

property desi_dr8_url

Construct URL for public DESI DR8 cutout.

detect_photometry_count

How many times the object was detected above \(S/N = 5\).

dist_nearest_source

Distance to the nearest Obj [arcsec].

e_mag_nearest_source

Error on magnitude of the nearest Obj [mag].

followup_requests

Robotic follow-up requests of the object.

property gal_lat_deg

Get the galactic latitute of this object

property gal_lon_deg

Get the galactic longitude of this object

get_classifications_owned_by(user_or_token)

Query the database and return the Classifications on this Obj that are accessible to any of the User or Token owner’s accessible Groups.

Parameters
user_or_tokenbaselayer.app.models.User or baselayer.app.models.Token

The requesting User or Token object.

Returns
comment_listlist of skyportal.models.Classification

The accessible classifications attached to this Obj.

get_comments_owned_by(user_or_token)

Query the database and return the Comments on this Obj that are accessible to any of the User or Token owner’s accessible Groups.

Parameters
user_or_tokenbaselayer.app.models.User or baselayer.app.models.Token

The requesting User or Token object.

Returns
comment_listlist of skyportal.models.Comment

The accessible comments attached to this Obj.

get_if_owned_by(user_or_token, options=[])

Return an Obj from the database if the Obj is either a Source or a Candidate in at least one of the requesting User or Token owner’s accessible Groups. If the Obj is not a Source or a Candidate in one of the User or Token owner’s accessible Groups, raise an AccessError. If the Obj does not exist, return None.

Parameters
obj_idinteger or string

Primary key of the Obj.

user_or_tokenbaselayer.app.models.User or baselayer.app.models.Token

The requesting User or Token object.

optionslist of `sqlalchemy.orm.MapperOption`s

Options that wil be passed to options() in the loader query.

Returns
objskyportal.models.Obj

The requested Obj.

get_photometry_owned_by_user(user_or_token)

Query the database and return the Photometry for this Obj that is shared with any of the User or Token owner’s accessible Groups.

Parameters
obj_idstring

The ID of the Obj to look up.

user_or_tokenbaselayer.app.models.User or baselayer.app.models.Token

The requesting User or Token object.

Returns
photometry_listlist of skyportal.models.Photometry

The accessible Photometry of this Obj.

get_spectra_owned_by(user_or_token)

Query the database and return the Spectra for this Obj that are shared with any of the User or Token owner’s accessible Groups.

Parameters
obj_idstring

The ID of the Obj to look up.

user_or_tokenbaselayer.app.models.User or baselayer.app.models.Token

The requesting User or Token object.

Returns
photometry_listlist of skyportal.models.Spectrum

The accessible Spectra of this Obj.

id

Name of the object.

internal_key

Internal key used for secure websocket messaging.

is_roid

Boolean indicating whether the object is a moving object.

last_detected

UTC ISO date at which the object was last detected above a S/N of 5.

mag_nearest_source

Magnitude of the nearest Obj [AB].

modified

UTC time the object’s row was last modified in the database.

offset

Offset from nearest static object [arcsec].

origin

Origin of the object.

photometry

Photometry of the object.

ra_dis

J2000 Right Ascension at discovery time [deg].

ra_err

Error on J2000 Right Ascension at discovery time [deg].

redshift

Redshift.

score

Machine learning score.

property sdss_url

Construct URL for public Sloan Digital Sky Survey (SDSS) cutout.

sources

Instances in which a group saved this Obj.

spectra

Spectra of the object.

property target

Representation of the RA and Dec of this Obj as an astroplan.FixedTarget.

thumbnails

Thumbnails of the object.

transient

Boolean indicating whether the object is an astrophysical transient.

varstar

Boolean indicating whether the object is a variable star.

class skyportal.models.ObservingRun(**kwargs)

A classical observing run with a target list (of Objs).

Attributes
assignments

The Target Assignments for this Run.

calendar_date

The Local Calendar date of this Run.

created_at

UTC time of insertion of object’s row into the database.

group

The Group associated with this Run.

group_id

The ID of the Group associated with this run.

id

Unique object identifier.

instrument

The Instrument for this run.

instrument_id

ID of the Instrument used for this run.

modified

UTC time the object’s row was last modified in the database.

observers

The name(s) of the observer(s) on this run.

owner

The User who created this ObservingRun.

owner_id

The ID of the User who created this ObservingRun.

pi

The name(s) of the PI(s) of this run.

sources

The targets [Objs] for this run.

sunrise

The UTC timestamp of Sunrise on this run.

sunset

The UTC timestamp of Sunset on this run.

twilight_evening_astronomical

The UTC timestamp of evening astronomical (-18 degree) twilight on this run.

twilight_evening_nautical

The UTC timestamp of evening nautical (-12 degree) twilight on this run.

twilight_morning_astronomical

The UTC timestamp of morning astronomical (-18 degree) twilight on this run.

twilight_morning_nautical

The UTC timestamp of morning nautical (-12 degree) twilight on this run.

Methods

create_or_get(id)

Return a new cls if an instance with the specified primary key does not exist, else return the existing instance.

get_if_owned_by(ident, user_or_token[, options])

Return an object from the database if the requesting User or Token has access to read the object.

is_owned_by(user_or_token)

Generic ownership logic for any skyportal ORM model.

to_dict()

Serialize this object to a Python dictionary.

assignments

The Target Assignments for this Run.

calendar_date

The Local Calendar date of this Run.

created_at

UTC time of insertion of object’s row into the database.

group

The Group associated with this Run.

group_id

The ID of the Group associated with this run.

id

Unique object identifier.

instrument

The Instrument for this run.

instrument_id

ID of the Instrument used for this run.

modified

UTC time the object’s row was last modified in the database.

observers

The name(s) of the observer(s) on this run.

owner

The User who created this ObservingRun.

owner_id

The ID of the User who created this ObservingRun.

pi

The name(s) of the PI(s) of this run.

sources

The targets [Objs] for this run.

property sunrise

The UTC timestamp of Sunrise on this run.

property sunset

The UTC timestamp of Sunset on this run.

property twilight_evening_astronomical

The UTC timestamp of evening astronomical (-18 degree) twilight on this run.

property twilight_evening_nautical

The UTC timestamp of evening nautical (-12 degree) twilight on this run.

property twilight_morning_astronomical

The UTC timestamp of morning astronomical (-18 degree) twilight on this run.

property twilight_morning_nautical

The UTC timestamp of morning nautical (-12 degree) twilight on this run.

class skyportal.models.Photometry(**kwargs)

Calibrated measurement of the flux of an object through a broadband filter.

Attributes
alert_id

ID of the alert from which this Photometry was extracted (if any).

altdata

Arbitrary metadata in JSON format..

assignment
assignment_id
cartesian

Convert to Cartesian coordinates.

x, y, zfloat

A tuple of the x, y, and z coordinates.

created_at

UTC time of insertion of object’s row into the database.

dec
dec_unc

Uncertainty of dec position [arcsec]

e_mag

The error on the magnitude of the photometry point.

filter

Filter with which the observation was taken.

flux

Flux of the observation in µJy. Corresponds to an AB Zeropoint of 23.9 in all filters.

fluxerr

Gaussian error on the flux in µJy.

followup_request
followup_request_id
groups

Groups that can access this Photometry.

id

Unique object identifier.

instrument

Instrument that took this Photometry.

instrument_id

ID of the Instrument that took this Photometry.

iso

UTC ISO timestamp (ArrowType) of the exposure that produced this Photometry.

jd

Julian Date of the exposure that produced this Photometry.

mag

The magnitude of the photometry point in the AB system.

mjd

MJD of the observation.

modified

UTC time the object’s row was last modified in the database.

obj

The Photometry’s Obj.

obj_id

ID of the Photometry’s Obj.

original_user_data

Original data passed by the user through the PhotometryHandler.POST API or the PhotometryHandler.PUT API. The schema of this JSON validates under either schema.PhotometryFlux or schema.PhotometryMag (depending on how the data was passed).

ra
ra_unc

Uncertainty of ra position [arcsec]

snr

Signal-to-noise ratio of this Photometry point.

thumbnails

Thumbnails for this Photometry.

upload_id

ID of the batch in which this Photometry was uploaded (for bulk deletes).

Methods

create_or_get(id)

Return a new cls if an instance with the specified primary key does not exist, else return the existing instance.

get_if_owned_by(ident, user_or_token[, options])

Return an object from the database if the requesting User or Token has access to read the object.

is_owned_by(user_or_token)

Generic ownership logic for any skyportal ORM model.

to_dict()

Serialize this object to a Python dictionary.

within(other, radius)

Test if this point is within a given radius of another point.

alert_id

ID of the alert from which this Photometry was extracted (if any).

altdata

Arbitrary metadata in JSON format..

created_at

UTC time of insertion of object’s row into the database.

dec_unc

Uncertainty of dec position [arcsec]

e_mag

The error on the magnitude of the photometry point.

filter

Filter with which the observation was taken.

flux

Flux of the observation in µJy. Corresponds to an AB Zeropoint of 23.9 in all filters.

fluxerr

Gaussian error on the flux in µJy.

groups

Groups that can access this Photometry.

id

Unique object identifier.

instrument

Instrument that took this Photometry.

instrument_id

ID of the Instrument that took this Photometry.

iso

UTC ISO timestamp (ArrowType) of the exposure that produced this Photometry.

jd

Julian Date of the exposure that produced this Photometry.

mag

The magnitude of the photometry point in the AB system.

mjd

MJD of the observation.

modified

UTC time the object’s row was last modified in the database.

obj

The Photometry’s Obj.

obj_id

ID of the Photometry’s Obj.

original_user_data

Original data passed by the user through the PhotometryHandler.POST API or the PhotometryHandler.PUT API. The schema of this JSON validates under either schema.PhotometryFlux or schema.PhotometryMag (depending on how the data was passed).

ra_unc

Uncertainty of ra position [arcsec]

snr

Signal-to-noise ratio of this Photometry point.

thumbnails

Thumbnails for this Photometry.

upload_id

ID of the batch in which this Photometry was uploaded (for bulk deletes).

class skyportal.models.SourceView(**kwargs)

Record of an instance in which a Source was viewed via the frontend or retrieved via the API (for use in the “Top Sources” widget).

Attributes
created_at

UTC timestamp of the view.

id

Unique object identifier.

is_token

Whether the viewer was a User or a Token.

modified

UTC time the object’s row was last modified in the database.

obj_id

Object ID for which the view was registered.

username_or_token_id

Username or token ID of the viewer.

Methods

create_or_get(id)

Return a new cls if an instance with the specified primary key does not exist, else return the existing instance.

get_if_owned_by(ident, user_or_token[, options])

Return an object from the database if the requesting User or Token has access to read the object.

is_owned_by(user_or_token)

Generic ownership logic for any skyportal ORM model.

to_dict()

Serialize this object to a Python dictionary.

created_at

UTC timestamp of the view.

id

Unique object identifier.

is_token

Whether the viewer was a User or a Token.

modified

UTC time the object’s row was last modified in the database.

obj_id

Object ID for which the view was registered.

username_or_token_id

Username or token ID of the viewer.

class skyportal.models.Spectrum(**kwargs)

Wavelength-dependent measurement of the flux of an object through a dispersive element.

Attributes
assignment
assignment_id
created_at

UTC time of insertion of object’s row into the database.

errors

Errors on the fluxes of the spectrum [F_lambda, same units as fluxes.]

fluxes

Flux of the Spectrum [F_lambda, arbitrary units].

followup_request
followup_request_id
groups

Groups that can view this spectrum.

id

Unique object identifier.

instrument

The Instrument that acquired the Spectrum.

instrument_id

ID of the Instrument that acquired the Spectrum.

modified

UTC time the object’s row was last modified in the database.

obj

The Spectrum’s Obj.

obj_id

ID of this Spectrum’s Obj.

observed_at

Median UTC ISO time stamp of the exposure or exposures in which the Spectrum was acquired.

origin

Origin of the spectrum.

wavelengths

Wavelengths of the spectrum [Angstrom].

Methods

create_or_get(id)

Return a new cls if an instance with the specified primary key does not exist, else return the existing instance.

from_ascii(filename, obj_id, instrument_id, …)

Generate a Spectrum from an ascii file.

get_if_owned_by(ident, user_or_token[, options])

Return an object from the database if the requesting User or Token has access to read the object.

is_owned_by(user_or_token)

Generic ownership logic for any skyportal ORM model.

to_dict()

Serialize this object to a Python dictionary.

created_at

UTC time of insertion of object’s row into the database.

errors

Errors on the fluxes of the spectrum [F_lambda, same units as fluxes.]

fluxes

Flux of the Spectrum [F_lambda, arbitrary units].

classmethod from_ascii(filename, obj_id, instrument_id, observed_at)

Generate a Spectrum from an ascii file.

Parameters
filenamestr

The name of the ASCII file containing the spectrum.

obj_idstr

The name of the Spectrum’s Obj.

instrument_idint

ID of the Instrument with which this Spectrum was acquired.

observed_atstring or datetime

Median UTC ISO time stamp of the exposure or exposures in which the Spectrum was acquired.”

Returns
specskyportal.models.Spectrum

The Spectrum generated from the ASCII file.

groups

Groups that can view this spectrum.

id

Unique object identifier.

instrument

The Instrument that acquired the Spectrum.

instrument_id

ID of the Instrument that acquired the Spectrum.

modified

UTC time the object’s row was last modified in the database.

obj

The Spectrum’s Obj.

obj_id

ID of this Spectrum’s Obj.

observed_at

Median UTC ISO time stamp of the exposure or exposures in which the Spectrum was acquired.

origin

Origin of the spectrum.

wavelengths

Wavelengths of the spectrum [Angstrom].

class skyportal.models.Stream(**kwargs)

A data stream producing alerts that can be programmatically filtered using a Filter.

Attributes
altdata

Misc. metadata stored in JSON format, e.g. {‘collection’: ‘ZTF_alerts’, selector: [1, 2]}

created_at

UTC time of insertion of object’s row into the database.

filters

The filters with access to this stream.

groups

The Groups with access to this Stream.

id

Unique object identifier.

modified

UTC time the object’s row was last modified in the database.

name

Stream name.

users

The users with access to this stream.

Methods

create_or_get(id)

Return a new cls if an instance with the specified primary key does not exist, else return the existing instance.

get_if_owned_by(ident, user_or_token[, options])

Return an object from the database if the requesting User or Token has access to read the object.

is_owned_by(user_or_token)

Generic ownership logic for any skyportal ORM model.

to_dict()

Serialize this object to a Python dictionary.

altdata

Misc. metadata stored in JSON format, e.g. {‘collection’: ‘ZTF_alerts’, selector: [1, 2]}

created_at

UTC time of insertion of object’s row into the database.

filters

The filters with access to this stream.

groups

The Groups with access to this Stream.

id

Unique object identifier.

modified

UTC time the object’s row was last modified in the database.

name

Stream name.

users

The users with access to this stream.

class skyportal.models.Taxonomy(**kwargs)

An ontology within which Objs can be classified.

Attributes
classifications

Classifications made within this Taxonomy.

created_at

UTC time of insertion of object’s row into the database.

groups

List of Groups that have access to this Taxonomy.

hierarchy

Nested JSON describing the taxonomy which should be validated against a schema before entry.

id

Unique object identifier.

isLatest

Consider this the latest version of the taxonomy with this name? Defaults to True.

modified

UTC time the object’s row was last modified in the database.

name

Short string to make this taxonomy memorable to end users.

provenance

Identifier (e.g., URL or git hash) that uniquely ties this taxonomy back to an origin or place of record.

version

Semantic version of this taxonomy

Methods

create_or_get(id)

Return a new cls if an instance with the specified primary key does not exist, else return the existing instance.

get_if_owned_by(ident, user_or_token[, options])

Return an object from the database if the requesting User or Token has access to read the object.

get_taxonomy_usable_by_user(user_or_token)

Query the database and return the requested Taxonomy if it is accessible to the requesting User or Token owner.

is_owned_by(user_or_token)

Generic ownership logic for any skyportal ORM model.

to_dict()

Serialize this object to a Python dictionary.

classifications

Classifications made within this Taxonomy.

created_at

UTC time of insertion of object’s row into the database.

get_taxonomy_usable_by_user(user_or_token)

Query the database and return the requested Taxonomy if it is accessible to the requesting User or Token owner. If the Taxonomy is not accessible or if it does not exist, return an empty list.

Parameters
taxonomy_idinteger

The ID of the requested Taxonomy.

user_or_tokenbaselayer.app.models.User or baselayer.app.models.Token

The requesting User or Token object.

Returns
taxskyportal.models.Taxonomy

The requested Taxonomy.

groups

List of Groups that have access to this Taxonomy.

hierarchy

Nested JSON describing the taxonomy which should be validated against a schema before entry.

id

Unique object identifier.

isLatest

Consider this the latest version of the taxonomy with this name? Defaults to True.

modified

UTC time the object’s row was last modified in the database.

name

Short string to make this taxonomy memorable to end users.

provenance

Identifier (e.g., URL or git hash) that uniquely ties this taxonomy back to an origin or place of record.

version

Semantic version of this taxonomy

class skyportal.models.Telescope(**kwargs)

A ground or space-based observational facility that can host Instruments.

Attributes
created_at

UTC time of insertion of object’s row into the database.

diameter

Diameter in meters.

elevation

Elevation in meters.

id

Unique object identifier.

instruments

The Instruments on this telescope.

lat

Latitude in deg.

lon

Longitude in deg.

modified

UTC time the object’s row was last modified in the database.

name

Unabbreviated facility name (e.g., Palomar 200-inch Hale Telescope).

nickname

Abbreviated facility name (e.g., P200).

observer

Return an astroplan.Observer representing an observer at this facility, accounting for the latitude, longitude, elevation, and local time zone of the observatory (if ground based).

robotic

Is this telescope robotic?

skycam_link

Link to the telescope’s sky camera.

Methods

create_or_get(id)

Return a new cls if an instance with the specified primary key does not exist, else return the existing instance.

get_if_owned_by(ident, user_or_token[, options])

Return an object from the database if the requesting User or Token has access to read the object.

is_owned_by(user_or_token)

Generic ownership logic for any skyportal ORM model.

to_dict()

Serialize this object to a Python dictionary.

created_at

UTC time of insertion of object’s row into the database.

diameter

Diameter in meters.

elevation

Elevation in meters.

id

Unique object identifier.

instruments

The Instruments on this telescope.

lat

Latitude in deg.

lon

Longitude in deg.

modified

UTC time the object’s row was last modified in the database.

name

Unabbreviated facility name (e.g., Palomar 200-inch Hale Telescope).

nickname

Abbreviated facility name (e.g., P200).

property observer

Return an astroplan.Observer representing an observer at this facility, accounting for the latitude, longitude, elevation, and local time zone of the observatory (if ground based).

robotic

Is this telescope robotic?

Link to the telescope’s sky camera.

class skyportal.models.Thumbnail(**kwargs)

Thumbnail image centered on the location of an Obj.

Attributes
created_at

UTC time of insertion of object’s row into the database.

file_uri

Path of the Thumbnail on the machine running SkyPortal.

id

Unique object identifier.

modified

UTC time the object’s row was last modified in the database.

obj

The Thumbnail’s Obj.

origin

Origin of the Thumbnail.

photometry

The Thumbnail’s corresponding Photometry point.

photometry_id

ID of the Thumbnail’s corresponding Photometry point.

public_url

Publically accessible URL of the thumbnail.

type

Thumbnail type (e.g., ref, new, sub, dr8, …)

Methods

create_or_get(id)

Return a new cls if an instance with the specified primary key does not exist, else return the existing instance.

get_if_owned_by(ident, user_or_token[, options])

Return an object from the database if the requesting User or Token has access to read the object.

is_owned_by(user_or_token)

Generic ownership logic for any skyportal ORM model.

to_dict()

Serialize this object to a Python dictionary.

created_at

UTC time of insertion of object’s row into the database.

file_uri

Path of the Thumbnail on the machine running SkyPortal.

id

Unique object identifier.

modified

UTC time the object’s row was last modified in the database.

obj

The Thumbnail’s Obj.

origin

Origin of the Thumbnail.

photometry

The Thumbnail’s corresponding Photometry point.

photometry_id

ID of the Thumbnail’s corresponding Photometry point.

public_url

Publically accessible URL of the thumbnail.

type

Thumbnail type (e.g., ref, new, sub, dr8, …)

skyportal.models.candidate_is_owned_by(self, user_or_token)

Return a boolean indicating whether the Candidate passed the Filter of any of a User or Token owner’s accessible Groups.

Parameters
user_or_tokenbaselayer.app.models.User or baselayer.app.models.Token

The requesting User or Token object.

Returns
ownedbool

Whether the Candidate is owned by the User or Token owner.

skyportal.models.get_candidate_if_owned_by(obj_id, user_or_token, options=[])

Return an Obj from the database if the Obj is a Candidate in at least one of the requesting User or Token owner’s accessible Groups. If the Obj is not a Candidate in one of the User or Token owner’s accessible Groups, raise an AccessError. If the Obj does not exist, return None.

Parameters
obj_idinteger or string

Primary key of the Obj.

user_or_tokenbaselayer.app.models.User or baselayer.app.models.Token

The requesting User or Token object.

optionslist of `sqlalchemy.orm.MapperOption`s

Options that wil be passed to options() in the loader query.

Returns
objskyportal.models.Obj

The requested Obj.

skyportal.models.get_obj_classifications_owned_by(self, user_or_token)

Query the database and return the Classifications on this Obj that are accessible to any of the User or Token owner’s accessible Groups.

Parameters
user_or_tokenbaselayer.app.models.User or baselayer.app.models.Token

The requesting User or Token object.

Returns
comment_listlist of skyportal.models.Classification

The accessible classifications attached to this Obj.

skyportal.models.get_obj_comments_owned_by(self, user_or_token)

Query the database and return the Comments on this Obj that are accessible to any of the User or Token owner’s accessible Groups.

Parameters
user_or_tokenbaselayer.app.models.User or baselayer.app.models.Token

The requesting User or Token object.

Returns
comment_listlist of skyportal.models.Comment

The accessible comments attached to this Obj.

skyportal.models.get_obj_if_owned_by(obj_id, user_or_token, options=[])

Return an Obj from the database if the Obj is either a Source or a Candidate in at least one of the requesting User or Token owner’s accessible Groups. If the Obj is not a Source or a Candidate in one of the User or Token owner’s accessible Groups, raise an AccessError. If the Obj does not exist, return None.

Parameters
obj_idinteger or string

Primary key of the Obj.

user_or_tokenbaselayer.app.models.User or baselayer.app.models.Token

The requesting User or Token object.

optionslist of `sqlalchemy.orm.MapperOption`s

Options that wil be passed to options() in the loader query.

Returns
objskyportal.models.Obj

The requested Obj.

skyportal.models.get_photometry_owned_by_user(obj_id, user_or_token)

Query the database and return the Photometry for this Obj that is shared with any of the User or Token owner’s accessible Groups.

Parameters
obj_idstring

The ID of the Obj to look up.

user_or_tokenbaselayer.app.models.User or baselayer.app.models.Token

The requesting User or Token object.

Returns
photometry_listlist of skyportal.models.Photometry

The accessible Photometry of this Obj.

skyportal.models.get_source_if_owned_by(obj_id, user_or_token, options=[])

Return an Obj from the database if the Obj is a Source in at least one of the requesting User or Token owner’s accessible Groups. If the Obj is not a Source in one of the User or Token owner’s accessible Groups, raise an AccessError. If the Obj does not exist, return None.

Parameters
obj_idinteger or string

Primary key of the Obj.

user_or_tokenbaselayer.app.models.User or baselayer.app.models.Token

The requesting User or Token object.

optionslist of `sqlalchemy.orm.MapperOption`s

Options that wil be passed to options() in the loader query.

Returns
objskyportal.models.Obj

The requested Obj.

skyportal.models.get_spectra_owned_by(obj_id, user_or_token)

Query the database and return the Spectra for this Obj that are shared with any of the User or Token owner’s accessible Groups.

Parameters
obj_idstring

The ID of the Obj to look up.

user_or_tokenbaselayer.app.models.User or baselayer.app.models.Token

The requesting User or Token object.

Returns
photometry_listlist of skyportal.models.Spectrum

The accessible Spectra of this Obj.

skyportal.models.get_taxonomy_usable_by_user(taxonomy_id, user_or_token)

Query the database and return the requested Taxonomy if it is accessible to the requesting User or Token owner. If the Taxonomy is not accessible or if it does not exist, return an empty list.

Parameters
taxonomy_idinteger

The ID of the requested Taxonomy.

user_or_tokenbaselayer.app.models.User or baselayer.app.models.Token

The requesting User or Token object.

Returns
taxskyportal.models.Taxonomy

The requested Taxonomy.

skyportal.models.is_owned_by(self, user_or_token)

Generic ownership logic for any skyportal ORM model.

Models with complicated ownership logic should implement their own method instead of adding too many additional conditions here.

skyportal.models.source_is_owned_by(self, user_or_token)

Return a boolean indicating whether the Source has been saved to any of a User or Token owner’s accessible Groups.

Parameters
user_or_tokenbaselayer.app.models.User or baselayer.app.models.Token

The requesting User or Token object.

Returns
ownedbool

Whether the Candidate is owned by the User or Token owner.

skyportal.models.token_groups

The groups the Token owner is a member of.

skyportal.models.user_or_token_accessible_groups

Return the list of Groups a User or Token has access to. For non-admin Users or Token owners, this corresponds to the Groups they are a member of. For System Admins, this corresponds to all Groups.

class baselayer.app.models.ACL(**kwargs)

An access control list item representing a privilege within the application. ACLs are aggregated into collections called Roles which are assumed by Users. Examples of ACLs include Upload Data, Comment, and Manage Groups.

Attributes
created_at

UTC time of insertion of object’s row into the database.

id

ACL name.

modified

UTC time the object’s row was last modified in the database.

Methods

create_or_get(id)

Return a new cls if an instance with the specified primary key does not exist, else return the existing instance.

get_if_owned_by(ident, user_or_token[, options])

Return an object from the database if the requesting User or Token has access to read the object.

is_owned_by(user_or_token)

Generic ownership logic for any skyportal ORM model.

to_dict()

Serialize this object to a Python dictionary.

created_at

UTC time of insertion of object’s row into the database.

id

ACL name.

modified

UTC time the object’s row was last modified in the database.

class baselayer.app.models.Role(**kwargs)

A collection of ACLs. Roles map Users to ACLs. One User may assume multiple Roles.

Attributes
acls

ACLs associated with the Role.

created_at

UTC time of insertion of object’s row into the database.

id

Role name.

modified

UTC time the object’s row was last modified in the database.

users

Users who have this Role.

Methods

create_or_get(id)

Return a new cls if an instance with the specified primary key does not exist, else return the existing instance.

get_if_owned_by(ident, user_or_token[, options])

Return an object from the database if the requesting User or Token has access to read the object.

is_owned_by(user_or_token)

Generic ownership logic for any skyportal ORM model.

to_dict()

Serialize this object to a Python dictionary.

acls

ACLs associated with the Role.

created_at

UTC time of insertion of object’s row into the database.

id

Role name.

modified

UTC time the object’s row was last modified in the database.

users

Users who have this Role.

class baselayer.app.models.RoleACL(**kwargs)

Join table class mapping Roles to ACLs.

Attributes
acl
acl_id
created_at

UTC time of insertion of object’s row into the database.

id
modified

UTC time the object’s row was last modified in the database.

role
role_id

Methods

create_or_get(id)

Return a new cls if an instance with the specified primary key does not exist, else return the existing instance.

get_if_owned_by(ident, user_or_token[, options])

Return an object from the database if the requesting User or Token has access to read the object.

is_owned_by(user_or_token)

Generic ownership logic for any skyportal ORM model.

to_dict()

Serialize this object to a Python dictionary.

created_at

UTC time of insertion of object’s row into the database.

modified

UTC time the object’s row was last modified in the database.

class baselayer.app.models.Token(**kwargs)

A command line token that can be used to programmatically access the API as a particular User.

Attributes
accessible_groups

Return the list of Groups a User or Token has access to.

acls

The ACLs granted to the Token.

created_at

UTC time of insertion of object’s row into the database.

created_by

The User that created the token.

created_by_id

The ID of the User that created the Token.

groups

The groups the Token owner is a member of.

id

The value of the token. This field is used for authenticating as a User on the command line.

modified

UTC time the object’s row was last modified in the database.

name

The name of the token.

Methods

create_or_get(id)

Return a new cls if an instance with the specified primary key does not exist, else return the existing instance.

get_if_owned_by(ident, user_or_token[, options])

Return an object from the database if the requesting User or Token has access to read the object.

is_owned_by(user_or_token)

Return a boolean indicating whether this Token is owned by the specified User (or Token instance, if a token is passed).

to_dict()

Serialize this object to a Python dictionary.

property accessible_groups

Return the list of Groups a User or Token has access to. For non-admin Users or Token owners, this corresponds to the Groups they are a member of. For System Admins, this corresponds to all Groups.

acls

The ACLs granted to the Token.

created_at

UTC time of insertion of object’s row into the database.

created_by

The User that created the token.

created_by_id

The ID of the User that created the Token.

property groups

The groups the Token owner is a member of.

id

The value of the token. This field is used for authenticating as a User on the command line.

is_owned_by(user_or_token)

Return a boolean indicating whether this Token is owned by the specified User (or Token instance, if a token is passed).

Parameters
user_or_tokenbaselayer.app.models.User or baselayer.app.models.Token

The User or Token to check.

Returns
ownedbool

Whether this Token instance is owned by the User or Token.

modified

UTC time the object’s row was last modified in the database.

name

The name of the token.

class baselayer.app.models.TokenACL(**kwargs)

Join table mapping Tokens to ACLs

Attributes
acl
acl_id
created_at

UTC time of insertion of object’s row into the database.

id
modified

UTC time the object’s row was last modified in the database.

token
token_id

Methods

create_or_get(id)

Return a new cls if an instance with the specified primary key does not exist, else return the existing instance.

get_if_owned_by(ident, user_or_token[, options])

Return an object from the database if the requesting User or Token has access to read the object.

is_owned_by(user_or_token)

Generic ownership logic for any skyportal ORM model.

to_dict()

Serialize this object to a Python dictionary.

created_at

UTC time of insertion of object’s row into the database.

modified

UTC time the object’s row was last modified in the database.

class baselayer.app.models.User(**kwargs)

An application user.

Attributes
accessible_groups

Return the list of Groups a User or Token has access to.

acls

List of the user’s ACLs.

assignments

Objs the User has assigned to ObservingRuns.

comments
contact_email

The phone number at which the user prefers to receive communications.

contact_phone

The email at which the user prefers to receive communications.

created_at

UTC time of insertion of object’s row into the database.

first_name

The User’s first name.

followup_requests

The follow-up requests this User has made.

gravatar_url

The Gravatar URL inferred from the user’s contact email, or, if the contact email is null, the username.

groups

The Groups this User is a member of.

id

Unique object identifier.

last_name

The User’s last name.

modified

UTC time the object’s row was last modified in the database.

oauth_uid

The user’s OAuth UID.

observing_runs

Observing Runs this User has created.

permissions

List of the names of the user’s ACLs.

preferences

The user’s application settings.

roles

The roles assumed by this user.

saved_sources
sources

The Sources accessible to this User.

streams

The Streams this User has access to.

tokens

This user’s tokens.

transactions

The FacilityTransactions initiated by this User.

username

The user’s username.

Methods

create_or_get(id)

Return a new cls if an instance with the specified primary key does not exist, else return the existing instance.

get_if_owned_by(ident, user_or_token[, options])

Return an object from the database if the requesting User or Token has access to read the object.

is_active()

Boolean flag indicating whether the User is currently active.

is_authenticated()

Boolean flag indicating whether the User is currently authenticated.

is_owned_by(user_or_token)

Generic ownership logic for any skyportal ORM model.

to_dict()

Serialize this object to a Python dictionary.

user_model()

The base model for User subclasses.

property accessible_groups

Return the list of Groups a User or Token has access to. For non-admin Users or Token owners, this corresponds to the Groups they are a member of. For System Admins, this corresponds to all Groups.

property acls

List of the user’s ACLs.

assignments

Objs the User has assigned to ObservingRuns.

contact_email

The phone number at which the user prefers to receive communications.

contact_phone

The email at which the user prefers to receive communications.

created_at

UTC time of insertion of object’s row into the database.

first_name

The User’s first name.

followup_requests

The follow-up requests this User has made.

property gravatar_url

The Gravatar URL inferred from the user’s contact email, or, if the contact email is null, the username.

groups

The Groups this User is a member of.

id

Unique object identifier.

is_active()

Boolean flag indicating whether the User is currently active.

is_authenticated()

Boolean flag indicating whether the User is currently authenticated.

last_name

The User’s last name.

modified

UTC time the object’s row was last modified in the database.

oauth_uid

The user’s OAuth UID.

observing_runs

Observing Runs this User has created.

property permissions

List of the names of the user’s ACLs.

preferences

The user’s application settings.

roles

The roles assumed by this user.

sources

The Sources accessible to this User.

streams

The Streams this User has access to.

tokens

This user’s tokens.

transactions

The FacilityTransactions initiated by this User.

classmethod user_model()

The base model for User subclasses.

username

The user’s username.

class baselayer.app.models.UserRole(**kwargs)

Join table mapping Users to Roles.

Attributes
created_at

UTC time of insertion of object’s row into the database.

id
modified

UTC time the object’s row was last modified in the database.

role
role_id
user
user_id

Methods

create_or_get(id)

Return a new cls if an instance with the specified primary key does not exist, else return the existing instance.

get_if_owned_by(ident, user_or_token[, options])

Return an object from the database if the requesting User or Token has access to read the object.

is_owned_by(user_or_token)

Generic ownership logic for any skyportal ORM model.

to_dict()

Serialize this object to a Python dictionary.

created_at

UTC time of insertion of object’s row into the database.

modified

UTC time the object’s row was last modified in the database.

baselayer.app.models.join_model(join_table, model_1, model_2, column_1=None, column_2=None, fk_1='id', fk_2='id', base=<class 'sqlalchemy.ext.declarative.api.Base'>)

Helper function to create a join table for a many-to-many relationship.

Parameters
join_tablestr

Name of the new table to be created.

model_1str

First model in the relationship.

model_2str

Second model in the relationship.

column_1str, optional

Name of the join table column corresponding to model_1. If None, then {table1`[:-1]_id} will be used (e.g., `user_id for users).

column_2str, optional

Name of the join table column corresponding to model_2. If None, then {table2`[:-1]_id} will be used (e.g., `user_id for users).

fk_1str, optional

Name of the column from model_1 that the foreign key should refer to.

fk_2str, optional

Name of the column from model_2 that the foreign key should refer to.

basesqlalchemy.ext.declarative.api.DeclarativeMeta

SQLAlchemy model base to subclass.

Returns
sqlalchemy.ext.declarative.api.DeclarativeMeta

SQLAlchemy association model class

Entity Relationship Diagram

The following entity relationship diagram visualizes the structure of the SkyPortal database.

Skyportal Entity Relationship Diagram