From 0c03478be53eba0c8650aaa93be839a26bd872dc Mon Sep 17 00:00:00 2001
From: Robert Izzard <r.izzard@surrey.ac.uk>
Date: Fri, 8 Oct 2021 19:20:52 +0100
Subject: [PATCH] add system information to vb1print

---
 binarycpython/utils/grid.py | 29 ++++++++++++++++++++++++-----
 1 file changed, 24 insertions(+), 5 deletions(-)

diff --git a/binarycpython/utils/grid.py b/binarycpython/utils/grid.py
index 1cc2942c8..992e9f97c 100644
--- a/binarycpython/utils/grid.py
+++ b/binarycpython/utils/grid.py
@@ -1416,7 +1416,7 @@ class Population:
                 lock = multiprocessing.Lock()
 
                 # Do the printing itself
-                self.vb1print(ID, now, system_number)
+                self.vb1print(ID, now, system_number, system_dict)
 
                 # Set some values for next time
                 next_log_time = now + self.grid_options["log_dt"]
@@ -4271,7 +4271,7 @@ eccentricity3=0
     ######################
     # Status logging
 
-    def vb1print(self, ID, now, system_number):
+    def vb1print(self, ID, now, system_number, system_dict):
         """
         Verbosity-level 1 printing, to keep an eye on a grid.
         Arguments:
@@ -4316,9 +4316,27 @@ eccentricity3=0
         # add up memory use from each thread
         total_mem_use = sum(self.shared_memory["memory_use_per_thread"])
 
-        #
+        def _format_number(number):
+            # compact number formatter
+            string = "{number:.2g}".format(number=number)
+            string = string.replace("e+0","e+")
+            string = string.replace("e-0","e-")
+            return string
+
+        # make a string to describe the system e.g. M1, M2, etc.
+        system_string = ""
+        if 'multiplicity' in system_dict:
+            for i in range(system_dict['multiplicity']):
+                i1 = str(i+1)
+                system_string += "M{}=".format(i1) + _format_number(system_dict['M_'+i1]) + " "
+        if 'separation' in system_dict:
+            system_string += "a=" + _format_number(system_dict['separation'])
+        if 'orbital_period' in system_dict:
+            system_string += "P=" + _format_number(system_dict['orbital_period'])
+
+        # do the print
         verbose_print(
-            "{system_number}/{total_starcount}{modulo} {complete:5.1f}% complete {hours:02d}:{minutes:02d}:{seconds:02d} ETA={eta:7.1f}{units} tpr={tpr:2.2e} ETF={etf} mem:{mem_use:.1f}MB".format(
+            "{system_number}/{total_starcount}{modulo} {complete:5.1f}% complete {hours:02d}:{minutes:02d}:{seconds:02d} ETA={eta:7.1f}{units} tpr={tpr:2.2e} ETF={etf} mem:{mem_use:.1f}MB {system_string}".format(
                 system_number = system_number,
                 total_starcount = self.grid_options["_total_starcount"],
                 complete=(100.0*system_number)/(1.0*self.grid_options["_total_starcount"]) if self.grid_options["_total_starcount"] else -1,
@@ -4330,7 +4348,8 @@ eccentricity3=0
                 units = units,
                 tpr = tpr,
                 etf = etf,
-                mem_use = total_mem_use
+                mem_use = total_mem_use,
+                system_string=system_string
             ),
             self.grid_options["verbosity"],
             1
-- 
GitLab