koa_middleware.database.remote_database

Classes

RemoteCalibrationDB(instrument_name)

A class to interface with a remote calibration database hosted at Keck Observatory.

class koa_middleware.database.remote_database.RemoteCalibrationDB(instrument_name: str)[source]

Bases: object

A class to interface with a remote calibration database hosted at Keck Observatory.

The current implementation uses the Keck Observer login system for authentication. Eventually, this will be replaced with the appropriate client for accessing KOA. The URL _KECK_CALIBRATIONS_URL will also be replaced with the appropriate KOA URL.

add(meta: dict | list[dict])[source]

Add a new calibration metadata entry or entries to the remote database.

Parameters:

meta (dict or list[dict]) – A dictionary or a list of dictionaries containing the calibration metadata to add. If a list is provided, each dictionary should represent a separate calibration entry.

download_calibration_file(cal_id: str, output_dir: str, output_path: str | None = None) str[source]
get_last_updated() str[source]

Get the last updated timestamp for the instrument’s calibration data.

Returns:

The last updated timestamp as an ISO format string.

Return type:

str

query(**kwargs) dict | list[dict][source]

Query metadata from the remote calibration database.

Parameters:

**kwargs

cal_typestr, optional

Calibration type to filter by (e.g., “dark”).

cal_idstr, optional

Calibration ID to filter by.

date_time_startstr, optional

Start datetime in ISO format.

date_time_endstr, optional

End datetime in ISO format.

last_updated_startstr, optional

Start of last_updated range in ISO format.

last_updated_endstr, optional

End of last_updated range in ISO format.

fetchstr, optional

Fetch mode; use “first” to return only the first result.

Additional kwargs

Other parameters to pass to the remote API.

Returns:

The JSON response containing the queried metadata.

Return type:

dict or list[dict]