lcc.utils package

Submodules

lcc.utils.commons module

There are common functions and decorators mainly for query classes

class lcc.utils.commons.Spinner(txt='', delay=None)[source]

Methods

busy = False
delay = 0.1
spinner_task()[source]
static spinning_cursor()[source]
start()[source]
stop()[source]
lcc.utils.commons.accepts(*accepted_arg_types)[source]

A decorator to validate the parameter types of a given function. It is passed a tuple of types. eg. (<type ‘tuple’>, <type ‘int’>)

lcc.utils.commons.args_type(**decls)[source]

Decorator to check argument types

Examples

@args_type(name=”str”,age=(int,float)) def func(...):

lcc.utils.commons.check_attribute(attribute, cond, if_not=False)[source]

The class decorator checks if some class attributes has certain value

Parameters:

attribute : str

Name of the inspected class attribute

cond : optional

Condition to test for the inspected attribute

id_not : optional

Variable which will be returned if condition is not satisfied. If it is ‘raise’ exception will be raised

Returns:

Original output of the function if condition is satisfied

lcc.utils.commons.default_values(**decls)[source]

Decorator to add default values to certain arguments if missing

lcc.utils.commons.mandatory_args(*args_options)[source]

Decorator to check presence of mandatory arguments

Examples

@default_values((“name”,”age”),(“nick_name”,”sex”)) def func(...):

lcc.utils.commons.returns(*accepted_return_type_tuple)[source]

Validates the return type. Since there’s only ever one return type, this makes life simpler. Along with the accepts() decorator, this also only does a check for the top argument. For example you couldn’t check (<type ‘tuple’>, <type ‘int’>, <type ‘str’>). In that case you could only check if it was a tuple.

lcc.utils.data_analysis module

There are functions for processing data series

lcc.utils.data_analysis.abbe(x, n)[source]

Calculation of Abbe value

Parameters:

x : numpy.array

Input data serie

n : int

Dimension of original data (before dimension reduction)

Returns:

float

Abbe value

lcc.utils.data_analysis.computePrecision(true_pos, false_pos)[source]
lcc.utils.data_analysis.compute_bins(x_time, days_per_bin, set_min=5)[source]

Compute number of bins for given time series according to given ratio of number of days per one bin

Parameters:

x_time : numpy.array, list

List of times

days_per_bin : float

Transformation rate for dimension reduction

set_min

lcc.utils.data_analysis.histogram(xx, yy, bins_num=None, centred=True, normed=True)[source]
Parameters:

xx : numpy.array

Input x data

yy : numpy.array

Input y data

bins_num : int

Number of values in histogram

centred : bool

If True values will be shifted (mean value into the zero)

normed : bool

If True values will be normed (according to standard deviation)

Returns:

numpy.array

Number of values in particular ranges

numpy.array

Ranges

lcc.utils.data_analysis.normalize(x, eps=1e-06)[source]

Function will normalize an array (give it a mean of 0, and a standard deviation of 1) unless it’s standard deviation is below epsilon, in which case it returns an array of zeros the length of the original array.

Parameters:

x : numpy.array, list, iterable

Input data serie

Returns:

numpy.arrray

Normalized data serie

lcc.utils.data_analysis.sort_pairs(x, y, rev=False)[source]

Sort two numpy arrays according to the first

lcc.utils.data_analysis.to_PAA(x, bins)[source]

Function performs Piecewise Aggregate Approximation on data set, reducing the dimension of the dataset x to w discrete levels. returns the reduced dimension data set, as well as the indicies corresponding to the original data for each reduced dimension

Parameters:

x : list, array, iterable

1D serie of values

bins : int

Dimension of reduced data

Returns:

numpy.array

Approximated data serie

list

Indices

lcc.utils.data_analysis.to_ekvi_PAA(x, y, bins=None, days_per_bin=None)[source]

This method perform PAA (see above) on y data set, but it will consider different time steps between values (in x data set) and return corrected data set.

Parameters:

x : list, numpy.array, iterable

Times which is treated as template for transformation y values

y : list, numpy.array, iterable

List of values

bins : int

Dimension of result data

days_per_bin : float

This value can be used for calculating bins

Returns:

list

Reduced x data

list

Reduced y data

lcc.utils.data_analysis.variogram(x, y, bins=None, log_opt=True)[source]

Variogram of function shows variability of function in various time steps

Parameters:

x : list, numpy.array, iterable

Time values

y : list, numpy.array

Measured values

bins : int

Number of values in a variogram

log_opt : bool

Option if variogram values return in logarithm values

Returns:

tuple

Variogram as two numpy arrays

lcc.utils.helpers module

lcc.utils.helpers.checkDepth(a, deep_level, ifnotraise=True)[source]

Check if input list has desired level of nested lists

lcc.utils.helpers.clean_path(path)[source]

Get name from path as last item without dot

lcc.utils.helpers.convertInputValue(value)[source]
lcc.utils.helpers.create_folder(path)[source]

Create folder if it not exists

lcc.utils.helpers.get_arguments(insp_classes)[source]

Get args and kwargs of the class methods

Parameters:

insp_classes : list

Classes to inspect

lcc.utils.helpers.getMeanDict(dict_list)[source]
lcc.utils.helpers.get_combinations(keys, *lists)[source]

Make combinations from given lists

Parameters:

keys : list

Name of consequent columns (lists)

lists : list of lists

Values to combine

Returns:

list

All combinations

lcc.utils.helpers.progressbar(it, prefix='', size=60)[source]
Parameters:

it : list

List of values

prefix : str

Text which is displayed before progressbar

size : int

Number of items in progressbar

Returns:

None

lcc.utils.helpers.subDictInDict(sub_dict, dict_list, remove_keys=[])[source]
Parameters:

sub_dict : dict

Single dictionary

dict_list : list

List of dictionaries

remove_keys : list

List of keys which are removed from dictionaries

Example

——

subDictInDict({“x”:1},[{“x”:2,”y”:5,..},{“x”:1,”z”:2,..}, ..} –> [{“x”:1, “z”:2, ..},..]

In this example list of dictionaries which contain x = 1 is returned

Returns:

list

List of dictionaries which contain condition in sub_dict

lcc.utils.helpers.verbose(txt, verbosity, verb_level=2)[source]
Parameters:

txt : str

Message which will be showed

verb_level : int

Level of verbosity:

0 - All messages will be showed 1 - Just messages witch verbosity 1 an 2 will be showed 2 - Just messages witch verbosity 2 will be showed

verb_level : int

Verbosity level

Returns:

None

lcc.utils.output_process_modules module

lcc.utils.output_process_modules.loadFromFile(file_name='saved_object.pickle')[source]

Open object from file

Parameters:

file_name : str

Name of the serialized file

Returns:

object

Loaded object

lcc.utils.output_process_modules.saveIntoFile(obj, path='.', file_name='saved_object.pickle', folder_name=None)[source]

This method serialize object (save it into file)

obj : object
Object to serialize
path : str
Path to the folder
file_name : str
Name of result file
folder_name : str
Name of folder
Returns:None

lcc.utils.stars module

There are common functions for list of star objects (evaluation, plotting...)

lcc.utils.stars.plotStarsPicture(stars, option='show', hist_bins=10, vario_bins=10, center=True, save_loc=None, num_plots=None, abbe_bins=20)[source]

This function plot three graphs for all stars: Light curve, histogram and variogram. Additionally Abbe value will be displayed.

Parameters:

stars : list of `Star`s

List of star objects to be plot

option : str

Option whether plots will be saved or just showed

hist_bins : int

Dimension of histogram

vario_bins : int

Dimension of variogram

center : bool

Centering of histogram

save_loc : str, NoneType

Location where images will be saved

num_plots : int, NoneType

Number of plots

abbe_bins : int

Dimension of reduced light curve for calculating Abbe value

lcc.utils.stars.saveStars(stars, path='.', clobber=True)[source]

Save Star objects into fits files

Parameters:

stars : list, iterable

Star objects to be saved

path : str

Relative path to the file where fits are stored

clobber : bool

Files are overwritten if True

Returns:

list

List of names of star files

Module contents