Пример #1
0
def export1d(runid):
    """
    Export all PVs to a file. Do not talk to filestore.

    Parameters
    ----------
    runid : int
        run number
    """
    t = get_table(db[runid], fill=False)
    name = 'scan_'+str(runid)+'.txt'
    t.to_csv(name)
Пример #2
0
def fetch_data_from_db(runid):
    """
    Read data from database.

    .. note:: Requires the dataportal package from NSLS2

    Parameters
    ----------
    runid : int
        ID for given experimental measurement

    Returns
    -------
    data : pandas.core.frame.DataFrame
        data frame with keys as given PV names.
    """

    #hdr = db[runid]
    # headers = db.find_headers(scan_id=runid)
    # head_list = sorted(headers, key=lambda x: x.start_time)
    # hdr = head_list[-1]
    # # events = db.fetch_events(hdr, fill=False)
    # # num_events = len(list(events))
    # # print('%s events found' % num_events)
    # ev = db.fetch_events(hdr)
    #
    # events = []
    # for idx, event in enumerate(ev):
    #     if idx % 1000 == 0:
    #         print('event %s loaded' % (idx+1))
    #     events.append(event)
    #
    # muxer = dm.from_events(events)
    # data = muxer.to_sparse_dataframe()
    fields = [
        'xspress3_ch1', 'xspress3_ch2', 'xspress3_ch3', 'ssx[um]', 'ssy[um]',
        'ssx', 'ssy', 'sclr1_ch3', 'sclr1_ch4'
    ]
    d = get_table(db[runid], fields=fields)
    return d
Пример #3
0
def fetch_data_from_db(runid):
    """
    Read data from database.

    .. note:: Requires the databroker package from NSLS2

    Parameters
    ----------
    runid : int
        ID for given experimental measurement

    Returns
    -------
    data : pandas.core.frame.DataFrame
        data frame with keys as given PV names.
    """

    #hdr = db[runid]
    # headers = db.find_headers(scan_id=runid)
    # head_list = sorted(headers, key=lambda x: x.start_time)
    # hdr = head_list[-1]
    # # events = db.fetch_events(hdr, fill=False)
    # # num_events = len(list(events))
    # # print('%s events found' % num_events)
    # ev = db.fetch_events(hdr)
    #
    # events = []
    # for idx, event in enumerate(ev):
    #     if idx % 1000 == 0:
    #         print('event %s loaded' % (idx+1))
    #     events.append(event)
    #
    # muxer = dm.from_events(events)
    # data = muxer.to_sparse_dataframe()
    fields = ['xspress3_ch1', 'xspress3_ch2', 'xspress3_ch3',
              'ssx[um]', 'ssy[um]', 'ssx', 'ssy', 'sclr1_ch3', 'sclr1_ch4']
    d = get_table(db[runid], fields=fields)
    return d