def ModeX(Occupied_Timeline):

    "Plan to schedule the Mode at the start of the timeline"
    initial_StartDate = ephem.Date(
        OPT_Config_File.Timeline_settings()['start_date'])

    "Set a duration of the Mode in seconds, which in turns sets the endDate"
    duration = 600
    #duration = OPT_Config_File.ModeX_settings()['duration']
    endDate = ephem.Date(initial_StartDate + ephem.second * duration)

    "Check if the planned initial_StartDate is available and postpone until available"
    startDate, endDate, iterations = scheduler(Occupied_Timeline,
                                               initial_StartDate, endDate)

    comment = 'Number of times date postponed: ' + str(iterations)

    "Get the name of the function, which shall also be the name of the mode"
    Mode_name = sys._getframe(0).f_code.co_name

    "Add the scheduled startDate and endDate as a duple to the Occupied_Timeline dictionary using your Mode name as the key"
    Occupied_Timeline[Mode_name].append((startDate, endDate))

    "Return the updated Occupied_Timeline variable and a comment"
    return Occupied_Timeline, comment
Example #2
0
def date_select(Occupied_Timeline, initial_date):

    date = initial_date

    try:
        Logger.info('Mode specific mode_duration used as initial date')
        endDate = ephem.Date(
            initial_date + ephem.second *
            OPT_Config_File.Timeline_settings()['mode_separation'] +
            ephem.second * Mode201_settings()['mode_duration'])
    except:
        Logger.info('Timeline mode_duration used as initial date')
        endDate = ephem.Date(
            initial_date + ephem.second *
            OPT_Config_File.Timeline_settings()['mode_separation'] +
            ephem.second *
            OPT_Config_File.Timeline_settings()['mode_duration'])

    ############### Start of availability schedueler ##########################

    date, endDate, iterations = scheduler(Occupied_Timeline, date, endDate)

    ############### End of availability schedueler ##########################

    comment = 'Number of times date postponed: ' + str(iterations)

    "Get the name of the parent function, which is always defined as the name of the mode"
    Mode_name = sys._getframe(1).f_code.co_name

    Occupied_Timeline[Mode_name].append((date, endDate))

    return Occupied_Timeline, comment
Example #3
0
def Mode100(Occupied_Timeline):
    """Core function for the scheduling of Mode100.
    
    Arguments:
        Occupied_Timeline (:obj:`dict` of :obj:`list`): Dictionary with keys equal to planned and scheduled Modes/CMDs with entries equal to their start and end time as a list.
        
    Returns:
        (tuple): tuple containing:
            (:obj:`dict` of :obj:`list`): Occupied_Timeline (updated with the result from the scheduled Mode). \n
            (str): Comment regarding the result of scheduling of the mode.
    
    """

    Timeline_settings = OPT_Config_File.Timeline_settings()
    Settings = OPT_Config_File.Mode100_settings()

    "Get the initially planned date"
    if Settings["start_date"] != "0":
        initialDate = ephem.Date(Settings["start_date"])
        Logger.info("Mode specific start_date used as initial date")
    else:
        Logger.info("Timeline start_date used as initial date")
        initialDate = ephem.Date(Timeline_settings["start_date"])

    # number_of_CMDs = 6
    number_of_altitudes = int((Settings["pointing_altitude_to"] -
                               Settings["pointing_altitude_from"]) /
                              Settings["pointing_altitude_interval"] + 1)

    "Set higher than in reality to make sure there is enough time"
    NumberOfCMDsPerAltitude = 12
    duration = (Settings["pointing_duration"] +
                Timeline_settings["pointing_stabilization"] +
                Timeline_settings["CCDSYNC_Waittime"] +
                Timeline_settings["CMD_separation"] *
                NumberOfCMDsPerAltitude) * number_of_altitudes

    endDate = ephem.Date(
        initialDate + ephem.second *
        (duration + Timeline_settings["mode_separation"])
    )  # no mode seperation to ensure consistency at each altitude

    ############### Start of availability schedueler ##########################

    startDate, endDate, iterations = scheduler(Occupied_Timeline, initialDate,
                                               endDate)

    ############### End of availability schedueler ##########################

    comment = "Number of times date postponed: " + str(iterations)

    "Get the name of the parent function, which is always defined as the name of the mode"
    Mode_name = sys._getframe(0).f_code.co_name

    Occupied_Timeline[Mode_name].append((startDate, endDate))

    return Occupied_Timeline, comment
