-
Notifications
You must be signed in to change notification settings - Fork 35
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #137 from nwittler/log-reader
Updated log reader and added docs.
- Loading branch information
Showing
6 changed files
with
112 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
Logs and current optimization status | ||
==================================== | ||
|
||
During optimizations (optimal control, calibration, model learning), a | ||
current best point is stored in the log folder to monitor progress. | ||
Called on a log file it will print a | ||
`rich <https://github.com/willmcgugan/rich>`__ table of the current | ||
status. With the ``-w`` or ``-- watch`` options the table will keep | ||
updating. | ||
|
||
.. code:: bash | ||
c3/utils/log_reader.py -h | ||
.. code-block:: | ||
usage: log_reader.py [-h] [-w WATCH] log_file | ||
positional arguments: | ||
log_file | ||
optional arguments: | ||
-h, --help show this help message and exit | ||
-w WATCH, --watch WATCH | ||
Update the table every WATCH seconds. | ||
Using the example log from the test folder: | ||
|
||
.. code:: bash | ||
c3/utils/log_reader.py test/sample_optim_log.c3log | ||
.. parsed-literal:: | ||
Optimization reached 0.00462 at Tue Aug 17 15:28:09 2021 | ||
┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━┓ | ||
┃ Parameter ┃ Value ┃ Gradient ┃ | ||
┡━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━┩ | ||
│ rx90p[0]-d1-gauss-amp │ 497.311 mV │ 18.720 mV │ | ||
│ rx90p[0]-d1-gauss-freq_offset │ -52.998 MHz 2pi │ -414.237 µHz 2pi │ | ||
│ rx90p[0]-d1-gauss-xy_angle │ -47.409 mrad │ 2.904 mrad │ | ||
│ rx90p[0]-d1-gauss-delta │ -1.077 │ 6.648 m │ | ||
└───────────────────────────────┴─────────────────┴──────────────────┘ | ||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{"opt_map": [["rx90p[0]-d1-gauss-amp"], ["rx90p[0]-d1-gauss-freq_offset"], ["rx90p[0]-d1-gauss-xy_angle"], ["rx90p[0]-d1-gauss-delta"]], "units": ["V", "Hz 2pi", "rad", ""], "optim_status": {"params": [0.49731057256150457, -52997604.24565414, -0.0474089606329513, -1.0765842275871154], "goal": 0.004623751716391289, "time": "Tue Aug 17 15:28:09 2021", "gradient": [0.018719753658557353, -0.00041423747880565335, 0.0029041996681835715, 0.006648118709775015]}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
""" | ||
Tests for command line utilities. | ||
""" | ||
|
||
import pytest | ||
import hjson | ||
from rich.console import Console | ||
|
||
from c3.c3objs import hjson_decode | ||
from c3.utils.log_reader import show_table | ||
|
||
SAMPLE_LOG = "test/sample_optim_log.c3log" | ||
|
||
|
||
@pytest.mark.unit | ||
def test_log_viewer(): | ||
""" | ||
Check that the log is read and processed without error. This does not check if | ||
the output is correct. | ||
""" | ||
console = Console() | ||
with open(SAMPLE_LOG) as logfile: | ||
show_table(hjson.load(logfile, object_pairs_hook=hjson_decode), console) |