lib_ini_files module¶
Routines for generating/accessing the .ini files with the configuration of the scenario for the correlation.
Notes¶
Parameters and values are case sensitive!
Regarding initialization files¶
Initialization files follow this format: | | [section] | param: value
-
lib_ini_files.
find_nearest_seconds
(vector_seconds_ref, seconds_fr)[source]¶ - Find second which is nearest to seconds_fr in delay param vector. In other words, find the timestamp
- (start time) of the accumulation period to which the timestamp of the frame corresponds.
- vector_seconds_ref : list of floats
- seconds for delay information (start time polynomials).
- seconds_fr
- seconds to be searched for in the previous item.
- seconds_out
- highest value lesser than the input number of seconds, or -1 if not found
-
lib_ini_files.
get_all_params_serial
(params_array, section)[source]¶ Retrieves list with all the parameters for a section.
- params_array : list
- list with configuration [created with serial_params_to_array()].
- section : str
- section to be looked up.
- values : str
- lists of strings corresponding to the parameters in the section.
-
lib_ini_files.
get_all_sections
(params_array)[source]¶ Retrieves list with all the section names.
- params_array
- list with configuration [created with serial_params_to_array()].
- sections
- list of strings with the names of all the sections in the ini file.
-
lib_ini_files.
get_all_values_serial
(params_array, param)[source]¶ Retrieves list with all the values of a paramter for all the section.
- params_array : list
- configuration [created with serial_params_to_array()].
- param : str
- parameter to be looked up through all sections.
- values
- list with strings with all the values corresponding to the requested paramter.
-
lib_ini_files.
get_delay_cache
(seconds_fr_nearest, pair_st_so, params_delays, cache_delays=[])[source]¶ Get the delays from the cache.
-
lib_ini_files.
get_pair_st_so
(st_id, so_id)[source]¶ Get string st<st_id>-so<so_id> (e.g. st0-so0).
- st_id : int
- station id.
- so_id : int
- source id.
- pair_st_so : str
- output.
-
lib_ini_files.
get_param_eq_vector
(params_array, section, param, separator_values=':', modein='int')[source]¶ Returns the vector with the mapped values for the specified parameters.
- params_array : list
- configuration [created with serial_params_to_array()].
- section : str
- section to be looked up.
- param : str
- parameter to be looked up.
- separator_values
- separator for values [SEP_VALUES from const_ini_files.py by default].
- modein : str
- selector of format for output: | “int” : convert values in output list to integer. | else: return output list as is (strings).
- eq_vector
- equivalent vector with indices reported at the first sections of the ini file.
Example:Given the file media.ini:[channels]CH2 = 1CH1 = 0[polarizations]L = 0R = 1[VDF-0.vt]polarizations = L:R:L:Rchannels = CH1:CH1:CH2:CH2station = At...>>>params_array=serial_params_to_array(serialize_config(sources_file=’media.ini’))>>>eq_vector=get_param_eq_vector(params_array,’VDF-0.vt’,’polarizations’)>>>print(eq_vector)[0, 1, 0, 1]
-
lib_ini_files.
get_param_serial
(params_array, section, param)[source]¶ Retrieves value given an array with parameters, the filename and the parameter.
- params_array : list
- configuration [created with serial_params_to_array()].
- section : str
- section to be looked up.
- param : str
- parameter to be looked up.
- value : str
- value corresponding to requested section and param.
Example:>>> value = get_param_serial(params_array,’VF-0.vt’,’channels’)>>> print(value)0:0:1:1
-
lib_ini_files.
get_param_total
(params_array, section, param, separator_values=':')[source]¶ Returns the number of different values for a parameter. This is e.g. for getting the number of polarizations in a media.ini file for a station.
- params_array : list
- configuration [created with serial_params_to_array()].
- section : str
- section to be looked up.
- param : str
- parameter to be looked up.
- separator_values
- separator for values [SEP_VALUES from const_ini_files.py by default].
- total : int
- number of different values separated by separator_vaules.
Example:>>> tot = get_param_total(params_array,’VF-0.vt’,’Channels’)>>> print(tot)2
-
lib_ini_files.
get_rates_cache
(seconds_fr_nearest, pair_st_so, params_delays, cache_rates=[])[source]¶ - Get rates from delays.ini. It allows to keep a cache (currently only one element) to
- reduce the number of look-ups.
-
lib_ini_files.
get_section_delay_model
(params_array, mjd_in, seconds, source_id_in, station_id_in, v=0)[source]¶ Get section from delay model ini file.
- params_array : list
- information from delay model ini file (see lib_ini_files.py).
- mjd_in
- MJD for the start of the experiment.
- seconds
- number of seconds for the start of the experiment.
- source_id_in : int
- source identifier in sources ini file.
- station_id_in : int
- stations identifier in stations ini file.
- v : int
- 0 by default, 1 for verbose mode.
- section_found : str
- section found in the delay model ini file, otherwise “”.
- start_s : int
- seconds for this section.
TO DO:Move to lib_ini_files.py
-
lib_ini_files.
get_val_vector
(params_array, section, param)[source]¶ Returns vector with list of values.
- params_array : list
- configuration [created with serial_params_to_array()].
- section : str
- string with section to be looked up.
- param : str
- parameter to be looked up.
Example:Given the file media.ini:...[file1]sidebands = U:U:U:U...>>>>sidebands=get_val_vector(params_media,”file1”,C_INI_MEDIA_SIDEBANDS)>>>>print(sidebands)[‘U’, ‘U’, ‘U’, ‘U’]
-
lib_ini_files.
get_vector_delay_ref
(vector_params_delay)[source]¶ Get seconds corresponding to elements in delays.ini.
- vector_params_delay : str
- serialized representation of the delay model ini file.
- sv : list of floats
- seconds for delay information (start time polynomials).
-
lib_ini_files.
serial_params_to_array
(read_str='')[source]¶ Converts string with serialized configuration file into array.
- read_str : str
- serialized configuration [created with serialize_config()].
- files_param : list of lists
- list of lists based on serialized configuration.
Example:>>> params_array=serial_params_to_array(serial_str)>>> print(params_array)[[‘VF-0.vt’, ‘polarizations/L:R:L:R’, ‘station/At’, ‘channels/0:0:1:1’], [‘VF-1.vt’, ‘polarizations/L:R:L:R’, ‘station/At’, ‘channels/0:0:1:1’]]
-
lib_ini_files.
serialize_config
(sources_file='media.ini')[source]¶ Converts configuration file into string.
- sources_file : str
- name of initialization [.ini] file (e.g.: media.ini, stations.ini, delays.ini, etc.)
- serial_str : str
- serialized contents of initialization file.
Format configuration:See const_ini_files.py:SEPARATOR_ELEMENTSSEPARATOR_VECTORSEP_VALUES**Notes:Avoid use of reserved separators from list of file if existingE.g.: list of files separated with commasfile1,file2 -> file1:file2Example:>>> serial_str=serialize_config()>>> print(serial_str)VF-0.vt,polarizations/L:R:L:R,station/At,channels/0:0:1:1;VF-1.vt,polarizations/L:R:L:R,station/At,channels/0:0:1:1