Skip to content

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:

from damnit import Damnit

db = Damnit(1234) # This would also work: Damnit("/my/path/to/amore")

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 ¤

Damnit(location)

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

proposal property ¤

proposal: int

The currently active proposal of the database.

runs ¤

runs() -> list

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 ¤

table(with_titles=False) -> pd.DataFrame

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"]`

proposal property ¤

proposal: int

The proposal of the run.

run property ¤

run: int

The run number.

file property ¤

file: Path

The path to the HDF5 file for the run.

keys ¤

keys() -> list

The names of the available variables.

Note that a variable will not appear in the list if there is no data for it.

titles ¤

titles() -> list

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.

name property ¤

name: str

The variable name.

title property ¤

title: str

The variable title (defaults to the name if not set explicitly).

proposal property ¤

proposal: int

The proposal to which the variable belongs.

run property ¤

run: int

The run to which the variable belongs.

file property ¤

file: Path

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.

read ¤

read()

Read the data for the variable.

summary ¤

summary()

Read the summary data for a variable.

For user-editable variables like comments, this will be the same as VariableData.read().