Example #1
0
def read_altitude(filename='altitude_prediction.txt'):
    fin = open(filename, 'rb')
    datalines = fin.readlines()
    fin.close()
    altitude = nparray([npdouble(line.strip().split()[1]) for line in datalines])
    times = nparray([DateTime(line.strip().split()[0]).secs for line in datalines])
    return (times, altitude)
Example #2
0
def convert_eclipse_times(eclipse):
    for n in eclipse['eclipse_nums']:
        if n != 'epoch':
            for m in eclipse[n].keys():
                eclipse[n][m].update({'durationsec':
                                      npdouble(eclipse[n][m]['Duration'])})
                eclipse[n][m].update({'startsec':
                                      DateTime(eclipse[n][m]['Start Time']).secs})
                eclipse[n][m].update({'stopsec':
                                      DateTime(eclipse[n][m]['Stop Time']).secs})
                if m == 'entrancepenumbra':
                    if eclipse[n][m].has_key('Entry Timer'):
                        eclipse[n][m].update({'timersec':
                                              npdouble(eclipse[n][m]
                                                       ['Entry Timer'])})
    return eclipse
Example #3
0
def convert_eclipse_times(eclipse):
    for n in eclipse['eclipse_nums']:
        if n != 'epoch':
            for m in eclipse[n].keys():
                eclipse[n][m].update(
                    {'durationsec': npdouble(eclipse[n][m]['Duration'])})
                eclipse[n][m].update(
                    {'startsec': DateTime(eclipse[n][m]['Start Time']).secs})
                eclipse[n][m].update(
                    {'stopsec': DateTime(eclipse[n][m]['Stop Time']).secs})
                if m == 'entrancepenumbra':
                    if 'Entry Timer' in eclipse[n][m].keys():
                        eclipse[n][m].update({
                            'timersec':
                            npdouble(eclipse[n][m]['Entry Timer'])
                        })
    return eclipse
Example #4
0
def read_altitude(filename='altitude_prediction.txt'):
    fin = open(filename, 'r', encoding='utf-8')
    datalines = fin.readlines()
    fin.close()
    altitude = np.array(
        [npdouble(line.strip().split()[1]) for line in datalines])
    times = np.array(
        [DateTime(line.strip().split()[0]).secs for line in datalines])
    return (times, altitude)
Example #5
0
    def parse_line(line):
        words = line.split()
        starttime = words[0][4:] + ':' + words[0][:3] + ':' + words[1]
        stoptime = words[2][4:] + ':' + words[2][:3] + ':' + words[3]

        returndict = {'Start Time': starttime,
                      'Stop Time': stoptime,
                      'Duration': words[4],
                      'Current Condition': words[5],
                      'Obstruction': words[6],
                      'durationsec': npdouble(words[4]),
                      'startsec': DateTime(starttime).secs,
                      'stopsec': DateTime(stoptime).secs}

        if len(words) == 9:
            returndict.update({'Entry Timer': words[7],
                               'timersec': npdouble(words[7]),
                               'Type': words[8]})

        return returndict
Example #6
0
def calculateGetisG(keyList, dataMean, dataStd, dataDictionary, dataLength):
    """
    This function returns the local G statistic a given region.
    """
    sum = 0
    for i in keyList:
        sum = sum + npdouble((dataDictionary[i]))
    neighborNumber = len(keyList)
    numerator = sum - dataMean * neighborNumber
    denominator = dataStd * ((float(dataLength * neighborNumber - (neighborNumber ** 2)) / (dataLength - 1)) ** 0.5)

    #  denominator = (dataStd*((dataLength*neighborNumber-(neighborNumber**2))/(dataLength-1))**0.5)

    G = numerator / denominator
    return G
Example #7
0
    def parse_line(line):
        words = line.split()
        starttime = words[0][4:] + ':' + words[0][:3] + ':' + words[1]
        stoptime = words[2][4:] + ':' + words[2][:3] + ':' + words[3]

        returndict = {
            'Start Time': starttime,
            'Stop Time': stoptime,
            'Duration': words[4],
            'Current Condition': words[5],
            'Obstruction': words[6],
            'durationsec': npdouble(words[4]),
            'startsec': DateTime(starttime).secs,
            'stopsec': DateTime(stoptime).secs
        }

        if len(words) == 9:
            returndict.update({
                'Entry Timer': words[7],
                'timersec': npdouble(words[7]),
                'Type': words[8]
            })

        return returndict
def calculateGetisG(keyList, dataMean, dataStd, dataDictionary, dataLength):
    """
    This function returns the local G statistic a given region.
    """
    sum = 0
    for i in keyList:
        sum = sum + npdouble((dataDictionary[i]))
    neighborNumber = len(keyList)
    numerator = sum - dataMean * neighborNumber
    denominator = dataStd * ((float(dataLength * neighborNumber -
                                    (neighborNumber**2)) /
                              (dataLength - 1))**0.5)

    #  denominator = (dataStd*((dataLength*neighborNumber-(neighborNumber**2))/(dataLength-1))**0.5)

    G = numerator / denominator
    return G
Example #9
0
def read_comms(filename, numheaderlines, year):

    fin = open(filename, 'rb')
    datalines = fin.readlines()
    fin.close()
    [datalines.pop(0) for n in range(numheaderlines)]

    year = str(year)

    fieldnames = ('day', 'start', 'bot', 'eot', 'end', 'facility', 'user',
                  'endocde2', 'endcode1', 'config', 'passno', 'activity',
                  'tstart', 'tbot', 'teot', 'tend')

    commdata = {}

    k = -1
    while len(datalines) > 0:
        if len(datalines[0].strip()) > 20:
            k = k + 1

            words = datalines.pop(0).strip().split()
            try:
                day = words.pop(0)
            except:
                import readline  # optional, will allow Up/Down/History in the console
                import code
                vars = globals().copy()
                vars.update(locals())
                shell = code.InteractiveConsole(vars)
                shell.interact()
            start = words.pop(0)
            bot = words.pop(0)
            eot = words.pop(0)
            end = words.pop(0)
            facility = words.pop(0)
            user = words.pop(0)
            endcode2 = words.pop(-1)
            endcode1 = words.pop(-1)
            config = words.pop(-1)
            passno = words.pop(-1)
            activity = ' '.join(words)

            yearday = year + ':' + day + ':'
            tstart = DateTime(yearday + start[:2] + ':' + start[2:] +
                              ':00.000').secs
            tbot = DateTime(yearday + bot[:2] + ':' + bot[2:] + ':00.000').secs
            teot = DateTime(yearday + eot[:2] + ':' + eot[2:] + ':00.000').secs
            tend = DateTime(yearday + end[:2] + ':' + end[2:] + ':00.000').secs

            if npdouble(bot) < npdouble(start):
                tbot = tbot + 24 * 3600
                teot = teot + 24 * 3600
                tend = tend + 24 * 3600
            elif npdouble(eot) < npdouble(bot):
                teot = teot + 24 * 3600
                tend = tend + 24 * 3600
            elif npdouble(end) < npdouble(eot):
                tend = tend + 24 * 3600

            passinfo = (day, start, bot, eot, end, facility, user, endcode2,
                        endcode1, config, passno, activity, tstart, tbot, teot,
                        tend)

            commdata.update(dict({k: dict(zip(fieldnames, passinfo))}))

        junk = datalines.pop(0)

    return commdata
Example #10
0
def read_comms(filename, numheaderlines, year):

    fin = open(filename, 'r', encoding='utf-8')
    datalines = fin.readlines()
    fin.close()
    [datalines.pop(0) for n in range(numheaderlines)]

    year = str(year)

    fieldnames = ('day', 'start', 'bot', 'eot', 'end', 'facility', 'user',
                  'endocde2', 'endcode1', 'config', 'passno', 'activity',
                  'tstart', 'tbot', 'teot', 'tend')

    commdata = {}

    k = -1
    while len(datalines) > 0:
        if datalines[0][0] != '*':
            if len(datalines[0].strip()) > 20:
                k = k + 1

                words = datalines.pop(0).strip().split()
                try:
                    day = words.pop(0)
                except:
                    import readline  # optional, will allow Up/Down/History in the console
                    import code
                    vars = globals().copy()
                    vars.update(locals())
                    shell = code.InteractiveConsole(vars)
                    shell.interact()
                start = words.pop(0)
                bot = words.pop(0)
                eot = words.pop(0)
                end = words.pop(0)
                facility = words.pop(0)
                user = words.pop(0)
                endcode2 = words.pop(-1)
                endcode1 = words.pop(-1)
                config = words.pop(-1)
                passno = words.pop(-1)
                activity = ' '.join(words)

                yearday = year + ':' + day + ':'
                tstart = DateTime(yearday + start[:2] + ':' + start[2:] +
                                  ':00.000').secs
                tbot = DateTime(yearday + bot[:2] + ':' + bot[2:] +
                                ':00.000').secs
                teot = DateTime(yearday + eot[:2] + ':' + eot[2:] +
                                ':00.000').secs
                tend = DateTime(yearday + end[:2] + ':' + end[2:] +
                                ':00.000').secs

                if npdouble(bot) < npdouble(start):
                    tbot = tbot + 24 * 3600
                    teot = teot + 24 * 3600
                    tend = tend + 24 * 3600
                elif npdouble(eot) < npdouble(bot):
                    teot = teot + 24 * 3600
                    tend = tend + 24 * 3600
                elif npdouble(end) < npdouble(eot):
                    tend = tend + 24 * 3600

                passinfo = (day, start, bot, eot, end, facility, user,
                            endcode2, endcode1, config, passno, activity,
                            tstart, tbot, teot, tend)

                commdata.update(dict({k: dict(zip(fieldnames, passinfo))}))

        junk = datalines.pop(0)

    return commdata