Ejemplo n.º 1
0
def get_mnemonic(mnemonic_identifier, start_time, end_time):
    """Execute query and return a EdbMnemonic instance.

    The underlying MAST service returns data that include the
    datapoint preceding the requested start time and the datapoint
    that follows the requested end time.

    Parameters
    ----------
    mnemonic_identifier : str
        Telemetry mnemonic identifiers, e.g. 'SA_ZFGOUTFOV'
    start_time : astropy.time.Time instance
        Start time
    end_time : astropy.time.Time instance
        End time

    Returns
    -------
    mnemonic : instance of EdbMnemonic
        EdbMnemonic object containing query results

    """
    mast_token = get_mast_token()
    data, meta, info = query_single_mnemonic(mnemonic_identifier,
                                             start_time,
                                             end_time,
                                             token=mast_token)

    # create and return instance
    mnemonic = EdbMnemonic(mnemonic_identifier, start_time, end_time, data,
                           meta, info)
    return mnemonic
Ejemplo n.º 2
0
def get_mnemonic_info(mnemonic_identifier):
    """Return the mnemonic description.

    Parameters
    ----------
    mnemonic_identifier : str
        Telemetry mnemonic identifier, e.g. ``SA_ZFGOUTFOV``

    Returns
    -------
    info : dict
        Object that contains the returned data
    """

    mast_token = get_mast_token()
    return query_mnemonic_info(mnemonic_identifier, token=mast_token)
Ejemplo n.º 3
0
def log_into_mast(request):
    """Login via astroquery.mast if user authenticated in web app.

    Parameters
    ----------
    request : HttpRequest object
        Incoming request from the webpage

    """
    if Mast.authenticated():
        return True

    # get the MAST access token if present
    access_token = str(get_mast_token(request))

    # authenticate with astroquery.mast if necessary
    if access_token != 'None':
        Mast.login(token=access_token)
        return Mast.authenticated()
    else:
        return False