From 97d9901e4b0356d4a8ab77d65013e7f5b73bc009 Mon Sep 17 00:00:00 2001 From: Jan Petykiewicz Date: Sat, 12 Aug 2017 19:20:29 -0700 Subject: [PATCH] Use logging package for output --- fdtd.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/fdtd.py b/fdtd.py index bbdabec..961bc0e 100644 --- a/fdtd.py +++ b/fdtd.py @@ -6,6 +6,7 @@ See main() for simulation setup. import sys import time +import logging import numpy import lzma @@ -20,6 +21,9 @@ import fdfd_tools __author__ = 'Jan Petykiewicz' +logging.basicConfig(level=logging.DEBUG) +logger = logging.getLogger(__name__) + def perturbed_l3(a: float, radius: float, **kwargs) -> Pattern: """ @@ -120,7 +124,7 @@ def main(): eps=n_air**2, polygons=mask.as_polygons()) - print('grid shape: {}'.format(grid.shape)) + logger.info('grid shape: {}'.format(grid.shape)) # #### Create the simulation grid #### sim = Simulation(grid.grids, do_poynting=True, pml_thickness=8) @@ -157,7 +161,7 @@ def main(): e.wait() if t % 100 == 0: - print('iteration {}: average {} iterations per sec'.format(t, (t+1)/(time.perf_counter()-start))) + logger.info('iteration {}: average {} iterations per sec'.format(t, (t+1)/(time.perf_counter()-start))) sys.stdout.flush() with lzma.open('saved_simulation', 'wb') as f: