bio_rtd.logger¶
DefaultLogger¶
-
class
bio_rtd.logger.
DefaultLogger
(log_level=30, log_data=False, log_level_data=10)[source]¶ Bases:
bio_rtd.logger.RtdLogger
Prints warnings to terminal and raises errors.
Does not store data.
-
DEBUG
= 10¶
-
ERROR
= 40¶
-
INFO
= 20¶
-
WARNING
= 30¶
-
d_data
(tree, key, value)¶ Log larger intermediate data (time series).
Populates (key, value.copy()) pair into tree if log_level_data >= DEBUG and log_data is True.
If the copy of the value is stored, then the self._on_data_stored function is called.
-
e
(msg)¶ Log message at ERROR level
ERROR level is meant for signaling events that are very likely the source of or the sign of inaccuracies in the model, but not severe enough to raise an exception in all situations (e.g. in an interactive session via GUI).
If the issue is big enough to warrant an exception, then raise the exception instead of using this log.
Examples
Probability distribution with only few data points. Probability distribution with a high cut-off at time 0. Load phase of PCC being shorter than the rest of the process.
-
get_data_tree
(data_tree_id)¶ Returns reference to the registered data tree.
- Return type
dict
-
get_entire_data_tree
()¶ Returns reference to the dict with all logged data.
-
i
(msg)¶ Log message at INFO level
INFO level is meant for events that might indicate potential mishaps the model, but can also occur normally.
Examples
- Reporting that surge tank ran dry.
This info might help explain the spectra, but it might just as well be a normal occurrence during the shut-down phase.
-
i_data
(tree, key, value)¶ Log smaller data (no time series).
Populates (key, value.copy()) pair into tree if log_level_data >= INFO and log_data is True.
If the copy of the value is stored, then the self._on_data_stored function is called.
-
log
(level, msg)[source]¶ Log messages at specific log level.
See documentation of self.e(), self.w() and self.i() on info about what belongs under which log level.
-
set_branch
(data_tree, branch_name, branch)¶ Seeds branch into data tree.
Typically used to store data from nested unit operations or parts of unit operations (evaluation data of probability distributions, breakthrough profiles, etc.).
- Parameters
data_tree (dict) – Parent data tree.
branch_name (dict) – Branch (child tree) name.
branch (dict) – Branch (child tree).
Examples
>>> log = DataStoringLogger() >>> data_tree = dict() >>> branch_tree = dict() >>> log.set_data_tree("my_uo", data_tree) >>> log.set_branch(data_tree, "pdf", branch_tree) >>> log.i_data(branch_tree, "par_b", 8.4) >>> data_tree["pdf"]["par_b"] 8.4 >>> branch_tree["par_b"] 8.4
-
set_data_tree
(data_tree_id, data_tree)¶ Seeds data tree in root dictionary.
Typically tree_id = uo.id and tree_root = dict().
Unit operation needs to save a reference to the tree_root in order to store data in this logger.
- Parameters
data_tree_id (str) – Id of root tree (typically id of unit operation).
data_tree (dict) – Root for data logging (for that unit operation).
Examples
>>> log = DataStoringLogger() >>> data_tree = dict() >>> log.set_data_tree("my_uo", data_tree) >>> log.i_data(data_tree, "par_a", 10.4) >>> data_tree["par_a"] 10.4
-
w
(msg)¶ Log message at WARNING level
WARNING level is meant for signaling events that might be the source of inaccuracies in the model.
Examples
Suspicious probability distributions. Empty concentration of flow rate profiles. Assumptions that might impact the results, such as assumptions during steady-state estimation.
-
DataStoringLogger¶
-
class
bio_rtd.logger.
DataStoringLogger
(log_level=30, log_data=True, log_level_data=10)[source]¶ Bases:
bio_rtd.logger.RtdLogger
Prints messages to terminal. Stores all data.
-
DEBUG
= 10¶
-
ERROR
= 40¶
-
INFO
= 20¶
-
WARNING
= 30¶
-
d_data
(tree, key, value)¶ Log larger intermediate data (time series).
Populates (key, value.copy()) pair into tree if log_level_data >= DEBUG and log_data is True.
If the copy of the value is stored, then the self._on_data_stored function is called.
-
e
(msg)¶ Log message at ERROR level
ERROR level is meant for signaling events that are very likely the source of or the sign of inaccuracies in the model, but not severe enough to raise an exception in all situations (e.g. in an interactive session via GUI).
If the issue is big enough to warrant an exception, then raise the exception instead of using this log.
Examples
Probability distribution with only few data points. Probability distribution with a high cut-off at time 0. Load phase of PCC being shorter than the rest of the process.
-
get_data_tree
(data_tree_id)¶ Returns reference to the registered data tree.
- Return type
dict
-
get_entire_data_tree
()¶ Returns reference to the dict with all logged data.
-
i
(msg)¶ Log message at INFO level
INFO level is meant for events that might indicate potential mishaps the model, but can also occur normally.
Examples
- Reporting that surge tank ran dry.
This info might help explain the spectra, but it might just as well be a normal occurrence during the shut-down phase.
-
i_data
(tree, key, value)¶ Log smaller data (no time series).
Populates (key, value.copy()) pair into tree if log_level_data >= INFO and log_data is True.
If the copy of the value is stored, then the self._on_data_stored function is called.
-
log
(level, msg)[source]¶ Log messages at specific log level.
See documentation of self.e(), self.w() and self.i() on info about what belongs under which log level.
-
set_branch
(data_tree, branch_name, branch)¶ Seeds branch into data tree.
Typically used to store data from nested unit operations or parts of unit operations (evaluation data of probability distributions, breakthrough profiles, etc.).
- Parameters
data_tree (dict) – Parent data tree.
branch_name (dict) – Branch (child tree) name.
branch (dict) – Branch (child tree).
Examples
>>> log = DataStoringLogger() >>> data_tree = dict() >>> branch_tree = dict() >>> log.set_data_tree("my_uo", data_tree) >>> log.set_branch(data_tree, "pdf", branch_tree) >>> log.i_data(branch_tree, "par_b", 8.4) >>> data_tree["pdf"]["par_b"] 8.4 >>> branch_tree["par_b"] 8.4
-
set_data_tree
(data_tree_id, data_tree)¶ Seeds data tree in root dictionary.
Typically tree_id = uo.id and tree_root = dict().
Unit operation needs to save a reference to the tree_root in order to store data in this logger.
- Parameters
data_tree_id (str) – Id of root tree (typically id of unit operation).
data_tree (dict) – Root for data logging (for that unit operation).
Examples
>>> log = DataStoringLogger() >>> data_tree = dict() >>> log.set_data_tree("my_uo", data_tree) >>> log.i_data(data_tree, "par_a", 10.4) >>> data_tree["par_a"] 10.4
-
w
(msg)¶ Log message at WARNING level
WARNING level is meant for signaling events that might be the source of inaccuracies in the model.
Examples
Suspicious probability distributions. Empty concentration of flow rate profiles. Assumptions that might impact the results, such as assumptions during steady-state estimation.
-
StrictLogger¶
-
class
bio_rtd.logger.
StrictLogger
[source]¶ Bases:
bio_rtd.logger.RtdLogger
Raises RuntimeError on warning and error messages.
-
DEBUG
= 10¶
-
ERROR
= 40¶
-
INFO
= 20¶
-
WARNING
= 30¶
-
d_data
(tree, key, value)¶ Log larger intermediate data (time series).
Populates (key, value.copy()) pair into tree if log_level_data >= DEBUG and log_data is True.
If the copy of the value is stored, then the self._on_data_stored function is called.
-
e
(msg)¶ Log message at ERROR level
ERROR level is meant for signaling events that are very likely the source of or the sign of inaccuracies in the model, but not severe enough to raise an exception in all situations (e.g. in an interactive session via GUI).
If the issue is big enough to warrant an exception, then raise the exception instead of using this log.
Examples
Probability distribution with only few data points. Probability distribution with a high cut-off at time 0. Load phase of PCC being shorter than the rest of the process.
-
get_data_tree
(data_tree_id)¶ Returns reference to the registered data tree.
- Return type
dict
-
get_entire_data_tree
()¶ Returns reference to the dict with all logged data.
-
i
(msg)¶ Log message at INFO level
INFO level is meant for events that might indicate potential mishaps the model, but can also occur normally.
Examples
- Reporting that surge tank ran dry.
This info might help explain the spectra, but it might just as well be a normal occurrence during the shut-down phase.
-
i_data
(tree, key, value)¶ Log smaller data (no time series).
Populates (key, value.copy()) pair into tree if log_level_data >= INFO and log_data is True.
If the copy of the value is stored, then the self._on_data_stored function is called.
-
log
(level, msg)[source]¶ Log messages at specific log level.
See documentation of self.e(), self.w() and self.i() on info about what belongs under which log level.
-
set_branch
(data_tree, branch_name, branch)¶ Seeds branch into data tree.
Typically used to store data from nested unit operations or parts of unit operations (evaluation data of probability distributions, breakthrough profiles, etc.).
- Parameters
data_tree (dict) – Parent data tree.
branch_name (dict) – Branch (child tree) name.
branch (dict) – Branch (child tree).
Examples
>>> log = DataStoringLogger() >>> data_tree = dict() >>> branch_tree = dict() >>> log.set_data_tree("my_uo", data_tree) >>> log.set_branch(data_tree, "pdf", branch_tree) >>> log.i_data(branch_tree, "par_b", 8.4) >>> data_tree["pdf"]["par_b"] 8.4 >>> branch_tree["par_b"] 8.4
-
set_data_tree
(data_tree_id, data_tree)¶ Seeds data tree in root dictionary.
Typically tree_id = uo.id and tree_root = dict().
Unit operation needs to save a reference to the tree_root in order to store data in this logger.
- Parameters
data_tree_id (str) – Id of root tree (typically id of unit operation).
data_tree (dict) – Root for data logging (for that unit operation).
Examples
>>> log = DataStoringLogger() >>> data_tree = dict() >>> log.set_data_tree("my_uo", data_tree) >>> log.i_data(data_tree, "par_a", 10.4) >>> data_tree["par_a"] 10.4
-
w
(msg)¶ Log message at WARNING level
WARNING level is meant for signaling events that might be the source of inaccuracies in the model.
Examples
Suspicious probability distributions. Empty concentration of flow rate profiles. Assumptions that might impact the results, such as assumptions during steady-state estimation.
-
RtdLogger¶
-
class
bio_rtd.logger.
RtdLogger
(log_level=30, log_data=False, log_level_data=10)[source]¶ Bases:
abc.ABC
Abstract class for log and log data in rtd models.
Logger has different levels: DEBUG, INFO, WARNING, ERROR. Logger has option to hold copies of intermediate data.
- Variables
log_level (int) – Verbosity level for messages. Default = WARNING.
log_data – If True, logger collects copies of intermediate data. Default = False.
log_level_data – ‘Verbosity level’ for data. Default = DEBUG. Ignored if log_data is False.
-
DEBUG
= 10¶ Log level DEBUG
DEBUG level is meant for keeping also large intermediate data (time series) in logger.
-
ERROR
= 40¶ Log level ERROR
ERROR level is meant for signaling events (with messages) that very likely impact the accuracy of the model.
-
INFO
= 20¶ Log level INFO
INFO level is meant for events that might indicate potential mishaps in the model, but can also occur normally (e.g. if surge tank runs dry). This info might help explain the spectra, but it might also be a normal occurrence during the shut-down phase.
INFO level is also meant for keeping small intermediate results (no time series) in logger.
-
WARNING
= 30¶ Log level WARNING
WARNING level is meant for signaling events (with messages) that might be the source of inaccuracies in the model.
-
d_data
(tree, key, value)[source]¶ Log larger intermediate data (time series).
Populates (key, value.copy()) pair into tree if log_level_data >= DEBUG and log_data is True.
If the copy of the value is stored, then the self._on_data_stored function is called.
-
e
(msg)[source]¶ Log message at ERROR level
ERROR level is meant for signaling events that are very likely the source of or the sign of inaccuracies in the model, but not severe enough to raise an exception in all situations (e.g. in an interactive session via GUI).
If the issue is big enough to warrant an exception, then raise the exception instead of using this log.
Examples
Probability distribution with only few data points. Probability distribution with a high cut-off at time 0. Load phase of PCC being shorter than the rest of the process.
-
get_data_tree
(data_tree_id)[source]¶ Returns reference to the registered data tree.
- Return type
dict
-
i
(msg)[source]¶ Log message at INFO level
INFO level is meant for events that might indicate potential mishaps the model, but can also occur normally.
Examples
- Reporting that surge tank ran dry.
This info might help explain the spectra, but it might just as well be a normal occurrence during the shut-down phase.
-
i_data
(tree, key, value)[source]¶ Log smaller data (no time series).
Populates (key, value.copy()) pair into tree if log_level_data >= INFO and log_data is True.
If the copy of the value is stored, then the self._on_data_stored function is called.
-
abstract
log
(level, msg)[source]¶ Log messages at specific log level.
See documentation of self.e(), self.w() and self.i() on info about what belongs under which log level.
-
set_branch
(data_tree, branch_name, branch)[source]¶ Seeds branch into data tree.
Typically used to store data from nested unit operations or parts of unit operations (evaluation data of probability distributions, breakthrough profiles, etc.).
- Parameters
data_tree (dict) – Parent data tree.
branch_name (dict) – Branch (child tree) name.
branch (dict) – Branch (child tree).
Examples
>>> log = DataStoringLogger() >>> data_tree = dict() >>> branch_tree = dict() >>> log.set_data_tree("my_uo", data_tree) >>> log.set_branch(data_tree, "pdf", branch_tree) >>> log.i_data(branch_tree, "par_b", 8.4) >>> data_tree["pdf"]["par_b"] 8.4 >>> branch_tree["par_b"] 8.4
-
set_data_tree
(data_tree_id, data_tree)[source]¶ Seeds data tree in root dictionary.
Typically tree_id = uo.id and tree_root = dict().
Unit operation needs to save a reference to the tree_root in order to store data in this logger.
- Parameters
data_tree_id (str) – Id of root tree (typically id of unit operation).
data_tree (dict) – Root for data logging (for that unit operation).
Examples
>>> log = DataStoringLogger() >>> data_tree = dict() >>> log.set_data_tree("my_uo", data_tree) >>> log.i_data(data_tree, "par_a", 10.4) >>> data_tree["par_a"] 10.4
-
w
(msg)[source]¶ Log message at WARNING level
WARNING level is meant for signaling events that might be the source of inaccuracies in the model.
Examples
Suspicious probability distributions. Empty concentration of flow rate profiles. Assumptions that might impact the results, such as assumptions during steady-state estimation.