diff --git a/conf_files/fields/simple.yaml b/conf_files/fields/simple.yaml index 0322fd4a4..d0ea92033 100644 --- a/conf_files/fields/simple.yaml +++ b/conf_files/fields/simple.yaml @@ -14,22 +14,14 @@ position: "05h35m17.2992s -05d23m27.996s" observation: exp_set_size: 5 - type: "panoptes.pocs.scheduler.observation.compound.Observation" - exptime: - - 15 - - 45 - - 90 min_nexp: 10 + exptime: 30 priority: 75 - field: name: M45 position: "03h47m24s +24d07m01.20s" observation: exp_set_size: 5 - type: "panoptes.pocs.scheduler.observation.compound.Observation" - exptime: - - 15 - - 45 - - 90 + exptime: 30 min_nexp: 10 priority: 100 diff --git a/src/panoptes/pocs/mount/__init__.py b/src/panoptes/pocs/mount/__init__.py index 41be7d02f..d37284185 100644 --- a/src/panoptes/pocs/mount/__init__.py +++ b/src/panoptes/pocs/mount/__init__.py @@ -78,7 +78,10 @@ def create_mount_from_config(mount_info=None, port = mount_info['serial']['port'] logger.info(f'Looking for {driver} on {port}.') if port is None or len(glob(port)) == 0: - raise error.MountNotFound(msg=f'Mount {port=} not available.') + if port == 'loop://': + logger.warning('Using loop:// for mount connection.') + else: + raise error.MountNotFound(msg=f'Mount {port=} not available.') except KeyError: # See Issue 866 if model == 'bisque': diff --git a/src/panoptes/pocs/mount/ioptron/cem40.py b/src/panoptes/pocs/mount/ioptron/cem40.py index 65756e039..9a8900702 100644 --- a/src/panoptes/pocs/mount/ioptron/cem40.py +++ b/src/panoptes/pocs/mount/ioptron/cem40.py @@ -1,18 +1,10 @@ -import re import time -from astropy import units as u -from astropy.time import Time - -from panoptes.pocs.mount.ioptron.base import Mount as BaseMount from panoptes.pocs.mount.ioptron import MountState +from panoptes.pocs.mount.ioptron.base import Mount as BaseMount class Mount(BaseMount): - """ - Mount class for iOptron mounts. Overrides the base `initialize` method - and providers some helper methods to convert coordinates. - """ def __init__(self, location, mount_version='0040', *args, **kwargs): self._mount_version = mount_version @@ -30,3 +22,20 @@ def search_for_home(self): while self.status.get('state') != MountState.AT_HOME: self.logger.trace(f'Searching for home position.') time.sleep(1) + + def set_target_coordinates(self, *args, **kwargs): + """After setting target coordinates, check number of positions. + The CEM40 can determine if there are 0, 1, or 2 possible positions + for the given RA/Dec, with the latter being the case for the meridian + flip. + """ + target_set = super().set_target_coordinates(*args, **kwargs) + self.logger.debug(f'Checking number of possible positions for {self._target_coordinates}') + num_possible_positions = self.query('query_positions') + self.logger.debug(f'Number of possible positions: {num_possible_positions}') + + if num_possible_positions == 0: + self.logger.warning(f'No possible positions for {self._target_coordinates}') + target_set = False + + return target_set diff --git a/src/panoptes/pocs/mount/ioptron/ieq30pro.py b/src/panoptes/pocs/mount/ioptron/ieq30pro.py index dc9be7c87..b8a26e9a0 100644 --- a/src/panoptes/pocs/mount/ioptron/ieq30pro.py +++ b/src/panoptes/pocs/mount/ioptron/ieq30pro.py @@ -1,15 +1,7 @@ -import re - -from astropy.time import Time - from panoptes.pocs.mount.ioptron.base import Mount as BaseMount class Mount(BaseMount): - """ - Mount class for iOptron mounts. Overrides the base `initialize` method - and providers some helper methods to convert coordinates. - """ def __init__(self, location, mount_version='0030', *args, **kwargs): self._mount_version = mount_version diff --git a/src/panoptes/pocs/scheduler/dispatch.py b/src/panoptes/pocs/scheduler/dispatch.py index 74dc55e78..a9a19a867 100644 --- a/src/panoptes/pocs/scheduler/dispatch.py +++ b/src/panoptes/pocs/scheduler/dispatch.py @@ -78,17 +78,17 @@ def get_observation(self, time=None, show_all=False, constraints=None, read_file self.logger.info(f'Best observation: {top_obs_name}\tScore: {top_obs_score:.02f}') # Check new best against current_observation - if self.current_observation is not None \ - and top_obs_name != self.current_observation.name: + if self.current_observation is not None and top_obs_name != self.current_observation.name: + self.logger.debug(f'Checking if {self.current_observation} is still valid') # Favor the current observation if still available end_of_next_set = time + self.current_observation.set_duration if self.observation_available(self.current_observation, end_of_next_set): - # If current is better or equal to top, use it + self.logger.debug(f'{self.current_observation.merit=}') + self.logger.debug(f'{top_obs_score=}') if self.current_observation.merit >= top_obs_score: - best_obs.insert(0, (self.current_observation, - self.current_observation.merit)) + best_obs.insert(0, (self.current_observation, self.current_observation.merit)) # Set the current self.current_observation = self.observations[top_obs_name] diff --git a/src/panoptes/pocs/scheduler/scheduler.py b/src/panoptes/pocs/scheduler/scheduler.py index fcfa47174..8f6732dec 100644 --- a/src/panoptes/pocs/scheduler/scheduler.py +++ b/src/panoptes/pocs/scheduler/scheduler.py @@ -7,7 +7,6 @@ from astropy import units as u from astropy.coordinates import get_body from panoptes.utils import error -from panoptes.utils.library import load_module from panoptes.utils.serializers import from_yaml from panoptes.utils.time import current_time @@ -121,7 +120,7 @@ def current_observation(self, new_observation): # Add the new observation to the list self.observed_list[new_observation.seq_time] = new_observation - self.logger.info("Setting new observation to {}".format(new_observation)) + self.logger.info(f'Setting new observation to {new_observation}') self._current_observation = new_observation @property diff --git a/tests/scheduler/test_dispatch_scheduler.py b/tests/scheduler/test_dispatch_scheduler.py index fddcd9f02..01bdd6c40 100644 --- a/tests/scheduler/test_dispatch_scheduler.py +++ b/tests/scheduler/test_dispatch_scheduler.py @@ -1,6 +1,7 @@ import os import yaml import pytest +import time from astropy import units as u from astropy.coordinates import EarthLocation @@ -19,14 +20,14 @@ def constraints(): return [MoonAvoidance(), Duration(30 * u.deg)] -@pytest.fixture +@pytest.fixture(scope='function') def observer(): loc = get_config('location') location = EarthLocation(lon=loc['longitude'], lat=loc['latitude'], height=loc['elevation']) return Observer(location=location, name="Test Observer", timezone=loc['timezone']) -@pytest.fixture() +@pytest.fixture(scope='function') def field_file(): scheduler_config = get_config('scheduler', default={}) @@ -37,7 +38,7 @@ def field_file(): return fields_path -@pytest.fixture() +@pytest.fixture(scope='function') def field_list(): return yaml.full_load(""" - @@ -97,8 +98,12 @@ def field_list(): """) -@pytest.fixture +@pytest.fixture(scope='function') def scheduler(field_list, observer, constraints): + try: + del os.environ['POCSTIME'] + except Exception: + pass return Scheduler(observer, fields_list=field_list, constraints=constraints) @@ -179,11 +184,6 @@ def test_continue_observation(scheduler): def test_set_observation_then_reset(scheduler): - try: - del os.environ['POCSTIME'] - except Exception: - pass - time = Time('2016-08-13 05:00:00') scheduler.get_observation(time=time) @@ -246,23 +246,21 @@ def test_new_observation_seq_time(scheduler): def test_observed_list(scheduler): assert len(scheduler.observed_list) == 0 - time = Time('2016-09-11 07:08:00') - scheduler.get_observation(time=time) - + time0 = Time('2016-09-11 07:08:00') + scheduler.get_observation(time=time0) assert len(scheduler.observed_list) == 1 # A few hours later should now be different - time = Time('2016-09-11 10:30:00') - scheduler.get_observation(time=time) - + time.sleep(1) + time1 = Time('2016-09-11 10:08:00') + scheduler.get_observation(time=time1) assert len(scheduler.observed_list) == 2 # A few hours later should be the same - time = Time('2016-09-11 14:30:00') - scheduler.get_observation(time=time) - + time.sleep(1) + time2 = Time('2016-09-11 14:38:00') + scheduler.get_observation(time=time2) assert len(scheduler.observed_list) == 2 scheduler.reset_observed_list() - assert len(scheduler.observed_list) == 0