Skip to content
Snippets Groups Projects

Fix logging for clock noise generation

Merged Jean-Baptiste Bayle requested to merge fix-logging into master
4 files
+ 59
53
Compare changes
  • Side-by-side
  • Inline
Files
4
@@ -13,6 +13,8 @@ import numpy
import h5py
import matplotlib.pyplot
logger = logging.getLogger(__name__)
class ForEachObject(abc.ABC):
"""Abstract class which represents a dictionary holding a value for each object."""
@@ -70,7 +72,7 @@ class ForEachObject(abc.ABC):
if size != 1 and len(value) != size:
raise ValueError(f"incompatible sizes in dictionary '{size}' and '{len(size)}'")
size = max(size, len(value))
logging.debug("Writing dataset of size '%s' with '%s' columns", size, len(self.indices()))
logger.debug("Writing dataset of size '%s' with '%s' columns", size, len(self.indices()))
# Write dataset
dtype = numpy.dtype({'names': self.indices(), 'formats': len(self.indices()) * [numpy.float64]})
hdf5.create_dataset(dataset, (size,), dtype=dtype)
@@ -109,7 +111,7 @@ class ForEachObject(abc.ABC):
size = len(self) if len(self) > 1 else 100
t = t0 + numpy.arange(size) * dt
# Plot signals
logging.info("Plotting signals for each object")
logger.info("Plotting signals for each object")
matplotlib.pyplot.figure(figsize=(12, 4))
for key, signal in self.items():
matplotlib.pyplot.plot(t, numpy.broadcast_to(signal, size), label=key)
@@ -120,7 +122,7 @@ class ForEachObject(abc.ABC):
matplotlib.pyplot.title(title)
# Save or show glitch
if output is not None:
logging.info("Saving plot to %s", output)
logger.info("Saving plot to %s", output)
matplotlib.pyplot.savefig(output, bbox_inches='tight')
else:
matplotlib.pyplot.show()
Loading