phockett / tmo-dev

Dev and scratch space for tmo analysis routines dev
GNU General Public License v3.0
0 stars 0 forks source link

Pulling run info and configs (SACLA runs, plus general methods) #7

Open phockett opened 11 months ago

phockett commented 11 months ago

For SACLA workflow:

Basic logbook code example (from GSheet), working for 2023 runs:

# Source: https://stackoverflow.com/questions/19611729/getting-google-spreadsheet-csv-into-a-pandas-dataframe

# Tidy version
import pandas as pd

# Import Logbook
SHEET_ID = '<id number here>'
SHEET_NAME = 'Sheet1'
url = f'https://docs.google.com/spreadsheets/d/{SHEET_ID}/gviz/tq?tqx=out:csv&sheet={SHEET_NAME}'

logbook = pd.read_csv(url, header=0, index_col='Aq ')  # Get data from URL

# Clean up
logbook.index = logbook.index.astype(int)  # Force to int (otherwise float)
logbook.drop(logbook.columns[31:37], axis=1, inplace=True)  # Drop extra cols at the end
logbook.columns = logbook.columns.str.rstrip()   # Clean col name strings

# Display current
logbook.loc[runs]

Quick and dirty params setting in notebook via magic, e.g. %run -i 'aq189_params.py' where params file is just python vars from other sources.