photons.utils module
General classes and functions.
- photons.utils.array_central(centre, width, step, *, randomize=False, decimals=None)[source]
Get an array about a central value, for a given full width and step size.
- Parameters:
centre (
float) – The central value in the array.width (
float) – The full width about centre. Must be an integer multiple of step.step (
float) – The step size. Must be a positive number.randomize (
bool) – Whether to randomize the values in the array.decimals (
int) – The number of decimals to use innumpy.around(). If not specified then uses the value of step to determine the number of decimals.
- Return type:
- Returns:
The requested array.
- photons.utils.array_evenly(start, stop, step, *, randomize=False, decimals=None)[source]
Return evenly-spaced values within a given interval.
The values are generated within the interval [start, stop].
- Parameters:
start (
float) – Start value (the interval includes this value).stop (
float) – Stop value (the interval includes this value).step (
float) – The step size.randomize (
bool) – Whether to randomize the values in the array.decimals (
int) – The number of decimals to use innumpy.around(). If not specified then uses the value of step to determine the number of decimals.
- Return type:
- Returns:
The requested array.
- photons.utils.array_merge(*vectors)[source]
Merge 1-D arrays, field by field, to create a new structured N-D array.
- Return type:
- photons.utils.array_photodiode_centre(centre, *, width=10, step=0.1, randomize=False, decimals=None)[source]
Useful when trying to find the centre position of a photodiode.
The returned array has values at the two edges of the photodiode and in the central region of the photodiode (in one-dimension only).
- Parameters:
centre (
float) – The position of a translation stage where the centre of the photodiode is believed to be.width (
float) – The width of the photodiode or the diameter of the aperture. Must have the same unit as step.step (
float) – The step size to move the translation stage within each of the three regions (not between regions).randomize (
bool) – Whether to randomize the values in the array.decimals (
int) – The number of decimals to use innumpy.around(). If not specified then uses the values of centre and step to determine the number of decimals.
- Return type:
- Returns:
The requested array.
- photons.utils.ave_std(data, *, axis=None)[source]
Calculate the average and standard deviation.
- Parameters:
- Return type:
- Returns:
The average value and the standard deviation.
- photons.utils.get_decimals(value)[source]
Get the number of digits after the decimal point.
This function returns a sensible result only if value was explicitly defined for a parameter (for example a value from a QSpinbox). If value is the result from a calculation then there will be floating-point issues, and will most likely return nonsense (e.g., a number > 15).
- Return type:
- photons.utils.lab_logging(root_url, *aliases, corrected=True, strict=True, timeout=10)[source]
Read the current temperature, humidity and dewpoint of (an) OMEGA iServer(s).
- Parameters:
root_url (
str) – The root url of the webapp, e.g.,'http://hostname:port/'aliases (
str) – The iServer alias(es) to retrieve the data from. If not specified then retrieves the data from all iServers.corrected (
bool) – Whether to return corrected (True) or uncorrected (False) values.strict (
bool) – Whether to raise an exception if the connection to the webapp cannot be established.timeout (
float) – The maximum number of seconds to wait for a reply from the webapp.
- Return type:
- Returns:
The temperature, humidity and dewpoint from the iServer(s).
- photons.utils.std_relative(array, *, axis=None)[source]
Calculate the relative standard deviation.
- Parameters:
- Return type:
- Returns:
The relative standard deviation.