Example #1
0
def sscweb():

    from hapiclient.hapi import hapi
    from hapiclient.hapiplot import hapiplot

    # SSCWeb data
    server = 'http://hapi-server.org/servers/SSCWeb/hapi'
    dataset = 'ace'
    start = '2001-01-01T05:00:00'
    stop = '2001-01-01T10:00:00'
    parameters = 'X_GSE,Y_GSE,Z_GSE'
    opts = {'logging': True, 'usecache': True}
    data, meta = hapi(server, dataset, parameters, start, stop, **opts)
    hapiplot(data, meta, **opts)
Example #2
0
def cassini():
    from hapiclient import hapi
    from hapiclient import hapiplot

    server = 'http://datashop.elasticbeanstalk.com/hapi'
    dataset = 'CHEMS_PHA_BOX_FLUXES_FULL_TIME_RES'
    parameters = 'HPlus_BEST_T1'
    start = '2004-07-01T04:00:00Z'
    stop = '2004-07-01T06:00:00Z'
    opts = {'usecache': True}

    data, meta = hapi(server, dataset, parameters, start, stop, **opts)

    popts = {'logging': False, 'logy': True, 'logz': True}
    hapiplot(data, meta, **popts)
Example #3
0
def omniweb():

    from hapiclient import hapi
    from hapiclient import hapiplot

    server = 'https://cdaweb.gsfc.nasa.gov/hapi'
    dataset = 'OMNI2_H0_MRG1HR'
    start = '2003-09-01T00:00:00'
    stop = '2003-12-01T00:00:00'
    parameters = 'DST1800'
    opts = {'logging': True, 'usecache': False}

    # Get data
    data, meta = hapi(server, dataset, parameters, start, stop, **opts)

    # Plot all parameters
    hapiplot(data, meta)
Example #4
0
def cdaweb():

    from hapiclient.hapi import hapi
    from hapiclient.hapiplot import hapiplot

    # CDAWeb data - Magnitude and BGSEc from dataset AC_H0_MFI
    server = 'https://cdaweb.gsfc.nasa.gov/hapi'
    dataset = 'AC_H0_MFI'
    start = '2001-01-01T05:00:00'
    stop = '2001-01-01T10:00:00'
    parameters = 'Magnitude,BGSEc'
    opts = {'logging': True, 'usecache': True}
    data, meta = hapi(server, dataset, parameters, start, stop, **opts)
    hapiplot(data, meta, **opts)

    # CDAWeb metadata for AC_H0_MFI
    server = 'https://cdaweb.gsfc.nasa.gov/hapi'
    dataset = 'AC_H0_MFI'
    meta = hapi(server, dataset, **opts)
    print('Parameters in %s' % dataset)
    for i in range(0, len(meta['parameters'])):
        print('  %s' % meta['parameters'][i]['name'])
    print('')

    # CDAWeb metadata for all datasets
    server = 'https://cdaweb.gsfc.nasa.gov/hapi'
    meta = hapi(server, **opts)
    print('%d CDAWeb datasets' % len(meta['catalog']))
    for i in range(0, 3):
        print('  %d. %s' % (i, meta['catalog'][i]['id']))
    print('  ...')
    print('  %d. %s' % (len(meta['catalog']), meta['catalog'][-1]['id']))
    print('')

    # List all servers
    servers = hapi(logging=True)  # servers is an array of URLs
    print('')
Example #5
0
# Install latest hapiclient package from https://pypi.org/project/hapiclient/
# Only needs to be executed once.
import os; print(os.popen('pip install hapiclient --upgrade').read())

from hapiclient import hapi, hapiplot

server     = 'SERVER';
dataset    = 'DATASET';
# Notes:
# 1. Use parameters='' to request all parameters from DATASET.
# 2. Multiple parameters can be requested using a comma-separated
#    listCSV_EXAMPLE
parameters = 'PARAMETERS'; 
start      = 'START';
stop       = 'STOP';

data, meta = hapi(server, dataset, parameters, start, stop)

hapiplot(data, meta)

# Notes:
# 1. To convert the ISO 8601 strings in data['TIMENAME'] to Python
#    datetimes, use
#      from hapiclient import hapitime2datetime
#      Time = hapitime2datetime(data['TIMENAME'])
# 2. Details about the data and metadata structures `data`
#    and `meta` are given at 
#    https://github.com/hapi-server/client-python-notebooks/blob/master/hapi_demo.ipynb
# 3. Many examples for using `data` and `meta` with other
#    Python libraries (e.g., Pandas, Numpy, Astropy) are given
#    in above-referenced notebook.
Example #6
0
for tn in tests:

    if tn == 0:
        # GUI plot of timeseries and spectra
        from hapiclient import hapi
        from hapiclient import hapiplot

        server = 'http://hapi-server.org/servers/TestData2.0/hapi'
        dataset = 'dataset1'
        parameters = 'scalar,spectra'
        start = '1970-01-01Z'
        stop = '1970-01-01T00:00:11Z'
        opts = {'logging': True, 'usecache': False}

        data, meta = hapi(server, dataset, parameters, start, stop, **opts)
        meta = hapiplot(data, meta, **opts)

    if tn == 1 or tn == 2:
        # Compare png with GUI plot
        import io
        from PIL import Image

        from hapiclient import hapi
        from hapiclient import hapiplot

        server = 'http://hapi-server.org/servers/TestData2.0/hapi'
        dataset = 'dataset1'
        start = '1970-01-01Z'
        stop = '1970-01-01T00:00:11Z'
        parameters = 'scalar'
        opts = {'logging': False, 'usecache': False}
Example #7
0
from hapiclient import hapi
from hapiclient import hapiplot

# CDAWeb data - Magnitude and BGSEc from dataset AC_H0_MFI
server = 'https://cdaweb.gsfc.nasa.gov/hapi'
dataset = 'AC_H0_MFI'
start = '1997-12-10T00:00:00'
stop = '1997-12-11T10:00:00'
parameters = 'Magnitude,BGSEc'
opts = {'logging': True, 'usecache': True}
data, meta = hapi(server, dataset, parameters, start, stop, **opts)
hapiplot(data, meta, **opts)

opts['returnimage'] = True
meta = hapiplot(data, meta, **opts)
fig = meta['parameters'][1]['hapiplot']['figure']