The python client for the Breadboard API. Gets parameters from the experiment and matches them to your images.
Get it with pip install breadboard. Ask me for an API key, and store it somewhere locally.
First, import the breadboard module and initialize with your secure API key (stored under filepath/API_CONFIG.json):
from breadboard import BreadboardClient
bc = BreadboardClient(config_path='filepath/API_CONFIG.json')Note: your API_CONFIG.json should look like:
{
"api_key": "API_TOKEN",
"lab_name": "lab_name",
"api_url": "https://fermi3.com"
}This is the easiest way to get parameters:
- Copy a list of imagenames.
- Run the following:
df = bc.get_images_df_clipboard()
print(df.head())This produces a pandas dataframe:
| imagename | x | reWhirrFreq | holdTime | TOF | evapEndTOPMHz | accordionHoldSpacing | unixtime | reWhirrTime | |
|---|---|---|---|---|---|---|---|---|---|
| 0 | 2019-03-04_15-36-22_SensicamQE | 1.55171e+09 | 4.75 | 300 | 0 | 1777 | 4.4 | 1.55171e+09 | 7 |
| 1 | 2019-03-04_15-35-52_SensicamQE | 1.55171e+09 | 4.75 | 275 | 0 | 1777 | 4.4 | 1.55171e+09 | 7 |
By default, you will get the variables that were list-bound in Cicero. This is most convenient if you were running a list (F12), and don't want to write down which variables were important.
The paramsin keyword argument lets you choose what parameters to return. You can request all parameters by passing the argument paramsin='*', or pass a list of desired parameters paramsin=[param1, param2, ...].
The x column is a copy of another column. This makes plotting and analysis easy (everything is versus df.x). By default, the x column is the timestamp, but you can select any other parameter (say paramname) by passing the argument xvar=paramname.
To get specific parameters, use:
imagenames = ['10-09-2018_00_27_44_TopA','10-09-2018_00_27_44_TopB']
params = ['FB_field_13_V','ImagFreq0']
df = bc.get_images_df(imagenames, paramsin=params)This produces:
| imagename | x | ImagFreq0 | FB_field_13_V | unixtime | |
|---|---|---|---|---|---|
| 0 | 10-09-2018_00_27_44_TopA | 1.53904e+09 | 193.95 | 3.774 | 1.53904e+09 |
| 1 | 10-09-2018_00_27_44_TopB | 1.53904e+09 | 193.95 | 3.774 | 1.53904e+09 |
An example of posting imagenames (can be an array or a list):
bc.post_images(imagenames, pixel_size=3, notes='test')
To copy images from your clipboard and use it for other things, use:
pd.read_clipboard(header=None)[0].tolist()
To get a list of images between two datetimes, use:
import datetime
start_datetime = datetime.datetime(2019,7,1,0,0,55)
end_datetime = datetime.datetime(2019,7,2,0,20,55)
out = bc.get_images_df(datetime_range=[start_datetime, end_datetime])Clone this repository and create a virtual environment:
pip install virtualenv --user
python -m virtualenv env
source env/bin/activate
pip install -r requirements.txt --userTo run the tests, add a API_CONFIG.json file into the tests/ folder and run:
pytestStart by adding a test, run pytest to see it fail, and then make it not fail by adding the feature you want.
For quick checks, run jupyter notebook and open the Client tests.ipynb notebook. Remember to initialize the client with the debugger turned on:
bc = BreadboardClient(config_path='API_CONFIG.json', debug=True)