cea.utilities package¶
-
class
cea.utilities.
devnull
[source]¶ Bases:
object
Suppress sys.stdout so that it goes to devnull for duration of the with block
-
cea.utilities.
identifier
(s, sep='-')[source]¶ First, all characters are lowercased, then, any character that is not in ascii_lowercase is replaced with
sep
.Parameters: Return type:
-
class
cea.utilities.
pushd
(path)[source]¶ Bases:
object
Manage an os.chdir so that at the end of a with block, the path is set back to what it was
-
cea.utilities.
remap
(x, in_min, in_max, out_min, out_max)[source]¶ Scale x from range [in_min, in_max] to [out_min, out_max] Based on this StackOverflow answer: https://stackoverflow.com/a/43567380/2260
-
cea.utilities.
unique
(sequence)[source]¶ Return only the unique elements in sequence, preserving order.
Parameters: sequence (Sequence[T]) – the sequence to unique-ify Return type: List[T]
Submodules¶
cea.utilities.color_fader module¶
cea.utilities.compile_pyd_files module¶
Compile the .pyd files using Numba pycc to speed up the calculation of certain modules. Currently used for:
- calc_tm.pyd (used in demand/sensible_loads.py)
- calc_radiator.pyd (used in technologies/radiators.py)
In order to run this script, you will need to install Numba. Try: conda install numba
cea.utilities.create_mixed_use_type module¶
cea.utilities.create_polygon module¶
cea.utilities.date module¶
cea.utilities.dbf module¶
cea.utilities.doc_glossary module¶
cea.utilities.doc_graphviz module¶
cea.utilities.doc_html module¶
cea.utilities.doc_schemas module¶
cea.utilities.epwreader module¶
cea.utilities.latin_hypercube module¶
cea.utilities.parallel module¶
Standardizes multiprocessing use. In the CEA, some functions are run using the standard multiprocessing
library.
They are run by map``ing the function to a list of arguments (see ``multiprocessing.Pool.map_async
) and waiting
for the processes to finish, while at the same time piping STDOUT, STDERR through
cea.utilities.workerstream.QueueWorkerStream
- this ensures that the dashboard interface can read the output from
the sub-processes.
The way this was done in CEA < v2.23 included boiler plate code that needed to be repeated every time multiprocessing was used. Issue [#2344](https://github.com/architecture-building-systems/CityEnergyAnalyst/issues/2344) was a result of not applying this technique to the demand script.
This module exports the function map which is intended to replace both map_async
and the builtin map
function
(which was used when config.multiprocessing == False
). This simplifies multiprocessing.
-
cea.utilities.parallel.
__apply_func_with_worker_stream
(args)[source]¶ Call func, using
queue
to redirect stdout and stderr, with a tuple of args because multiprocessing.Pool.map only accepts one argument for the function.This function is called _inside_ a separate process.
-
cea.utilities.parallel.
__multiprocess_wrapper
(func, processes, on_complete)[source]¶ Create a worker pool to map the function, taking care to set up STDOUT and STDERR
-
cea.utilities.parallel.
single_process_wrapper
(func, on_complete)[source]¶ The simplest form of vectorization: Just loop
-
cea.utilities.parallel.
vectorize
(func, processes=1, on_complete=None)[source]¶ Similar to
numpy.vectorize
, this function wrapsfunc
so that it operates on sequences (of same length) of inputs and outputs a sequence of results, similar tomap(func, *args)
.The main point of using
vectorize
is to unify single-processing with multi-processing - if processes > 1, then multiprocessing is used and the function will be run on a pool of processes. STDOUT and STDERR of these processes are fed through acea.workerstream.QueueWorkerStream
so it can be shown in the dashboard job output.The parameter
on_complete
is an optional callable that is called for each completed call offunc
. It takes 4 arguments:- i: the 0-based order in which this call was completed
- n: the total number of function calls to be made
- args: the arguments passed to this call to
func
- result: the return value of this call to
func
Parameters: - func – The function to vectorize
- processes (int) – The number of processes to use (use
config.get_number_of_processes()
) - on_complete – An optional function to call for each completed call to
func
.
cea.utilities.physics module¶
Physical functions
cea.utilities.rename_building module¶
cea.utilities.reporting module¶
cea.utilities.schedule_reader module¶
cea.utilities.solar_equations module¶
cea.utilities.standardize_coordinates module¶
cea.utilities.workerstream module¶
This file implements WorkerStream
for capturing stdout and stderr.
-
class
cea.utilities.workerstream.
QueueWorkerStream
(name, q)[source]¶ Bases:
object
File-like object for wrapping the output of the scripts with queues - to be created in child process