Skip to content

Instantly share code, notes, and snippets.

@danielballan
Last active September 17, 2019 21:26
Show Gist options
  • Select an option

  • Save danielballan/d39dfff1669786e596a6fc1914e319cf to your computer and use it in GitHub Desktop.

Select an option

Save danielballan/d39dfff1669786e596a6fc1914e319cf to your computer and use it in GitHub Desktop.
Try new data access

Obtain an SDDC account

Form

Log into to the SDCC NSLS-II JupyterHub

https://jupyter.sdcc.bnl.gov/jupyterhub/nsls

Create a new Jupyter kernel with databroker 1.0.0 (pre-release)

Open a new Termainal in Jupyter, and type or paste:

export MY_ENV=test-databroker
mkdir -p ~/venv
python -m venv ~/venv/$MY_ENV
source ~/venv/$MY_ENV/bin/activate
pip install wheel  # It's important to do this separately and first.
pip install ipykernel
pip install --pre databroker  # pre-released version of databroker 1.0.0
pip install matplotlib  # optional...anything you want

~/venv/$MY_ENV/bin/python -m ipykernel install --user --name $MY_ENV --display-name "DataBroker Test"

Go to File > Hub Control Panel and restart your server. This may not be necessary, but it's one way to ensure that the new kernel appears in your list of options.

Access and plot some data

Open a notebook and do this:

%matplotlib inline
import matplotlib.pyplot as plt
from intake import open_catalog

# There will soon be a slicker way to open the "default" catalog.
catalog = open_catalog('intake://broker', page_size=10)
list(catalog)  # Shows all your options---for now, just 'csx'.
csx = cat['csx']()

entry = csx['9b24c09f-ef87-4b43-af1c-e89c7e29751e']
run = entry()
run

for name, doc in run.canonical(fill='yes'):
    if name == 'event' and 'fccd_image' in doc['data']:
        break

plt.imshow(doc['data']['fccd_image'][0, ...])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment