Ejemplo n.º 1
0
def obsOneNight(fldPar, donePar, date):
    """Fully Schedules one night."""
    # Get the ephemeris for the night
    mmt = MMTEphem.ephem(date)
    startTime = mmt.eveningTwilight

    # Now, start at twilight and add observervations. Each
    # time increment currentTime by the observation time
    # If no observations are found, add 5 minutes and check again
    currentTime = startTime
    schedule = []  # Will contain scheduled fields
    allDone = False
    prevPos = None
    while (currentTime < mmt.morningTwilight) & (allDone is False):
        newSched, prevPos = obsUpdateRow(fldPar, donePar,
                                        currentTime, mmt, prevPos)
        # Check to see if something was observed
        if newSched is None:
            # Increment time and continue
            currentTime += datetime.timedelta(minutes=20)
        else:
            # Append new entry to schedule, increment currentTime
            # by exposure time.
            schedule.append(newSched)
            currentTime += datetime.timedelta(seconds=newSched[1])
            completed = donePar['complete'].values
            if min(completed) == 1:
                allDone = True

    return schedule
Ejemplo n.º 2
0
def obsOneNight(fldPar, donePar, date):
    """Fully Schedules one night."""
    # Get the ephemeris for the night
    mmt = MMTEphem.ephem(date)
    startTime = mmt.eveningTwilight

    # Now, start at twilight and add observervations. Each
    # time increment currentTime by the observation time
    # If no observations are found, add 5 minutes and check again
    currentTime = startTime
    schedule = []  # Will contain scheduled fields
    allDone = False
    prevPos = None
    while (currentTime < mmt.morningTwilight) & (allDone is False):
        newSched, prevPos = obsUpdateRow(fldPar, donePar, currentTime, mmt,
                                         prevPos)
        # Check to see if something was observed
        if newSched is None:
            # Increment time and continue
            currentTime += datetime.timedelta(minutes=20)
        else:
            # Append new entry to schedule, increment currentTime
            # by exposure time.
            schedule.append(newSched)
            currentTime += datetime.timedelta(seconds=newSched[1])
            completed = donePar['complete'].values
            if min(completed) == 1:
                allDone = True

    return schedule
Ejemplo n.º 3
0
def readAllocatedTime(startDay="1900/1/1", endDay="3000/1/1"):
    """Read a log file to determine how much each PI was allocated."""
    filename = "AllocatedTime.dat"
    f = open(filename, 'r')

    if type(startDay) == str:
        startDay = pyEphem.date(startDay).datetime()
    if type(endDay) == str:
        endDay = pyEphem.date(endDay).datetime()

    allocatedTime = {}
    for line in f.readlines():
        if line[0] == '#':
            # Comment string, skip
            continue

        date, PI = line.strip().split()
        date = pyEphem.date(date).datetime()
        mmt = MMTEphem.ephem(date)
        if (abs((date-startDay).total_seconds()) < 24*3600.) | \
           (abs((date-endDay).total_seconds()) < 24*3600.):
            # This night is not in the current run
            continue

        nightLength = (mmt.morningTwilight - mmt.eveningTwilight)
        nightLength = nightLength.total_seconds() / 3600.0

        if PI in allocatedTime:
            allocatedTime[PI] += nightLength
        else:
            allocatedTime[PI] = nightLength

    return allocatedTime
Ejemplo n.º 4
0
def readAllocatedTime(startDay="1900/1/1", endDay="3000/1/1"):
    """Read a log file to determine how much each PI was allocated."""
    filename = "AllocatedTime.dat"
    f = open(filename, 'r')

    if type(startDay) == str:
        startDay = pyEphem.date(startDay).datetime()
    if type(endDay) == str:
        endDay = pyEphem.date(endDay).datetime()

    allocatedTime = {}
    for line in f.readlines():
        if line[0] == '#':
            # Comment string, skip
            continue

        date, PI = line.strip().split()
        date = pyEphem.date(date).datetime()
        mmt = MMTEphem.ephem(date)
        if (abs((date-startDay).total_seconds()) < 24*3600.) | \
           (abs((date-endDay).total_seconds()) < 24*3600.):
            # This night is not in the current run
            continue

        nightLength = (mmt.morningTwilight - mmt.eveningTwilight)
        nightLength = nightLength.total_seconds() / 3600.0

        if PI in allocatedTime:
            allocatedTime[PI] += nightLength
        else:
            allocatedTime[PI] = nightLength

    return allocatedTime