Skip to content

egse.obsid

cgse-common

This code is part of the cgse-common package.

egse.obsid

An ObservationIdentifier or OBSID is a unique identifier for an observation or test.

Each observation or test needs a unique identification that can be used as a key in a database or in a filename for test data etc.

Classes:

Name Description
ObservationIdentifier

A unique identifier for each observation or test.

Functions:

Name Description
obsid_from_storage

Return the name of the folder for the given obsid in the 'obs' sub-folder of data_dir.

ObservationIdentifier

ObservationIdentifier(
    lab_id=None, setup_id=None, test_id=None
)

A unique identifier for each observation or test.

setup_id: the identifier for the setup that is used for the test
test_id: the test identifier or test number

Methods:

Name Description
create_id

Creates a string representation of the observation identifier.

create_id

create_id(*, order=LAB_SETUP_TEST, camera_name=None)

Creates a string representation of the observation identifier.

Parameters:

Name Type Description Default
order int

the order in which the parts are concatenated

LAB_SETUP_TEST
camera_name str

if a camera name is given, it will be appended in lower case

None

Returns:

Type Description
str

A string representation of the obsid with or without camera name attached.

obsid_from_storage

obsid_from_storage(
    obsid, data_dir, site_id=None, camera_name=None
)

Return the name of the folder for the given obsid in the 'obs' sub-folder of data_dir.

For the oldest observations, the obsid used in the directory structure and filenames was of the format TEST_LAB_SETUP. All files in this folder also have the obsid in that format in their name. At some point, we decided to change this to TEST_LAB, but we still need to be able to re-process the old data (with the setup ID in the names of the directories and files).

For newer observations (>= 2023.6.0+CGSE), the camera name is appended to the folder name and also included in the filenames in that folder.

Parameters:

Name Type Description Default
obsid Union[ObservationIdentifier, str, int]

Observation identifier. This can be an ObservationIdentifier object, a string in format TEST_LAB or TEST_LAB_SETUP, or an integer representing the test ID. In this last case, the site id is taken from the Settings.

required
data_dir str

root folder in which the observations are stored. This folder shall have a sub-folder 'obs'.

required
site_id str

a site id like 'CSL1' or 'IAS', when None, the SITE.ID from the Settings will be used

None
camera_name str

if not None, append the camera name to the result

None

Returns:

Type Description
str

The name of the folder for the given obsid in the 'obs' sub-folder of data_dir.