tools package

Submodules

tools.badpix module

tools.badpix.gen_bad_pix_mask(image, filsize=5, threshold=5.0, return_smoothed_image=False)[source]

tools.charisLogger module

class tools.charisLogger.CharisLogger(name, level=0)[source]

Bases: logging.Logger

This is the advanced logging object used throughout the CHARIS Data Extraction Pipeline. It inherits from the standard Python library ‘logging’ and provides added features. The default log level for the output file will be 1, ie ALL messages; while the default for the screen will be INFO, and can be changed easily using the setStreamLevel(lvl) member function.

Initialize the logger with a name and an optional level.

MAINCRITICAL = 80
MAINDEBUG = 60
MAINERROR = 75
MAININFO = 65
MAINWARNING = 70
PRIMCRITICAL = 55
PRIMDEBUG = 35
PRIMERROR = 49
PRIMINFO = 39
PRIMWARNING = 45
SUMMARY = 5
TOOLCRITICAL = 29
TOOLDEBUG = 9
TOOLERROR = 25
TOOLINFO = 15
TOOLWARNING = 19
maincritical(msg, lvl=80, *args, **kws)[source]
maindebug(msg, lvl=60, *args, **kws)[source]
mainerror(msg, lvl=75, *args, **kws)[source]
maininfo(msg, lvl=65, *args, **kws)[source]
mainwarning(msg, lvl=70, *args, **kws)[source]
primcritical(msg, lvl=55, *args, **kws)[source]
primdebug(msg, lvl=35, *args, **kws)[source]
primerror(msg, lvl=49, *args, **kws)[source]
priminfo(msg, lvl=39, *args, **kws)[source]
primwarning(msg, lvl=45, *args, **kws)[source]
setStreamLevel(lvl=20)[source]

Set/change the level for the stream handler for a logging object. Any file handlers will be left alone. All messages of a higher severity level than ‘lvl’ will be printed to the screen.

Args:
lvl (int): The severity level of messages printed to the screen with
the stream handler, default = 20.
Standard Levels New Levels
Name Level Name Level
CRITICAL 50 MAINCRITICAL 80
ERROR 40 MAINERROR 75
WARNING 30 MAINWARNING 70
INFO 20 MAININFO 65
DEBUG 10 MAINDEBUG 60
NOTSET 0 PRIMCRITICAL 55
    PRIMERROR 49
PRIMWARNING 45
PRIMINFO 39
PRIMDEBUG 35
TOOLCRITICAL 29
TOOLERROR 25
TOOLWARNING 19
TOOLINFO 15
TOOLDEBUG 9
SUMMARY 5
summary(msg, lvl=5, *args, **kws)[source]
toolcritical(msg, lvl=29, *args, **kws)[source]
tooldebug(msg, lvl=9, *args, **kws)[source]
toolerror(msg, lvl=25, *args, **kws)[source]
toolinfo(msg, lvl=15, *args, **kws)[source]
toolwarning(msg, lvl=19, *args, **kws)[source]
tools.charisLogger.addFileHandler(log, lvl=1)[source]

This function will add a file handler to a log with the provided level.

Args:
log (CharisLogger object): A CharisLogger object that was freshly
instantiated.
lvl (int): The severity level of messages printed to the file with
the file handler, default = 1.
tools.charisLogger.addFitsStyleHandler(log)[source]

This function will add a file handler with a string format ideal for directly loading into a FITS header.

Args:
log (CharisLogger object): A CharisLogger object that was freshly
instantiated.
tools.charisLogger.addStreamHandler(log, lvl=20)[source]

This function will add a stream handler to a log with the provided level.

Args:
log (CharisLogger object): A CharisLogger object that was freshly
instantiated.
lvl (int): The severity level of messages printed to the screen with
the stream handler, default = 20.
tools.charisLogger.getLogger(name='generalLoggerName', lvl=20, addFH=True, addSH=True)[source]

This will either return the logging object already instantiated, or instantiate a new one and return it. Use this function to both create and return any logger to avoid accidentally adding additional handlers by using the setUpLogger function instead.

Args:
name (str): The name for the logging object and
name.log will be the output file written to disk.
lvl (int): The severity level of messages printed to the screen with
the stream handler, default = 20.
addFH (boolean): Add a file handler to this logger? Default severity
level for it will be 1, and it will be named following name+’.log’. Default = True.
addSH (boolean): Add a stream handler to this logger? Severity set with
the lvl argument. Default = True.
Returns:
log (CharisLogger object): A CharisLogger object that was either
freshly instantiated or determined to already exist, then returned.
tools.charisLogger.logFileProcessInfo(log)[source]
tools.charisLogger.logSystemInfo(log)[source]

A function to be called just after a logging object is instantiated for the DEP to load the log up with info about the computer it is being ran on and the software version. This function utilizes the psutil and platform libraries, so they must be install for it to work. For clarity of the log, it is suggested to perform immediately after instantiation to put it at the top of the log file.

Args:
log (Python logging object): logging object to have the system’s
info summarized in.

The messages this prints to the log will look like:

System Information Summary:
OS type = Linux
OS Version = 3.9.10-100.fc17.x86_64
Machine UserName = xxxxxx.astron.s.u-tokyo.ac.jp
Machine Processor Type = x86_64
Number of cores = 8
Total RAM [GB] = 23.5403785706, % used = 15.9
Python Version = ‘2.7.3’
tools.charisLogger.setUpLogger(name='generalLoggerName', lvl=20, addFH=True, addSH=True)[source]

This function is utilized by getLogger to set up a new logging object. It will have the default name ‘generalLoggerName’ and stream handler level of 20 unless redefined in the function call. NOTE: If a file handler is added, it will have the lowest severity level by default (Currently no need for changing this setting, so it will stay this way for now). Remember that any messages will be passed up to any parent loggers, so children do not always need their own file handler.

Args:
name (str): The name for the logging object and
name.log will be the output file written to disk.
lvl (int): The severity level of messages printed to the screen with
the stream handler, default = 20.
addFH (boolean): Add a file handler to this logger? Default severity
level for it will be 1, and it will be named following name+’.log’. Default = True.
addSH (boolean): Add a stream handler to this logger? Severity set with
the lvl argument. Default = True.
Returns:
log (CharisLogger object): A CharisLogger object that was freshly
instantiated.

Module contents