utils – Utility functions¶
This module contains functions that are common to several other modules in this directory.
-
class
utils.ColoredFormatter(msg, use_color=True)¶ Formatter compatible with Python
loggingmodule. Allows colored messages to be written to the terminal, determined by the level of the message (warning, error, etc.).-
format(record)¶
-
-
utils.bin_single_segment_slow(time, flux, fluxerr, nbins, segstart, segend)¶ Returns a binned segment. This should not be used in the pipeline! It is useful for plotting individual segments and debugging.
See http://stackoverflow.com/questions/6163334/binning-data-in-python-with-scipy-numpy
Parameters: Return type:
-
utils.boxcar(time, duration, depth, midtime)¶ General function for producing a boxcar signal; useful for plotting.
Parameters:
-
utils.decode_array(s)¶ base64-decode the given string.
Parameters: s (str) – String to decode Return type: list
-
utils.encode_array(arr)¶ base64-encodes the given numpy array.
Parameters: arr (numpy.ndarray) – Array to encode Return type: str
-
utils.encode_list(lst)¶ base64-encodes the given Python list.
Parameters: lst (list) – List to encode Return type: str
-
utils.handle_exception(exc_tuple)¶ If these commands are called as a pipe chain with bash, etc., the chain needs to be stopped with a
sys.exit(1)call, which prevents printing the information about the exception we are used to. Call this function with the exception tuple to print out the traceback to STDERR before calling the exit.Parameters: exc_tuple – Exception tuple (from sys.exc_info())Tupe exc_tuple: tuple
-
utils.read_mapper_output(f, separator='\t', uri=False)¶ Reads data from the input file, assuming the given separator, in base64 format; yields the decoded and split line. The format is KIC ID, quarter, [uri], time, flux, error for each line.
Parameters: Return type:
-
utils.read_pipeline_output(f, separator='\t')¶ Reads data from the input file, assuming the given separator, in base64 format; yields the decoded and split line. The format for each line is KIC ID, quarter, segment_start, segment_end, srsq_dip, duration_dip, depth_dip, midtime_dip, srsq_blip, duration_blip, depth_blip, midtime_blip.
Parameters: Return type: