NuRadioReco.detector.RNO_G.db_mongo_read module
- class NuRadioReco.detector.RNO_G.db_mongo_read.Database(*args, **kwargs)[source]
Bases:
object
Interface to the RNO-G hardware database. This class uses the python API pymongo for the RNO-G MongoDB.
This classes allows you to connect to preconfigured mongo clients or select your mongo client freely. The database is accesible with the self.db variable.
- Parameters:
- database_connectionstr (Default: “RNOG_public”)
Specify mongo client. You have 5 options:
“env_pw_user”: Connect to a server with the environmental variables mongo_server, mongo_user, and mongo_password
“RNOG_public”: Preconfigured connection to read-only RNO-G Hardware DB
“RNOG_test_public”: Preconfigured connection to read-only RNO-G Test Hardware DB
“connection_string”: Use environmental variable db_mongo_connection_string to connect to mongo server
“mongodb*”: Every string which starts with `”mongodb” will be used to connect to a mongo server
- database_namestr (Default: None -> “RNOG_live”)
Select the database by name. If None (default) is passed, set to “RNOG_live”
- mongo_kwargsdict (Default: {})
Additional arguments to pass to MongoClient.
Methods
find_primary_measurement
(collection_name, ...)Find the object_id of entry with name 'name' and gives the measurement_id of the primary measurement, return the id of the object and the measurement
Depending on the inputs, all possible configurations in the database are returned; Input example: 'iglu_boards', 'Golden_IGLU' {'measurement_temp': 20, 'DRAB_id': 'Golden_DRAB'}
get_channel_signal_chain
(channel_signal_id)Returns the response data for a given signal chain.
function to return the channels signal chain information, returns primary unless measurement_name is not None
get_collection_information
(collection_name, ...)Get the information for a specified collection (will only work for 'station_position', 'channel_position' and 'signal_chain') if the station does not exist, {} will be returned.
get_complete_channel_information
(station_id, ...)Collects all available information about the input channel
get_complete_device_information
(station_id, ...)Collects all available information about a device
get_complete_station_information
(station_id)Collects all available information about the station
get_component_data
(component_type, ...[, ...])returns the current primary measurement of the component, reads in the component collection
get_general_channel_information
(station_id, ...)Get information from one channel.
get_general_device_information
(station_id, ...)Get information from one device.
get_general_station_information
(station_id)Get information from one station.
get_identifier
(station_id[, ...])Get the identifier for a station/channel/device measurement,
get_position
([station_id, ...])Function to return the channel position, returns primary unless measurement_name is not None
get_quantity_names
(collection_name, ...)Returns a list with all measurement names, ids, .
load_board_information
(type, board_name, ...)Load the information for a single component from the database (can be used for IGLU / DRAB)
Collects all the timestamps for station and channel (de)commissioning from the database.
set_database_time
(time)Set time for database.
set_detector_time
(time)Set time of detector.
get_collection_names
get_database_time
get_detector_time
get_object_names
get_station_ids
- set_database_time(time)[source]
Set time for database. This affects which primary measurement is used.
- Parameters:
- time: `datetime.datetime` or ``astropy.time.Time``
UTC time.
- set_detector_time(time)[source]
Set time of detector. This controls which stations/channels are commissioned.
- Parameters:
- time: `datetime.datetime` or ``astropy.time.Time``
UTC time.
- find_primary_measurement(collection_name, name, primary_time, identification_label, data_dict)[source]
Find the object_id of entry with name ‘name’ and gives the measurement_id of the primary measurement, return the id of the object and the measurement
- Parameters:
- collection_name: string
name of the collection that is searched (surface_board, iglu_board, …)
- name: string
the unique identifier of the input component
- primary_time: datetime.datetime
timestamp for the primary measurement
- identification_label: string
specify what kind of label is used for the identification (“name” or “id”)
- data_dict: dict
dictionary containing additional information that are used to search the database (e.g., channel_id, S_parameter)
- load_board_information(type, board_name, info_names)[source]
Load the information for a single component from the database (can be used for IGLU / DRAB)
- get_general_station_information(station_id)[source]
Get information from one station. Access information in the main collection.
- Parameters:
- station_id: int
Station id
- Returns:
- info: dict
- get_general_channel_information(station_id, channel_id)[source]
Get information from one channel. Access information in the main collection.
- Parameters:
- station_id: int
specifiy the station id from which the channel information is taken
- channel_id: int
specifiy the channel id
- Returns:
- info: dict
- get_general_device_information(station_id, device_id)[source]
Get information from one device. Access information in the main collection.
- Parameters:
- station_id: int
specifiy the station id from which the device information is taken
- device_id: int
specifiy the device id
- Returns:
- info: dict
- get_collection_information(collection_name, search_by, obj_id, measurement_name=None, channel_id=None, use_primary_time_with_measurement=False)[source]
Get the information for a specified collection (will only work for ‘station_position’, ‘channel_position’ and ‘signal_chain’) if the station does not exist, {} will be returned. Return primary measurement unless measurement_name is specified.
- Parameters:
- collection_name: string
Specify the collection, from which the information should be extracted (will only work for ‘station_position’, ‘channel_position’ and ‘signal_chain’)
- search_by: string
Specify if the collection is searched by ‘station_id’ or ‘id’. The latter is a position or signal chain identifier
- obj_id: string or int
station id or position/signal_chain identifier
- measurement_name: string
Use the measurement name to select the requested data (not database time / primary time). If “use_primary_time_with_measurement” is True, use measurement_name and primary time to find matching objects. (Default: None -> return measurement based on primary time)
- channel_id: int
Unique identifier of the channel. Only allowed if searched by ‘station_id’
- use_primary_time_with_measurement: bool
If True (and measurement_name is not None), use measurement name and primary time to select objects. (Default: False)
- Returns:
- info: list(dict)
- get_quantity_names(collection_name, wanted_quantity)[source]
Returns a list with all measurement names, ids, … or what is specified (example: wanted_quantity = measurements.measurement_name)
- get_all_available_signal_chain_configs(collection, object_name, input_dic)[source]
Depending on the inputs, all possible configurations in the database are returned; Input example: ‘iglu_boards’, ‘Golden_IGLU’ {‘measurement_temp’: 20, ‘DRAB_id’: ‘Golden_DRAB’}
- get_identifier(station_id, channel_device_id=None, component='station', what='signal')[source]
Get the identifier for a station/channel/device measurement,
For station and device returns position identifer. For channel returns position and signal chain identifier.
Access information in the main collection.
- Parameters:
- station id: int
Specify the station for which the measurement identifier is return
- channel_device_id: int
Specify the channel/device id. Only necessary if component=”channel” or “device. (Default: None)
- component: str
Specify for what you want to have the identifier(s): “station” (default), “channel”, or “device”
- what: str
For what to return the identifier: “position” (default) or “signal_chain” (only available for “channel”)
- Returns:
- position_id: str
Unique identifier to find measurement in different collection
- get_position(station_id=None, channel_device_id=None, position_id=None, measurement_name=None, use_primary_time_with_measurement=False, component='station', verbose=False)[source]
Function to return the channel position, returns primary unless measurement_name is not None
- get_channel_signal_chain_measurement(station_id=None, channel_id=None, channel_signal_id=None, measurement_name=None, verbose=False)[source]
function to return the channels signal chain information, returns primary unless measurement_name is not None
- get_component_data(component_type, component_id, supplementary_info, primary_time, verbose=True, sparameter='S21')[source]
returns the current primary measurement of the component, reads in the component collection
- get_complete_station_information(station_id, measurement_station_position=None, measurement_channel_position=None, measurement_signal_chain=None, measurement_device_position=None, verbose=True)[source]
Collects all available information about the station
- Parameters:
- station_id: int
The unique identifier of the station the channel belongs to
- measurement_station_position: string
If not None, this measurement will be collected (even though it is not the primary measurement)
- measurement_channel_position: string
If not None, this measurement will be collected (even though it is not the primary measurement)
- measurement_signal_chain: string
If not None, this measurement will be collected (even though it is not the primary measurement)
- measurement_device_position: string
If not None, this measurement will be collected (even though it is not the primary measurement)
- Returns:
- complete_info: dict
- get_channel_signal_chain(channel_signal_id, measurement_name=None, verbose=True)[source]
Returns the response data for a given signal chain.
- Parameters:
- channel_signal_id: str
Indentifier of the signal chain
- Returns:
- signal_chain: dict
A dictinoary which among otherthings contains the “response_chain” which carries the measured response for the different components in the signal chain.
- get_complete_channel_information(station_id, channel_id, measurement_position=None, measurement_signal_chain=None, verbose=True)[source]
Collects all available information about the input channel
- Parameters:
- station_id: int
The unique identifier of the station the channel belongs to
- channel_id: int
Channel id for which all information will be returned
- measurement_position: string
If not None, this measurement will be collected (even though it is not the primary measurement)
- measurement_signal_chain: string
If not None, this measurement will be collected (even though it is not the primary measurement)
- Returns:
- complete_info
- get_complete_device_information(station_id, device_id, measurement_position=None, verbose=True)[source]
Collects all available information about a device
- Parameters:
- station_id: int
The unique identifier of the station the device belongs to
- device_id: int
The device id for which the information will be written out
- measurement_position: string
If not None, this measurement will be collected (even though it is not the primary measurement)
- Returns:
- complete_info
- query_modification_timestamps_per_station()[source]
Collects all the timestamps for station and channel (de)commissioning from the database. Combines those to get a list of timestamps when modifications happened which requiers to update the buffer.
- Returns:
- station_data: dict(dict(list))
Returns for each station (key = station.id) a dictionary with three entries: “modification_timestamps”, “station_commission_timestamps”, “station_decommission_timestamps” each containing a list of timestamps. The former combines the latter two + channel (de)comission timestamps.