14.1.8. Miscellaneous¶
14.1.8.1. mosaic.settings module¶
Load analysis settings from a JSON file.
- Created:
8/24/2012
- Author:
Arvind Balijepalli <arvind.balijepalli@nist.gov>
- License:
See LICENSE.TXT
- ChangeLog:
- class mosaic.settings.settings(datpath, defaultwarn=True)[source]¶
Bases:
object
Initialize a settings object.
- Args:
datpath : Specify the location of the settings file. If a settings file is not found, return default settings.
defaultwarn : If True warn the user if a settings file was not found in the path specified by datpath.
14.1.8.2. mosaic.utilities.ionic_current_stats module¶
- Created:
10/30/2014
- Author:
Arvind Balijepalli <arvind.balijepalli@nist.gov>
- License:
See LICENSE.TXT
- ChangeLog:
- mosaic.utilities.ionic_current_stats.OpenCurrentDist(dat, limit, minBaseline=-1, maxBaseline=-1)[source]¶
Calculate the mean and standard deviation of a time-series.
- Args:
dat : time-series data
limit : limit the calculation to the top 50% (+0.5) of the range, bottom 50% (-0.5) or the entire range (0). Any other value of limit will cause it to be reset to 0 (i.e. full range).
14.1.8.3. mosaic.utilities.util module¶
A collection of utility functions
- mosaic.utilities.util.filter(dat, windowSz)[source]¶
Filter the data using a convolution. Returns an array of size len(dat)-windowSz+1 if dat is longer than windowSz. If len(dat) < windowSz, raise WindowSizeError
14.1.8.4. mosaic.utilities.mosaicLogFormat module¶
An object that allows arbitrary formatting of log text.
- Created:
09/12/2015
- Author:
Arvind Balijepalli <arvind.balijepalli@nist.gov>
- License:
See LICENSE.TXT
- ChangeLog:
- mosaic.utilities.mosaicLogFormat._d(msg, *args)[source]¶
Format a debug log message. This function will automatically append calling function name and file/line number.
- Parameters:
msg : Log message formatted using the Python formatter class.
args : Message arguments.
- Usage:
Log an integer or a float variable.
_d("Var x has value {0}", x) _d("Var y is a float with value {0:0.2f} to 2 decimal places.", y)
- mosaic.utilities.mosaicLogFormat._dprop(msg, *args)[source]¶
Format a debug log message for a class property. This function will automatically append calling function name and file/line number.
- Parameters:
msg : Log message formatted using the Python formatter class.
args : Message arguments.
- Usage:
Log a property that returns an integer or a float.
_dprop("Var x has value {0}", x) _dprop("Var y is a float with value {0:0.2f} to 2 decimal places.", y)
- class mosaic.utilities.mosaicLogFormat.mosaic_property(fget=None, fset=None, fdel=None, doc=None)[source]¶
Bases:
object
Emulate Python property. Add support to the getter and setter methods to automatically log properties in debug mode. The new class can be used exactly as the built-in Python property class, for example as a decorator
class foo: def __init__(self): self.x=100 @mosaic_property def x(self): return self.x @x.setter def x(self, val): self.x=val
Adapted from: https://docs.python.org/2/howto/descriptor.html#properties.
14.1.8.5. mosaic.utilities.mosaicLogging module¶
An implementation of Python logging heavily adapted from http://stackoverflow.com/questions/15727420/using-python-logging-in-multiple-modules.
- Created:
5/29/2016
- Author:
Arvind Balijepalli <arvind.balijepalli@nist.gov>
- License:
See LICENSE.TXT
- ChangeLog:
- class mosaic.utilities.mosaicLogging.MessageFormatter(fmt=None, datefmt=None, style='%', validate=True, *, defaults=None)[source]¶
Bases:
Formatter
- format(record)[source]¶
Format the specified record as text.
The record’s attribute dictionary is used as the operand to a string formatting operation which yields the returned string. Before formatting the dictionary, a couple of preparatory steps are carried out. The message attribute of the record is computed using LogRecord.getMessage(). If the formatting string uses the time (as determined by a call to usesTime(), formatTime() is called to format the event time. If there is exception information, it is formatted using formatException() and appended to the message.
- class mosaic.utilities.mosaicLogging.mosaicLogging(*args, **kwargs)[source]¶
Bases:
object
A custom logging class that uses the Python logging facility. Logs are automatically saved to a metaMDIO instance, and to a file log when DeveloperMode is active.
- static getLogger(name=None, dbHnd=None)[source]¶
Get a logger instance.
- Parameters:
name : Logger name
dbHnd : MetaMDIO handle to allow logs to be saved to the database.
- Usage:
In this example, we get an instance of a logger with the module name and log a debug message.
logger=mosaicLogging().getLogger(__name__) logger.debug("Test debug message")
14.1.8.6. mosaic.utilities.mosaicTiming module¶
A class that provides platform independent timing and function profiling utilities.
- Created:
4/10/2016
- Author:
Arvind Balijepalli <arvind.balijepalli@nist.gov>
- License:
See LICENSE.TXT
- ChangeLog:
- class mosaic.utilities.mosaicTiming.mosaicTiming[source]¶
Bases:
object
Profile code by attaching an instance of this class to any function. All the methods in this class are valid for the function being profiled.
- FunctionTiming(func)[source]¶
Pass the function to be profiled as an argument. Alternatively with python 2.4+, attach a decorator to the function being profiled.
- Parameters:
func : function to be profiled
- Usage:
funcTimer=mosaicTiming.mosaicTiming() @funcTimer.FunctionTiming def someFunc(): print 'doing something' # summarize the profiling results for someFunc funcTimer.PrintStatistics()
14.1.8.7. mosaic.utilities.fit_funcs module¶
Fit functions used in processing algorithms.
- Created:
10/30/2014
- Author:
Arvind Balijepalli <arvind.balijepalli@nist.gov>
- License:
See LICENSE.TXT
- ChangeLog: