API¤
The data that DAMNIT saves in its database and HDF5 files can be accessed through our Python API.
Quick start¤
You can open a database by proposal number, in which case it will look in
usr/Shared/amore
, or by an absolute path:
The run table can be read into a dataframe with Damnit.table():
# Use with_titles to name the columns by the variable titles rather than their
# names.
df = db.table(with_titles=True)
The variables themselves can be read by indexing db
:
run_vars = db[100] # Index by run number
run_vars.keys() # Get all available variables for this run
myvar = db[100, "myvar"] # Equivalent to run_vars["myvar"]
data = myvar.read()
summary = myvar.summary()
API reference¤
damnit.Damnit ¤
Represents a DAMNIT database.
Indexing this will return either a RunVariables or VariableData object:
db = Damnit(1234)
# Index by run number to get a RunVariables object
run_vars = db[100]
# Or by run number and variable name/title to get a VariableData object
myvar = db[100, "myvar"]
This is the entrypoint for inspecting data stored by DAMNIT.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
location |
int or str or Path
|
This can be either a proposal number or a path to a database directory. |
required |
runs ¤
A list of all existing runs.
Note that this does not include runs that were pre-created through the GUI but were never taken by the DAQ.
table ¤
Retrieve the run table as a DataFrame.
There are a few differences compared to what you'll see in the table displayed in the GUI:
- Images will be replaced with an
<image>
string. - Runs that were pre-created through the GUI but never taken by the DAQ will not be included.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
with_titles |
bool
|
Whether to use variable titles instead of names for the columns in the dataframe. |
False
|
damnit.RunVariables ¤
Represents the variables for a single run.
Don't create this object yourself, index a Damnit object instead.
Indexing this by either a variable name or title will return a VariableData object:
db = Damnit(1234)
run_vars = db[100]
myvar = run_vars["myvar"] # Alternatively by title, `run_vars["My Variable"]`
keys ¤
The names of the available variables.
Note that a variable will not appear in the list if there is no data for it.
titles ¤
The titles of available variables.
As with RunVariables.keys(), only variables that have data for the run will be included.
damnit.VariableData ¤
Represents a variable for a single run.
Don't create this object yourself, index a Damnit or RunVariables object instead.
file
property
¤
The path to the HDF5 file for the run.
Note that the data for user-editable variables will not be stored in the HDF5 files.
summary ¤
Read the summary data for a variable.
For user-editable variables like comments, this will be the same as VariableData.read().