PyPSA uses the Python standard library logging.
This script shows how to use it and control the logging messages from different modules.
Available as a Jupyter notebook at http://www.pypsa.org/examples/logging-demo.ipynb.
In [ ]:
#logging.basicConfig() needs to be called BEFORE importing PyPSA
#The reason is that logging.basicConfig() can only be called
#once, and it is already called in pypsa.__init__.py; further
#calls are ignored.
#Choices are ERROR, WARNING, INFO, DEBUG
import logging
logging.basicConfig(level=logging.ERROR)
import pypsa, os
In [ ]:
csv_folder_name = "../ac-dc-meshed/ac-dc-data/"
network = pypsa.Network(csv_folder_name=csv_folder_name)
In [ ]:
out = network.lopf()
In [ ]:
out = network.lpf()
In [ ]:
#now turn on warnings just for OPF module
pypsa.opf.logger.setLevel(logging.WARNING)
In [ ]:
out = network.lopf()
In [ ]:
#now turn on all messages for the PF module
pypsa.pf.logger.setLevel(logging.DEBUG)
In [ ]:
out = network.lpf()
In [ ]:
#now turn off all messages for the PF module again
pypsa.pf.logger.setLevel(logging.ERROR)
In [ ]:
out = network.lpf()
In [ ]:
In [ ]: