ilex.utils

check_ruamel_input(inp)[source]

Ruamel yaml is used in some cases, this will be used to process these inputs and make sure

Parameters:

inp (_class_) – Change ruamel class to python class

check_ruamel_output(out)[source]

Check if outputs are in right types

dict_checktype(dict, t)[source]

Check if all entries of Dict are type = t

Parameters:
  • dict (Dict) – Dictionary

  • t (Type()) – type to check against

Returns:

_description_

Return type:

_type_

dict_get(dict, keys)[source]

Get a sub-set of the Dictionary based on keys

Parameters:
  • dict (Dict) – Original dictionary

  • keys (List(str)) – List of items to retrieve

Returns:

new_dict – Sub-set of Dictionary

Return type:

Dict

dict_init(*dicts)[source]

Initilise any number of dictionaries

Returns:

A number of Dictionaries

Return type:

*dicts

dict_isall(dictA, dictB)[source]

Check if Entires in Dict A match those in Dict B

Parameters:
  • dictA (Dict) – Dict A

  • dictB (Dict) – Dict B

Returns:

1 if True, 0 if False

Return type:

bool

dict_null(dic)[source]

Set all entries in a Dictionary to ‘None’

Parameters:

dic (Dict) – Dictionary

Returns:

dic – Dict with entries set to ‘None’

Return type:

Dict

fix_ds_freq_lims(lims, df)[source]

fix ds frequency limits so they extend over the full dynamic spectrum. By default each frequency channel represents the midpoint of a frequency bin, but when plotting the dynamic spectra using plt.imshow, we need the entire bandwidth, so we add half a sample to each end.

Parameters:
  • lims (list[float]) – frequency limits, [min, max]

  • df (float) – frequency resolution

get_stk_from_datalist(data_list)[source]

Get Stokes characters, i.e. I, Q, U and V from list of Stokes products to make, i.e. “dsI”, “fQ” etc.

Parameters:

data_list (List(str)) – List of data products to make

Returns:

stk – Stokes Characters

Return type:

str

load_data(datafile: str, mmap=True)[source]

Load data to memory map

Parameters:
  • datafile (str) – filename or path

  • mmap (bool, optional) – is memorymap?, by default True

Returns:

data – loaded data

Return type:

np.mmap or np.ndarray

load_param_file(param_file=None, return_yaml_obj=False, ruamel2py=True)[source]

Load in param file and compare with default params file

Parameters:

param_file (str) – parameter file to load in, if None, will return default yaml file values

Returns:

params – parameters, compared with defaults

Return type:

Dict

load_plotstyle()[source]

Load in plotstyle file and compare with default plotstyle file

merge_dicts(*dicts)[source]

Combine multiple Dictionaries into 1 dictionary

Returns:

A number of dictionaries

Return type:

*dicts

plotnum2grid(nrows=None, ncols=None, num=None)[source]

Takes the number of axes you want and creates a grid, one can constrain either the number of rows or colums to make the grid. If Neither is specified, will create the smallest sqaure grid to fit.

Parameters:
  • nrows (int) – number of rows to keep constant

  • ncols (int) – number of columns to keep constant

  • num (int) – number of axes to make into grid

Returns:

  • grid_nrows (int) – number of rows of new grid

  • grid_ncols (int) – number of columns of new grid

save_data(data, filename: str)[source]

Save data to file

Parameters:
  • data (np.ndarray) – data to save to file

  • filename (str) – filename to save data to

save_param_file(pars, filename, yaml_obj=None)[source]

save to new parameter file

Parameters:
  • pars (dict) – dictionary of parameters in ilex.yaml format

  • filename (str) – filename of saved yaml file

set_plotstyle(filepath=None)[source]

set plotstyle path, if not given, will be set to default.

Parameters:

filepath (str, optional) – filepath to plotstyle yaml file, by default None

class struct_[source]
update_ruamel_CommentedMap(commented_map, key, val)[source]

Updated Commented map based on key, value pair

update_ruamel_CommentedSeq(commented_seq, val)[source]

Updates the value of the CommentedSeq whilst preserving the flow stype and comments