From 1ebfa5837bb5d1cb5ec055107bd58afd3d841523 Mon Sep 17 00:00:00 2001 From: Unknown Date: Wed, 17 Jan 2018 15:35:35 +1100 Subject: [PATCH 01/28] Make sequencer constraint *make the Sequencer class *veto=True if current_obs is in obs_list *might want a better string to be returned --- pocs/scheduler/constraint.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/pocs/scheduler/constraint.py b/pocs/scheduler/constraint.py index 3907baaa3..070bcb1a6 100644 --- a/pocs/scheduler/constraint.py +++ b/pocs/scheduler/constraint.py @@ -159,3 +159,21 @@ def get_score(self, time, observer, observation, **kwargs): def __str__(self): return "Moon Avoidance" + +class Seqencer(BaseConstraint): + + def __init__(self, *args, **kwargs): + super().__init__(*args, **kwargs) + + def get_score(self, time, observer, observation, **kwargs): + target = observation.field + + veto = False + score = self._score + + if scheduler.current_observation in scheduler.observed_list: + veto = True + return None + + def __str__(self): + return "Don't repeat observations" From 497b4dd48e00d46f2ca81f780f55bfe53247a66b Mon Sep 17 00:00:00 2001 From: Unknown Date: Wed, 17 Jan 2018 15:57:59 +1100 Subject: [PATCH 02/28] *can't use scheduler here (try observation) *return veto and score (does not need to be changed) --- pocs/scheduler/constraint.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/pocs/scheduler/constraint.py b/pocs/scheduler/constraint.py index 070bcb1a6..480cda0f8 100644 --- a/pocs/scheduler/constraint.py +++ b/pocs/scheduler/constraint.py @@ -166,14 +166,15 @@ def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) def get_score(self, time, observer, observation, **kwargs): - target = observation.field - veto = False score = self._score - if scheduler.current_observation in scheduler.observed_list: + target = observation.field + + if target in self.observation.observed_list: veto = True - return None + + return veto, score * self.weight def __str__(self): return "Don't repeat observations" From 7623a69498b35f1aa6f4d56079a95a706fa7d3c7 Mon Sep 17 00:00:00 2001 From: Unknown Date: Wed, 17 Jan 2018 16:34:09 +1100 Subject: [PATCH 03/28] *edit --- pocs/scheduler/constraint.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pocs/scheduler/constraint.py b/pocs/scheduler/constraint.py index 480cda0f8..c100a8f1e 100644 --- a/pocs/scheduler/constraint.py +++ b/pocs/scheduler/constraint.py @@ -170,8 +170,9 @@ def get_score(self, time, observer, observation, **kwargs): score = self._score target = observation.field + observed = observation.observed_list - if target in self.observation.observed_list: + if target in observed: veto = True return veto, score * self.weight From beac3739557588662575aa57c8c7b8e31f1e628a Mon Sep 17 00:00:00 2001 From: Unknown Date: Wed, 17 Jan 2018 23:43:16 +1100 Subject: [PATCH 04/28] Change names *change name of method *change string returned by method --- pocs/scheduler/constraint.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pocs/scheduler/constraint.py b/pocs/scheduler/constraint.py index c100a8f1e..6949cc349 100644 --- a/pocs/scheduler/constraint.py +++ b/pocs/scheduler/constraint.py @@ -160,7 +160,7 @@ def get_score(self, time, observer, observation, **kwargs): def __str__(self): return "Moon Avoidance" -class Seqencer(BaseConstraint): +class AlreadyVisited(BaseConstraint): def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) @@ -178,4 +178,4 @@ def get_score(self, time, observer, observation, **kwargs): return veto, score * self.weight def __str__(self): - return "Don't repeat observations" + return "Already Visited" From 2260d04f5fdaef8135082da61c814ae99678f722 Mon Sep 17 00:00:00 2001 From: Unknown Date: Thu, 18 Jan 2018 09:22:47 +1100 Subject: [PATCH 05/28] Start making test for constraint *small change to constraint *template of test **makes observed list **checks two different obs, one in list one not --- pocs/scheduler/constraint.py | 6 +++--- pocs/tests/test_constraints.py | 22 ++++++++++++++++++++++ 2 files changed, 25 insertions(+), 3 deletions(-) diff --git a/pocs/scheduler/constraint.py b/pocs/scheduler/constraint.py index 6949cc349..430acc865 100644 --- a/pocs/scheduler/constraint.py +++ b/pocs/scheduler/constraint.py @@ -170,10 +170,10 @@ def get_score(self, time, observer, observation, **kwargs): score = self._score target = observation.field - observed = observation.observed_list + observed_list = kwargs['observed_list'] - if target in observed: - veto = True + if target in observed_list: + veto = True return veto, score * self.weight diff --git a/pocs/tests/test_constraints.py b/pocs/tests/test_constraints.py index f620453bb..6dea192fe 100644 --- a/pocs/tests/test_constraints.py +++ b/pocs/tests/test_constraints.py @@ -14,6 +14,7 @@ from pocs.scheduler.constraint import BaseConstraint from pocs.scheduler.constraint import Duration from pocs.scheduler.constraint import MoonAvoidance +from pocs.scheduler.constraint import AlreadyVisited @pytest.fixture @@ -197,3 +198,24 @@ def test_moon_avoidance(observer): assert veto1 is False and veto2 is False assert score2 > score1 + + +def test_already_visited(observer): + avc = AlreadyVisited() + + time = Time('2016-08-13 10:00:00') + + observation1 = Observation(Field('HD189733', '20h00m43.7135s +22d42m39.0645s')) # HD189733 + observation2 = Observation(Field('Hat-P-16', '00h38m17.59s +42d27m47.2s')) # Hat-P-16 + observation3 = Observation(Field('Sabik', '17h10m23s -15d43m30s')) # Sabik + + observed_list = OrderedDict() + + observed_list[observation1.seq_time] = observation1 + observed_list[observation2.seq_time] = observation2 + + veto1, score1 = avc.get_score(time, observer, observation1, observed_list=observed_list) + veto2, score2 = avc.get_score(time, observer, observation3, observed_list=observed_list) + + assert veto1 is True + assert veto2 is False From b9f78775346d3bbdcef007f54dfd803d2aab354a Mon Sep 17 00:00:00 2001 From: Unknown Date: Thu, 18 Jan 2018 10:41:11 +1100 Subject: [PATCH 06/28] Edits *add docstring *use observer.observed_list *change test to use observer.observed_list --- pocs/scheduler/constraint.py | 7 ++++++- pocs/tests/test_constraints.py | 10 +++++----- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/pocs/scheduler/constraint.py b/pocs/scheduler/constraint.py index 430acc865..8d5242444 100644 --- a/pocs/scheduler/constraint.py +++ b/pocs/scheduler/constraint.py @@ -162,6 +162,11 @@ def __str__(self): class AlreadyVisited(BaseConstraint): + """ Simple Already Visited Constraint + + A simple already visited constraint that determines if the given `observation` + has already been visited before. + """ def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) @@ -170,7 +175,7 @@ def get_score(self, time, observer, observation, **kwargs): score = self._score target = observation.field - observed_list = kwargs['observed_list'] + observed_list = kwargs.get('observed_list', observer.observed_list) if target in observed_list: veto = True diff --git a/pocs/tests/test_constraints.py b/pocs/tests/test_constraints.py index 6dea192fe..b943657ee 100644 --- a/pocs/tests/test_constraints.py +++ b/pocs/tests/test_constraints.py @@ -209,13 +209,13 @@ def test_already_visited(observer): observation2 = Observation(Field('Hat-P-16', '00h38m17.59s +42d27m47.2s')) # Hat-P-16 observation3 = Observation(Field('Sabik', '17h10m23s -15d43m30s')) # Sabik - observed_list = OrderedDict() + observer.observed_list = OrderedDict() - observed_list[observation1.seq_time] = observation1 - observed_list[observation2.seq_time] = observation2 + observer.observed_list[observation1.seq_time] = observation1 + observer.observed_list[observation2.seq_time] = observation2 - veto1, score1 = avc.get_score(time, observer, observation1, observed_list=observed_list) - veto2, score2 = avc.get_score(time, observer, observation3, observed_list=observed_list) + veto1, score1 = avc.get_score(time, observer, observation1) + veto2, score2 = avc.get_score(time, observer, observation3) assert veto1 is True assert veto2 is False From 440a466356d9e82041226b72a21a4444cf4c25a0 Mon Sep 17 00:00:00 2001 From: Unknown Date: Thu, 18 Jan 2018 10:55:12 +1100 Subject: [PATCH 07/28] *fix indent typo --- pocs/scheduler/constraint.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pocs/scheduler/constraint.py b/pocs/scheduler/constraint.py index 8d5242444..de628b8ab 100644 --- a/pocs/scheduler/constraint.py +++ b/pocs/scheduler/constraint.py @@ -163,7 +163,7 @@ def __str__(self): class AlreadyVisited(BaseConstraint): """ Simple Already Visited Constraint - + A simple already visited constraint that determines if the given `observation` has already been visited before. """ @@ -177,8 +177,8 @@ def get_score(self, time, observer, observation, **kwargs): target = observation.field observed_list = kwargs.get('observed_list', observer.observed_list) - if target in observed_list: - veto = True + if target in observed_list: + veto = True return veto, score * self.weight From f4ab18ef3c3ce7305036f48d80509b8f792461f1 Mon Sep 17 00:00:00 2001 From: Unknown Date: Thu, 18 Jan 2018 11:04:00 +1100 Subject: [PATCH 08/28] *put return into function --- pocs/scheduler/constraint.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pocs/scheduler/constraint.py b/pocs/scheduler/constraint.py index de628b8ab..8b73321ce 100644 --- a/pocs/scheduler/constraint.py +++ b/pocs/scheduler/constraint.py @@ -180,7 +180,7 @@ def get_score(self, time, observer, observation, **kwargs): if target in observed_list: veto = True - return veto, score * self.weight + return veto, score * self.weight def __str__(self): return "Already Visited" From cfce4224e226fc5015f4614e731cf3fadc064893 Mon Sep 17 00:00:00 2001 From: Unknown Date: Thu, 18 Jan 2018 11:34:40 +1100 Subject: [PATCH 09/28] *import OrderedDict --- pocs/scheduler/constraint.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/pocs/scheduler/constraint.py b/pocs/scheduler/constraint.py index 8b73321ce..b7fcf855d 100644 --- a/pocs/scheduler/constraint.py +++ b/pocs/scheduler/constraint.py @@ -1,5 +1,7 @@ from astropy import units as u +from collections import OrderedDict + from pocs import PanBase From c8e118ed0cd306aa79bde48416e8438105180ed0 Mon Sep 17 00:00:00 2001 From: Unknown Date: Thu, 18 Jan 2018 12:08:44 +1100 Subject: [PATCH 10/28] *initialize observed_list to be empty --- pocs/tests/test_constraints.py | 1 + 1 file changed, 1 insertion(+) diff --git a/pocs/tests/test_constraints.py b/pocs/tests/test_constraints.py index b943657ee..42c76321e 100644 --- a/pocs/tests/test_constraints.py +++ b/pocs/tests/test_constraints.py @@ -209,6 +209,7 @@ def test_already_visited(observer): observation2 = Observation(Field('Hat-P-16', '00h38m17.59s +42d27m47.2s')) # Hat-P-16 observation3 = Observation(Field('Sabik', '17h10m23s -15d43m30s')) # Sabik + observer.observed_list = None observer.observed_list = OrderedDict() observer.observed_list[observation1.seq_time] = observation1 From 0c72b443376bca26cd5cbc13dea4f105cd926b56 Mon Sep 17 00:00:00 2001 From: Unknown Date: Thu, 18 Jan 2018 12:28:31 +1100 Subject: [PATCH 11/28] Couple fixups *consistent formatting *add import OrderedDict to test_constraints.py --- pocs/scheduler/constraint.py | 1 + pocs/tests/test_constraints.py | 2 ++ 2 files changed, 3 insertions(+) diff --git a/pocs/scheduler/constraint.py b/pocs/scheduler/constraint.py index b7fcf855d..da40411b7 100644 --- a/pocs/scheduler/constraint.py +++ b/pocs/scheduler/constraint.py @@ -162,6 +162,7 @@ def get_score(self, time, observer, observation, **kwargs): def __str__(self): return "Moon Avoidance" + class AlreadyVisited(BaseConstraint): """ Simple Already Visited Constraint diff --git a/pocs/tests/test_constraints.py b/pocs/tests/test_constraints.py index 42c76321e..f563a7fe6 100644 --- a/pocs/tests/test_constraints.py +++ b/pocs/tests/test_constraints.py @@ -7,6 +7,8 @@ from astropy.coordinates import get_moon from astropy.time import Time +from collections import OrderedDict + from pocs.scheduler.field import Field from pocs.scheduler.observation import Observation From 86c6f55611fff5829373d6773917e28c40bd96fc Mon Sep 17 00:00:00 2001 From: Unknown Date: Thu, 18 Jan 2018 12:52:44 +1100 Subject: [PATCH 12/28] *not checking observation.field --- pocs/scheduler/constraint.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pocs/scheduler/constraint.py b/pocs/scheduler/constraint.py index da40411b7..eeea8d97c 100644 --- a/pocs/scheduler/constraint.py +++ b/pocs/scheduler/constraint.py @@ -177,7 +177,7 @@ def get_score(self, time, observer, observation, **kwargs): veto = False score = self._score - target = observation.field + target = observation observed_list = kwargs.get('observed_list', observer.observed_list) if target in observed_list: From 71735abaa418c082f391f8a3408ddff8b2b7195a Mon Sep 17 00:00:00 2001 From: Unknown Date: Thu, 18 Jan 2018 13:25:16 +1100 Subject: [PATCH 13/28] *try for loop --- pocs/scheduler/constraint.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/pocs/scheduler/constraint.py b/pocs/scheduler/constraint.py index eeea8d97c..41858b898 100644 --- a/pocs/scheduler/constraint.py +++ b/pocs/scheduler/constraint.py @@ -177,11 +177,12 @@ def get_score(self, time, observer, observation, **kwargs): veto = False score = self._score - target = observation + target = observation.field observed_list = kwargs.get('observed_list', observer.observed_list) - if target in observed_list: - veto = True + for seq_time, Observation in observed_list: + if target = observation: + veto = True return veto, score * self.weight From 4548b9b40b96fd48943e515ee1371459331cadbc Mon Sep 17 00:00:00 2001 From: Unknown Date: Thu, 18 Jan 2018 13:37:16 +1100 Subject: [PATCH 14/28] *fix typos --- pocs/scheduler/constraint.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pocs/scheduler/constraint.py b/pocs/scheduler/constraint.py index 41858b898..23559d9fe 100644 --- a/pocs/scheduler/constraint.py +++ b/pocs/scheduler/constraint.py @@ -177,11 +177,11 @@ def get_score(self, time, observer, observation, **kwargs): veto = False score = self._score - target = observation.field + target = observation observed_list = kwargs.get('observed_list', observer.observed_list) - for seq_time, Observation in observed_list: - if target = observation: + for seq_time, previous_obs in observed_list: + if target == previous_obs: veto = True return veto, score * self.weight From 8106c11b62a54865e6ce1c7cc80a6cc296014e41 Mon Sep 17 00:00:00 2001 From: Unknown Date: Thu, 18 Jan 2018 14:06:38 +1100 Subject: [PATCH 15/28] *put print to see what observed_list looks like --- pocs/scheduler/constraint.py | 1 + 1 file changed, 1 insertion(+) diff --git a/pocs/scheduler/constraint.py b/pocs/scheduler/constraint.py index 23559d9fe..6c79a8780 100644 --- a/pocs/scheduler/constraint.py +++ b/pocs/scheduler/constraint.py @@ -179,6 +179,7 @@ def get_score(self, time, observer, observation, **kwargs): target = observation observed_list = kwargs.get('observed_list', observer.observed_list) + print(observed_list) for seq_time, previous_obs in observed_list: if target == previous_obs: From dcfba36637cab0d68fad2378b96b44e1003d30ed Mon Sep 17 00:00:00 2001 From: Unknown Date: Thu, 18 Jan 2018 14:52:58 +1100 Subject: [PATCH 16/28] Hopefully final fix! *add .items() at the end of observed_list --- pocs/scheduler/constraint.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/pocs/scheduler/constraint.py b/pocs/scheduler/constraint.py index 6c79a8780..12185ba9d 100644 --- a/pocs/scheduler/constraint.py +++ b/pocs/scheduler/constraint.py @@ -177,12 +177,10 @@ def get_score(self, time, observer, observation, **kwargs): veto = False score = self._score - target = observation observed_list = kwargs.get('observed_list', observer.observed_list) - print(observed_list) - for seq_time, previous_obs in observed_list: - if target == previous_obs: + for seq_time, previous_obs in observed_list.items(): + if observation == previous_obs: veto = True return veto, score * self.weight From aa6abe08809365a6646775274d3ad7ecc8db96cf Mon Sep 17 00:00:00 2001 From: Unknown Date: Thu, 18 Jan 2018 15:37:51 +1100 Subject: [PATCH 17/28] *try dict instead of OrderedDict --- pocs/tests/test_constraints.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/pocs/tests/test_constraints.py b/pocs/tests/test_constraints.py index f563a7fe6..1975d6d94 100644 --- a/pocs/tests/test_constraints.py +++ b/pocs/tests/test_constraints.py @@ -211,8 +211,7 @@ def test_already_visited(observer): observation2 = Observation(Field('Hat-P-16', '00h38m17.59s +42d27m47.2s')) # Hat-P-16 observation3 = Observation(Field('Sabik', '17h10m23s -15d43m30s')) # Sabik - observer.observed_list = None - observer.observed_list = OrderedDict() + observer.observed_list = {} observer.observed_list[observation1.seq_time] = observation1 observer.observed_list[observation2.seq_time] = observation2 From b50a07d7686f2949eb7cfe209d42fa5886afab51 Mon Sep 17 00:00:00 2001 From: Unknown Date: Thu, 18 Jan 2018 15:48:40 +1100 Subject: [PATCH 18/28] *change back to OrderedDict *set seq_time for all observations --- pocs/tests/test_constraints.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/pocs/tests/test_constraints.py b/pocs/tests/test_constraints.py index 1975d6d94..b8b0081dc 100644 --- a/pocs/tests/test_constraints.py +++ b/pocs/tests/test_constraints.py @@ -211,7 +211,11 @@ def test_already_visited(observer): observation2 = Observation(Field('Hat-P-16', '00h38m17.59s +42d27m47.2s')) # Hat-P-16 observation3 = Observation(Field('Sabik', '17h10m23s -15d43m30s')) # Sabik - observer.observed_list = {} + observer.observed_list = OrderedDict() + + observation1.seq_time = '01:00' + observation2.seq_time = '02:00' + observation3.seq_time = '03:00' observer.observed_list[observation1.seq_time] = observation1 observer.observed_list[observation2.seq_time] = observation2 From e33509edb7916051af969c13c5b1f66c6f249136 Mon Sep 17 00:00:00 2001 From: Unknown Date: Thu, 18 Jan 2018 16:07:37 +1100 Subject: [PATCH 19/28] *add sentence in class description --- pocs/scheduler/constraint.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pocs/scheduler/constraint.py b/pocs/scheduler/constraint.py index 12185ba9d..529dc19bd 100644 --- a/pocs/scheduler/constraint.py +++ b/pocs/scheduler/constraint.py @@ -168,7 +168,8 @@ class AlreadyVisited(BaseConstraint): """ Simple Already Visited Constraint A simple already visited constraint that determines if the given `observation` - has already been visited before. + has already been visited before. If given `observation` has already been + visited then it will not be considered for a call to become the `current observation`. """ def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) From 773d2b36c897d53aed0906ed61b418c5c0b28a68 Mon Sep 17 00:00:00 2001 From: Unknown Date: Thu, 18 Jan 2018 16:14:11 +1100 Subject: [PATCH 20/28] *don't need import OrderedDict in constraint.py --- pocs/scheduler/constraint.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/pocs/scheduler/constraint.py b/pocs/scheduler/constraint.py index 529dc19bd..3b4e318fd 100644 --- a/pocs/scheduler/constraint.py +++ b/pocs/scheduler/constraint.py @@ -1,7 +1,5 @@ from astropy import units as u -from collections import OrderedDict - from pocs import PanBase From 25b1a3ee4bd825d6d9c7ed273d91c627546d9d5a Mon Sep 17 00:00:00 2001 From: Unknown Date: Thu, 18 Jan 2018 16:43:49 +1100 Subject: [PATCH 21/28] *avoid loop --- pocs/scheduler/constraint.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/pocs/scheduler/constraint.py b/pocs/scheduler/constraint.py index 3b4e318fd..53ac3eada 100644 --- a/pocs/scheduler/constraint.py +++ b/pocs/scheduler/constraint.py @@ -178,9 +178,8 @@ def get_score(self, time, observer, observation, **kwargs): observed_list = kwargs.get('observed_list', observer.observed_list) - for seq_time, previous_obs in observed_list.items(): - if observation == previous_obs: - veto = True + if observation.seq_time in observed_list: + veto = True return veto, score * self.weight From 5b7b6fec1d24076e0d46cc30e49a7ac2ded43947 Mon Sep 17 00:00:00 2001 From: Unknown Date: Fri, 19 Jan 2018 08:39:57 +1100 Subject: [PATCH 22/28] Edit the scheduler playground *include `AlreadyVisited` constraint *import from constraint *add to `constrains` array --- examples/notebooks/Scheduler Playground.ipynb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/notebooks/Scheduler Playground.ipynb b/examples/notebooks/Scheduler Playground.ipynb index 17b0ba455..65eb8ef13 100644 --- a/examples/notebooks/Scheduler Playground.ipynb +++ b/examples/notebooks/Scheduler Playground.ipynb @@ -31,7 +31,7 @@ "from astroplan import Observer\n", "\n", "from pocs.scheduler.dispatch import Scheduler\n", - "from pocs.scheduler.constraint import Duration, MoonAvoidance\n", + "from pocs.scheduler.constraint import AlreadyVisited, Duration, MoonAvoidance\n", "from pocs.utils.config import load_config\n", "from pocs.utils import listify\n", "\n", @@ -72,7 +72,7 @@ "simple_fields_file = config['directories']['targets'] + '/simple.yaml'\n", "\n", "# Simple constraint to maximize duration above a certain altitude\n", - "constraints = [MoonAvoidance(), Duration(30 * u.deg)]\n", + "constraints = [AlreadyVisited(), MoonAvoidance(), Duration(30 * u.deg)]\n", "\n", "# Create a scheduler\n", "scheduler = Scheduler(observer, fields_file=simple_fields_file, constraints=constraints)" From 5c0b274b6e46e28450243e28c0a1df036a145c6a Mon Sep 17 00:00:00 2001 From: Unknown Date: Fri, 19 Jan 2018 21:43:04 +1100 Subject: [PATCH 23/28] Fixing issue with observed_list *take observer.observed_list out constraint *add observed_list to common_properties *just define observed_list in test (?) --- pocs/scheduler/constraint.py | 2 +- pocs/scheduler/dispatch.py | 3 ++- pocs/tests/test_constraints.py | 6 +++--- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/pocs/scheduler/constraint.py b/pocs/scheduler/constraint.py index 53ac3eada..1d438af8f 100644 --- a/pocs/scheduler/constraint.py +++ b/pocs/scheduler/constraint.py @@ -176,7 +176,7 @@ def get_score(self, time, observer, observation, **kwargs): veto = False score = self._score - observed_list = kwargs.get('observed_list', observer.observed_list) + observed_list = kwargs.get('observed_list') if observation.seq_time in observed_list: veto = True diff --git a/pocs/scheduler/dispatch.py b/pocs/scheduler/dispatch.py index e965a0fcc..e1ec903b1 100644 --- a/pocs/scheduler/dispatch.py +++ b/pocs/scheduler/dispatch.py @@ -49,7 +49,8 @@ def get_observation(self, time=None, show_all=False, reread_fields_file=False): common_properties = { 'end_of_night': self.observer.tonight(time=time, horizon=-18 * u.degree)[-1], - 'moon': get_moon(time, self.observer.location) + 'moon': get_moon(time, self.observer.location), + 'observed_list': self.observed_list } for constraint in listify(self.constraints): diff --git a/pocs/tests/test_constraints.py b/pocs/tests/test_constraints.py index b8b0081dc..fdb02f495 100644 --- a/pocs/tests/test_constraints.py +++ b/pocs/tests/test_constraints.py @@ -211,14 +211,14 @@ def test_already_visited(observer): observation2 = Observation(Field('Hat-P-16', '00h38m17.59s +42d27m47.2s')) # Hat-P-16 observation3 = Observation(Field('Sabik', '17h10m23s -15d43m30s')) # Sabik - observer.observed_list = OrderedDict() + observed_list = OrderedDict() observation1.seq_time = '01:00' observation2.seq_time = '02:00' observation3.seq_time = '03:00' - observer.observed_list[observation1.seq_time] = observation1 - observer.observed_list[observation2.seq_time] = observation2 + observed_list[observation1.seq_time] = observation1 + observed_list[observation2.seq_time] = observation2 veto1, score1 = avc.get_score(time, observer, observation1) veto2, score2 = avc.get_score(time, observer, observation3) From fd783070a9e5c9ee65241d162e2e5b85593f894d Mon Sep 17 00:00:00 2001 From: Unknown Date: Sat, 20 Jan 2018 11:06:54 +1100 Subject: [PATCH 24/28] *pass observed_list into get_score for already visited constraint --- pocs/scheduler/constraint.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pocs/scheduler/constraint.py b/pocs/scheduler/constraint.py index d20b98677..613c82c70 100644 --- a/pocs/scheduler/constraint.py +++ b/pocs/scheduler/constraint.py @@ -167,7 +167,7 @@ class AlreadyVisited(BaseConstraint): def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) - def get_score(self, time, observer, observation, **kwargs): + def get_score(self, time, observer, observation, observed_list=observed_list, **kwargs): veto = False score = self._score From 058bc654ea4638cc55485ee8bb4c772eb409bdbe Mon Sep 17 00:00:00 2001 From: jermainegug <32515601+jermainegug@users.noreply.github.com> Date: Sat, 20 Jan 2018 21:33:55 +1100 Subject: [PATCH 25/28] *put observed_list into get_score --- pocs/tests/test_constraints.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pocs/tests/test_constraints.py b/pocs/tests/test_constraints.py index 93ccbae7d..564ac9c0e 100644 --- a/pocs/tests/test_constraints.py +++ b/pocs/tests/test_constraints.py @@ -253,8 +253,8 @@ def test_already_visited(observer): observed_list[observation1.seq_time] = observation1 observed_list[observation2.seq_time] = observation2 - veto1, score1 = avc.get_score(time, observer, observation1) - veto2, score2 = avc.get_score(time, observer, observation3) + veto1, score1 = avc.get_score(time, observer, observation1, observed_list=observed_list) + veto2, score2 = avc.get_score(time, observer, observation3, observed_list=observed_list) assert veto1 is True assert veto2 is False From f2cba6c61cc1488e8d77a10e00a95e5314b4fbf4 Mon Sep 17 00:00:00 2001 From: jermainegug <32515601+jermainegug@users.noreply.github.com> Date: Sat, 20 Jan 2018 21:38:29 +1100 Subject: [PATCH 26/28] Undo commit *take out observed_list=observed_list from get_score *was put into the wrong get_score --- pocs/scheduler/constraint.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pocs/scheduler/constraint.py b/pocs/scheduler/constraint.py index 613c82c70..d20b98677 100644 --- a/pocs/scheduler/constraint.py +++ b/pocs/scheduler/constraint.py @@ -167,7 +167,7 @@ class AlreadyVisited(BaseConstraint): def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) - def get_score(self, time, observer, observation, observed_list=observed_list, **kwargs): + def get_score(self, time, observer, observation, **kwargs): veto = False score = self._score From 37c9616e5c244a4924b811fd3c185e946c3efebd Mon Sep 17 00:00:00 2001 From: Unknown Date: Sun, 21 Jan 2018 11:57:40 +1100 Subject: [PATCH 27/28] *update shceduler notebook --- examples/notebooks/Scheduler Playground.ipynb | 119 ++++++++++-------- 1 file changed, 64 insertions(+), 55 deletions(-) diff --git a/examples/notebooks/Scheduler Playground.ipynb b/examples/notebooks/Scheduler Playground.ipynb index 8ba58618c..bd1ad4105 100644 --- a/examples/notebooks/Scheduler Playground.ipynb +++ b/examples/notebooks/Scheduler Playground.ipynb @@ -3,7 +3,9 @@ { "cell_type": "code", "execution_count": 1, - "metadata": {}, + "metadata": { + "collapsed": true + }, "outputs": [], "source": [ "%load_ext autoreload\n", @@ -12,7 +14,7 @@ }, { "cell_type": "code", - "execution_count": 15, + "execution_count": 3, "metadata": {}, "outputs": [], "source": [ @@ -41,8 +43,10 @@ }, { "cell_type": "code", - "execution_count": 3, - "metadata": {}, + "execution_count": 4, + "metadata": { + "collapsed": true + }, "outputs": [], "source": [ "# Get a location\n", @@ -69,8 +73,10 @@ }, { "cell_type": "code", - "execution_count": 4, - "metadata": {}, + "execution_count": 5, + "metadata": { + "collapsed": true + }, "outputs": [], "source": [ "simple_fields_file = config['directories']['targets'] + '/simple.yaml'\n", @@ -85,7 +91,7 @@ }, { "cell_type": "code", - "execution_count": 5, + "execution_count": 6, "metadata": {}, "outputs": [ { @@ -94,6 +100,7 @@ "text": [ "Kepler 1100: 120.0 s exposures in blocks of 10, minimum 60, priority 125\n", "KIC 8462852: 120.0 s exposures in blocks of 10, minimum 60, priority 200\n", + "HD 23630: 120.0 s exposures in blocks of 10, minimum 60, priority 100\n", "HD 189733: 100.0 s exposures in blocks of 10, minimum 60, priority 105\n", "HD 209458: 120.0 s exposures in blocks of 10, minimum 60, priority 100\n", "Wasp 140: 120.0 s exposures in blocks of 10, minimum 60, priority 100\n", @@ -110,16 +117,18 @@ "HAT-P-20: 120.0 s exposures in blocks of 10, minimum 60, priority 100\n", "Qatar-1: 120.0 s exposures in blocks of 10, minimum 60, priority 100\n", "Qatar-2: 120.0 s exposures in blocks of 10, minimum 60, priority 100\n", - "Tres 3: 120.0 s exposures in blocks of 10, minimum 60, priority 200\n", + "Tres 3: 120.0 s exposures in blocks of 10, minimum 60, priority 100\n", "EPIC-211089792: 120.0 s exposures in blocks of 10, minimum 60, priority 100\n", "HAT-P-1: 120.0 s exposures in blocks of 10, minimum 60, priority 100\n", "HAT-P-12: 120.0 s exposures in blocks of 10, minimum 60, priority 100\n", + "HAT-P-30: 120.0 s exposures in blocks of 10, minimum 60, priority 100\n", "HAT-P-36: 120.0 s exposures in blocks of 10, minimum 60, priority 100\n", "HAT-P-37: 120.0 s exposures in blocks of 10, minimum 60, priority 100\n", "M42: 120.0 s exposures in blocks of 5, minimum 10, priority 75\n", "M44: 120.0 s exposures in blocks of 10, minimum 60, priority 50\n", "M45: 120.0 s exposures in blocks of 10, minimum 60, priority 50\n", - "M5: 120.0 s exposures in blocks of 10, minimum 60, priority 50\n" + "M5: 120.0 s exposures in blocks of 10, minimum 60, priority 50\n", + "CoRoT-18: 120.0 s exposures in blocks of 10, minimum 60, priority 100\n" ] } ], @@ -130,15 +139,18 @@ }, { "cell_type": "code", - "execution_count": 6, + "execution_count": 7, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ - "Field: Wasp 140 Merit: 202.05040998300152\n", - "Field: M42 Merit: 177.33362524754662\n" + "Field: CoRoT-18 Merit: 202.3220647772819\n", + "Field: Wasp 35 Merit: 202.03480563499681\n", + "Field: Wasp 33 Merit: 201.72962664908442\n", + "Field: Wasp 77 Merit: 201.5670638382877\n", + "Field: M42 Merit: 177.13043661663085\n" ] } ], @@ -153,7 +165,7 @@ }, { "cell_type": "code", - "execution_count": 7, + "execution_count": 8, "metadata": {}, "outputs": [ { @@ -162,7 +174,7 @@ "