NuRadioReco.detector.RNO_G.db_mongo_write module
- class NuRadioReco.detector.RNO_G.db_mongo_write.Database(*args, **kwargs)[source]
Bases:
Database
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
add_entry_to_database
(collection, ...[, ...])inserts a entry into the database.
changes the current active primary measurement for a single antenna measurement
change_primary_cable_measurement
(cable_type, ...)changes the current active primary measurement for a single cable measurement
changes the current active primary measurement for a single board measurement
change_primary_drab_measurement
(board_type, ...)changes the current active primary measurement for a single board measurement
change_primary_iglu_measurement
(board_type, ...)changes the current active primary measurement for a single board measurement
changes the current active primary measurement for a single board measurement
decommission_a_channel
(station_id, ...)function to decommission an active channel in the db
decommission_a_device
(station_id, device_id, ...)function to decommission an active device in the db
decommission_a_station
(station_id, decomm_time)function to decommission an active station in the db
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.
rename_database_collection
(old_name, new_name)changes the name of a collection of the database If the new name already exists, the operation fails.
set_database_time
(time)Set time for database.
set_detector_time
(time)Set time of detector.
set_not_working
(collection_name, name, ...)inserts that the input unit is broken.
update_current_primary
(collection_name, ...)updates the status of primary_measurement, set the timestamp of the current primary measurement to end at datetime.utcnow()
add_general_channel_info_to_station
add_general_device_info_to_station
add_general_station_info
add_measurement_protocol
clone_collection_to_collection
create_empty_collection
get_collection_names
get_database_time
get_detector_time
get_object_names
get_station_ids
- rename_database_collection(old_name, new_name)[source]
changes the name of a collection of the database If the new name already exists, the operation fails.
- Parameters:
- old_name: string
old name of the collection
- new_name: string
new name of the collection
- set_not_working(collection_name, name, primary_measurement, channel_id=None, breakout_id=None, breakout_channel_id=None)[source]
inserts that the input unit is broken. If the input unit dosn’t exist yet, it will be created.
- Parameters:
- collection_name: string
name of the collection that is searched (surface_board, iglu_board, …)
- name: string
the unique identifier of the input unit
- primary_measurement: boolean
specifies if this measurement is used as the primary measurement
- channel_id: int
channel-id of the measured object (default:None)
- breakout_id: int
number describing the breakout of the fiber (default: None)
- breakout_channel_id: string
string describing the breakout channel of the fiber (default: None)
- add_entry_to_database(collection, identification_key, identification_value, primary_measurement, data_dict, primary_measurement_start=None)[source]
inserts a entry into the database. If the measurement dosn’t exist yet, it will be created. Only works for the following collections: hpol, vpol, surface, …
- Parameters:
- collection: string
specify the collection in which the entry will be added
- identification_key: string
specify the key used for identification (must be ‘name’ or ‘id’)
- identification_value: string
specify the name of the entry (e.g. the name of the measurement or the channel position identifier)
- primary_measurement: bool
indicates the primary measurement to be used for analysis
- data_dict: dict
dictionary with all the information that should be saved for this entry
- primary_measurement_start: datetime.datetime
If this quantity is given, the start time of the primary measurement is set to this value. Otherwise, the primary start time will be set to the current time
- add_general_station_info(station_id, station_name, station_comment, number_of_samples, sampling_rate, commission_time, decommission_time=datetime.datetime(2080, 1, 1, 0, 0))[source]
- add_general_channel_info_to_station(station_id, channel_id, signal_chain, ant_type, channel_comment, commission_time, decommission_time=datetime.datetime(2080, 1, 1, 0, 0))[source]
- add_general_device_info_to_station(station_id, device_id, device_name, device_comment, amp_name, commission_time, decommission_time=datetime.datetime(2080, 1, 1, 0, 0))[source]
- update_current_primary(collection_name, name, identification_label, data_dict)[source]
updates the status of primary_measurement, set the timestamp of the current primary measurement to end at datetime.utcnow()
- Parameters:
- collection_name: string
name of the collection that is searched (surface_board, iglu_board, …)
- name: string
the unique identifier of the input component
- 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)
- change_primary_antenna_measurement(antenna_type, antenna_name, S_parameter, protocol, units_arr, function_test)[source]
changes the current active primary measurement for a single antenna measurement
- Parameters:
- antenna_type: string
specify if it is a VPol or HPol antenna
- antenna_name: string
the unique identifier of the antenna
- S_parameter: list of strings
specify which S_parameter is used (S11, …)
- protocol: string
details of the testing environment
- units_arr: list of strings
list of the input units (only y unit will be saved)
- function_test: boolean
describes if the channel is working or not
- change_primary_cable_measurement(cable_type, cable_name, S_parameter, protocol, units_arr, function_test)[source]
changes the current active primary measurement for a single cable measurement
- Parameters:
- cable_type: string
specify if it is a surface or downhole cable
- cable_name: string
the unique identifier of the cable
- S_parameter: list of strings
specify which S_parameter is used (S11, …)
- protocol: string
details of the testing environment
- units_arr: list of strings
list of the input units (only y unit will be saved)
- function_test: boolean
describes if the channel is working or not
- change_primary_iglu_measurement(board_type, board_name, S_parameter, protocol, units_arr, function_test, drab_id, laser_id, temperature)[source]
changes the current active primary measurement for a single board measurement
- Parameters:
- board_type: string
specify the board type
- board_name: string
the unique identifier of the board
- S_parameter: list of strings
specify which S_parameter is used (S11, …)
- protocol: string
details of the testing environment
- units_arr: list of strings
list of the input units (only y unit will be saved)
- function_test: boolean
describes if the channel is working or not
- drab_id: string
unique identifier of the drab used in the iglu measurement
- laser_id: string
id of the laser that is used in the iglu board
- temperature: int
temperature at which the measurement was performed
- change_primary_drab_measurement(board_type, board_name, S_parameter, iglu_id, photodiode_id, channel_id, temp, protocol, units_arr, function_test)[source]
changes the current active primary measurement for a single board measurement
- Parameters:
- board_type: string
specify the board type
- board_name: string
the unique identifier of the board
- S_parameter: list of strings
specify which S_parameter is used (S11, …)
- iglu_id: string
unique identifier of the iglu used in the drab measurement
- channel_id: int
channel of the drab that is measured
- temp: int
temperature at which the measurement was performed
- protocol: string
details of the testing environment
- units_arr: list of strings
list of the input units (only y unit will be saved)
- function_test: boolean
describes if the channel is working or not
- change_primary_surface_measurement(board_type, board_name, S_parameter, channel_id, temp, protocol, units_arr, function_test)[source]
changes the current active primary measurement for a single board measurement
- Parameters:
- board_type: string
specify the board type
- board_name: string
the unique identifier of the board
- S_parameter: list of strings
specify which S_parameter is used (S11, …)
- channel_id: int
channel of the surface board that is measured
- temp: int
temperature at which the measurement was performed
- protocol: string
details of the testing environment
- units_arr: list of strings
list of the input units (only y unit will be saved)
- function_test: boolean
describes if the channel is working or not
- change_primary_downhole_measurement(board_type, board_name, S_parameter, breakout_id, breakout_cha_id, iglu_id, drab_id, temp, protocol, units_arr, function_test)[source]
changes the current active primary measurement for a single board measurement
- Parameters:
- board_type: string
specify the board type
- board_name: string
the unique identifier of the board
- S_parameter: list of strings
specify which S_parameter is used (S11, …)
- breakout_id: int
number describing the breakout of the fiber (default: None)
- breakout_cha_id: string
string describing the breakout channel of the fiber (default: None)
- iglu_id: string
unique identifier of the iglu used in the measurement
- drab_id: string
unique identifier of the drab used in the measurement
- temp: int
temperature at which the measurement was performed
- protocol: string
details of the testing environment
- units_arr: list of strings
list of the input units (only y unit will be saved)
- function_test: boolean
describes if the channel is working or not
- decommission_a_station(station_id, decomm_time)[source]
function to decommission an active station in the db
- Parameters:
- station_id: int
the unique identifier of the station
- decomm_time: datetime
time which should be used for updating the decommission time
- decommission_a_channel(station_id, channel_id, decomm_time)[source]
function to decommission an active channel in the db
- Parameters:
- station_id: int
the unique identifier of the station
- channel_id: int
the unique identifier of the channel
- decomm_time: datetime
time which should be used for updating the decommission time
- decommission_a_device(station_id, device_id, decomm_time)[source]
function to decommission an active device in the db
- Parameters:
- station_id: int
the unique identifier of the station
- device_id: int
the unique identifier of the device
- decomm_time: datetime
time which should be used for updating the decommission 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)
- 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_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_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_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_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
- 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_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_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_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_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_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)
- 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)
- 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.