Example #4
0
def UserProvidedDateScheduler(Occupied_Timeline, Settings):
    """Schedules a single user provided date.
    
    Used by Mode120-124.
    
    Arguments:
        Occupied_Timeline (:obj:`dict` of :obj:`list`): Dictionary with keys equal to planned and scheduled Modes/CMDs with entries equal to their start and end time as a list.
        Settings (dict): Dictionary containing settings for this simulation.
        
    Returns:
        (tuple): tuple containing:
            (:obj:`dict` of :obj:`list`): Occupied_Timeline (updated with the result from the scheduled Mode). \n
            (str): Comment regarding the result of the scheduling of the mode.
    
    
    """

    "Get the name of the parent function, which is always defined as the name of the mode"
    Mode_name = sys._getframe(1).f_code.co_name

    Timeline_settings = OPT_Config_File.Timeline_settings()

    if (Settings['start_date'] == '0'):
        StartDate = ephem.Date(Timeline_settings['start_date'])
    else:
        try:
            StartDate = ephem.Date(Settings['start_date'])
        except:
            Logger.error('Could not get Settings["start_date"], exiting...')
            sys.exit()

    endDate = ephem.Date(
        StartDate + ephem.second *
        (Settings['freeze_start'] + Settings['freeze_duration'] +
         Timeline_settings['mode_separation']))

    ############### Start of availability schedueler ##########################

    StartDate, endDate, iterations = scheduler(Occupied_Timeline, StartDate,
                                               endDate)

    ############### End of availability schedueler ##########################

    comment = str(
        Mode_name
    ) + ' scheduled using a user given date, the date got postponed ' + str(
        iterations) + ' times'

    Occupied_Timeline[Mode_name].append((StartDate, endDate))

    return Occupied_Timeline, comment
Example #5
0
def Mode130(Occupied_Timeline):
    """Core function for the scheduling of Mode130.
    
    Arguments:
        Occupied_Timeline (:obj:`dict` of :obj:`list`): Dictionary with keys equal to planned and scheduled Modes/CMDs with entries equal to their start and end time as a list.
        
    Returns:
        (tuple): tuple containing:
            (:obj:`dict` of :obj:`list`): Occupied_Timeline (updated with the result from the scheduled Mode). \n
            (str): Comment regarding the result of scheduling of the mode.
    """

    Timeline_settings = OPT_Config_File.Timeline_settings()
    Settings = OPT_Config_File.Mode130_settings()

    "Get the initially planned date"
    if (Settings['start_date'] != '0'):
        initialDate = ephem.Date(Settings['start_date'])
        Logger.info('Mode specific start_date used as initial date')
    else:
        Logger.info('Timeline start_date used as initial date')
        initialDate = ephem.Date(Timeline_settings['start_date'])

    NumberOfCCDs = 7
    endDate = ephem.Date(initialDate + ephem.second *
                         (Settings['SnapshotSpacing'] * NumberOfCCDs +
                          Timeline_settings['pointing_stabilization'] +
                          Timeline_settings['mode_separation']))

    ############### Start of availability schedueler ##########################

    startDate, endDate, iterations = scheduler(Occupied_Timeline, initialDate,
                                               endDate)

    ############### End of availability schedueler ##########################

    comment = 'Number of times date postponed: ' + str(iterations)

    "Get the name of the parent function, which is always defined as the name of the mode"
    Mode_name = sys._getframe(0).f_code.co_name

    Occupied_Timeline[Mode_name].append((startDate, endDate))

    return Occupied_Timeline, comment
def Mode134(Occupied_Timeline):
    """Core function for the scheduling of Mode134.
    
    Arguments:
        Occupied_Timeline (:obj:`dict` of :obj:`list`): Dictionary with keys equal to planned and scheduled Modes/CMDs with entries equal to their start and end time as a list.
        
    Returns:
        (tuple): tuple containing:
            (:obj:`dict` of :obj:`list`): Occupied_Timeline (updated with the result from the scheduled Mode). \n
            (str): Comment regarding the result of scheduling of the mode.
    
    """

    "Get the initially planned date"
    if OPT_Config_File.Mode134_settings()["start_date"] != "0":
        initialDate = ephem.Date(OPT_Config_File.Mode160_settings()["start_date"])
        Logger.info("Mode specific start_date used as initial date")
    else:
        Logger.info("Timeline start_date used as initial date")
        initialDate = ephem.Date(OPT_Config_File.Timeline_settings()["start_date"])

    endDate = ephem.Date(
        initialDate
        + ephem.second
        * (
            OPT_Config_File.Mode134_settings()["mode_duration"]
            + OPT_Config_File.Timeline_settings()["mode_separation"]
        )
    )

    ############### Start of availability schedueler ##########################

    startDate, endDate, iterations = scheduler(Occupied_Timeline, initialDate, endDate)

    ############### End of availability schedueler ##########################

    comment = "Number of times date postponed: " + str(iterations)

    "Get the name of the parent function, which is always defined as the name of the mode"
    Mode_name = sys._getframe(0).f_code.co_name

    Occupied_Timeline[Mode_name].append((startDate, endDate))

    return Occupied_Timeline, comment
Example #7
0
def CMD_scheduler(Occupied_Timeline):
    """Subfuncton, Schedules a CMD/Procedure and saves it to the *Occupied_Timeline* variable
    
    Arguments:
        Occupied_Timeline (:obj:`dict` of :obj:`list`): Dictionary with keys equal to planned and scheduled Modes/CMDs with entries equal to their start and end time as a list.
        
    Returns:
        (tuple): tuple containing:
            (:obj:`dict` of :obj:`list`): Occupied_Timeline (updated with the result from the scheduled CMD). \n
            (str): Comment regarding the result of scheduling of the CMD.
    
    
    """

    Logger.info('Timeline start_time used as initial date')
    initial_date = ephem.Date(
        OPT_Config_File.Timeline_settings()['start_date'])
    duration = OPT_Config_File.Timeline_settings()['CMD_duration']
    endDate = ephem.Date(
        initial_date + ephem.second *
        (OPT_Config_File.Timeline_settings()['mode_separation'] + duration))

    ############### Start of availability schedueler ##########################

    date, endDate, iterations = scheduler(Occupied_Timeline, initial_date,
                                          endDate)

    ############### End of availability schedueler ##########################

    comment = 'Number of times date postponed: ' + str(iterations)

    "Get the name of the function, which is defined as the name of the CMD"
    CMD_name = sys._getframe(1).f_code.co_name

    Occupied_Timeline[CMD_name].append((date, endDate))

    return Occupied_Timeline, comment
def Mode132(Occupied_Timeline):
    """Core function for the scheduling of Mode132.
    
    Arguments:
        Occupied_Timeline (:obj:`dict` of :obj:`list`): Dictionary with keys equal to planned and scheduled Modes/CMDs with entries equal to their start and end time as a list.
        
    Returns:
        (tuple): tuple containing:
            (:obj:`dict` of :obj:`list`): Occupied_Timeline (updated with the result from the scheduled Mode). \n
            (str): Comment regarding the result of scheduling of the mode.
    
    """

    Timeline_settings = OPT_Config_File.Timeline_settings()
    Settings = OPT_Config_File.Mode132_settings()

    "Get the initially planned date"
    if Settings["start_date"] != "0":
        initialDate = ephem.Date(Settings["start_date"])
        Logger.info("Mode specific start_date used as initial date")
    else:
        Logger.info("Timeline start_date used as initial date")
        initialDate = ephem.Date(Timeline_settings["start_date"])

    NumberOfCMDsPerAltitude = 12

    if len(Settings["Exp_Times_UV"]) <= len(Settings["Exp_Times_IR"]):
        duration = (
            Settings["session_duration"] +
            Timeline_settings["CMD_separation"] * NumberOfCMDsPerAltitude +
            Timeline_settings["pointing_stabilization"]) * len(
                Settings["Exp_Times_UV"])
    elif len(Settings["Exp_Times_IR"]) < len(Settings["Exp_Times_UV"]):
        duration = (
            Settings["session_duration"] +
            Timeline_settings["CMD_separation"] * NumberOfCMDsPerAltitude +
            Timeline_settings["pointing_stabilization"]) * len(
                Settings["Exp_Times_IR"])
    """
    NumberOfCMDStepsInMacro = 12
    
    if( len(Settings['Exp_Times_UV']) <= len(Settings['Exp_Times_IR'])):
        duration = ( Settings['session_duration']+ NumberOfCMDStepsInMacro * Timeline_settings['CMD_separation'] ) * len(Settings['Exp_Times_UV'])+Timeline_settings['pointing_stabilization'] + Timeline_settings['mode_separation']
    elif( len(Settings['Exp_Times_IR']) < len(Settings['Exp_Times_UV']) ):
        duration = ( Settings['session_duration']+ NumberOfCMDStepsInMacro * Timeline_settings['CMD_separation'] ) * len(Settings['Exp_Times_IR'])+Timeline_settings['pointing_stabilization'] + Timeline_settings['mode_separation']
    """
    endDate = ephem.Date(initialDate + ephem.second *
                         (duration + Timeline_settings["mode_separation"]))

    ############### Start of availability schedueler ##########################

    startDate, endDate, iterations = scheduler(Occupied_Timeline, initialDate,
                                               endDate)

    ############### End of availability schedueler ##########################

    comment = "Number of times date postponed: " + str(iterations)

    "Get the name of the parent function, which is always defined as the name of the mode"
    Mode_name = sys._getframe(0).f_code.co_name

    Occupied_Timeline[Mode_name].append((startDate, endDate))

    return Occupied_Timeline, comment