<commit_before>#!/usr/bin/env python
# encoding: utf-8
"""
scheduler.py

Created by <NAME> on 17 Feb 2014.
Licensed under a 3-clause BSD license.

Revision history:
    17 Feb 2014 <NAME>
      Initial version

"""

from __future__ import division
from __future__ import print_function
from astropysics import obstools
from sdss.internal.manga.Totoro.exceptions import TotoroError
from timeline import Timelines
from sdss.internal.manga.Totoro import log, site
from sdss.internal.manga.Totoro.scheduler import observingPlan
from astropy import time


class BaseScheduler(object):
    """The base class for the autoscheduler.

    This class provides the common base to plan observations
    and is inherited by Scheduler, Plugger and Planner.

    """

    def __init__(self, startDate=None, endDate=None, **kwargs):

        if observingPlan is None:
            raise TotoroError('observing plan not found. Not possible to '
                              'create an instance of BaseScheduler.')

        self._observingPlan = observingPlan
        self.site = site
        self._setStartEndDate(startDate, endDate, **kwargs)

        self.observingBlocks = self._observingPlan.getObservingBlocks(
            self.startDate, self.endDate)

    def _setStartEndDate(self, startDate, endDate, scope='planner', **kwargs):
        """Sets the start and end date if they haven't been defined."""

        if scope == 'planner':
            if startDate is not None and endDate is not None:
                pass
            else:
                startDate, endDate = self._observingPlan.getRun(startDate)

        elif scope == 'nightly':
            if startDate is None or endDate is None:
                startDate, endDate = self._observingPlan.getJD(startDate)

        elif scope == 'plugger':
            startDate, endDate = self._observingPlan.getJD(
                int(time.Time.now().jd) + 1)<commit_msg>Totoro: planner now requires both start and end dates.<commit_after>#!/usr/bin/env python
# encoding: utf-8
"""
scheduler.py

Created by <NAME> on 17 Feb 2014.
Licensed under a 3-clause BSD license.

Revision history:
    17 Feb 2014 <NAME>
      Initial version

"""

from __future__ import division
from __future__ import print_function
from astropysics import obstools
from sdss.internal.manga.Totoro.exceptions import TotoroError
from timeline import Timelines
from sdss.internal.manga.Totoro import log, site
from sdss.internal.manga.Totoro.scheduler import observingPlan
from astropy import time


class BaseScheduler(object):
    """The base class for the autoscheduler.

    This class provides the common base to plan observations
    and is inherited by Scheduler, Plugger and Planner.

    """

    def __init__(self, startDate=None, endDate=None, **kwargs):

        if observingPlan is None:
            raise TotoroError('observing plan not found. Not possible to '
                              'create an instance of BaseScheduler.')

        self._observingPlan = observingPlan
        self.site = site
        self._setStartEndDate(startDate, endDate, **kwargs)

        self.observingBlocks = self._observingPlan.getObservingBlocks(
            self.startDate, self.endDate)

    def _setStartEndDate(self, startDate, endDate, scope='planner', **kwargs):
        """Sets the start and end date if they haven't been defined."""

        if scope == 'planner':
            if startDate is None or endDate is None:
                raise TotoroError('planner requires both start and end dates.')

        elif scope == 'nightly':
            if startDate is None or endDate is None:
                startDate, endDate = self._observingPlan.getJD(startDate)

        elif scope == 'plugger':
            startDate, endDate = self._observingPlan.getJD(
                int(time.Time.now().jd) + 1)
{'fraction_non_alphanumeric': 0.08006279434850863, 'fraction_numerical': 0.007849293563579277, 'mean_word_length': 2.766502463054187, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2321923', 'n_tokens_mistral': 1114, 'n_tokens_neox': 1030, 'n_words': 356}