From 24f610835171149c84380f285537cbe436a385a2 Mon Sep 17 00:00:00 2001
From: Robert Izzard <r.izzard@surrey.ac.uk>
Date: Fri, 15 Oct 2021 09:18:23 +0100
Subject: [PATCH] add working modulo and start_at

---
 binarycpython/utils/grid.py                  | 9 +++++++--
 binarycpython/utils/grid_options_defaults.py | 3 ++-
 2 files changed, 9 insertions(+), 3 deletions(-)

diff --git a/binarycpython/utils/grid.py b/binarycpython/utils/grid.py
index 12cd6f0bb..246a9853c 100644
--- a/binarycpython/utils/grid.py
+++ b/binarycpython/utils/grid.py
@@ -606,7 +606,7 @@ class Population:
         }
 
         # Check for gridtype input
-        if not gridtype in ["edge", "centred"]:
+        if not gridtype in ["edge", "right", "right edge", "left", "left edge", "centred", "centre", "center"]:
             msg = "Unknown gridtype value. Please start another one"
             raise ValueError(msg)
 
@@ -1186,6 +1186,12 @@ class Population:
         # TODO: build in method to handle with the HPC.
         # Continuously fill the queue
         for system_number, system_dict in enumerate(generator):
+
+            # skip systems before start_at, and apply modulo
+            if(not(system_number >= self.grid_options['start_at'] and
+                   (system_number - self.grid_options['start_at']) % self.grid_options['modulo'] == 0)):
+                continue
+
             # Put job in queue
             job_queue.put((system_number, system_dict))
 
@@ -2155,7 +2161,6 @@ class Population:
         # TODO: Add correct logging everywhere
         # TODO: add part to handle separation if orbital_period is added. Idea. use default values
         #   for orbital parameters and possibly overwrite those or something.
-        # TODO: add centre left right for the spacing.
         # TODO: add sensible description to this function.
         # TODO: Check whether all the probability and phasevol values are correct.
         # TODO: import only the necessary packages/functions
diff --git a/binarycpython/utils/grid_options_defaults.py b/binarycpython/utils/grid_options_defaults.py
index 7fc2cb722..24feaf9ed 100644
--- a/binarycpython/utils/grid_options_defaults.py
+++ b/binarycpython/utils/grid_options_defaults.py
@@ -119,7 +119,8 @@ grid_options_defaults_dict = {
     "_population_id": 0,  # Random id of this grid/population run, Unique code for the population. Should be set only once by the controller process.
     "_total_mass_run": 0,  # To count the total mass that thread/process has ran
     "_total_probability_weighted_mass_run": 0,  # To count the total mass * probability for each system that thread/process has ran
-    "modulo": 1,  # run modulo n of the grid. #TODO: fix this
+    "modulo": 1,  # run modulo n of the grid.
+    "start_at": 0, # start at the first model
     ## Grid type evolution
     "_grid_variables": {},  # grid variables
     "gridcode_filename": None,  # filename of gridcode
-- 
GitLab