Exemplo n.º 1
0
def quartile(res, Id, indicator, distribution):
    """ in which quartile is units value """
    #logging.debug((len(res), Id, indicator, len(distribution)))
    d = res[(res.LocId.isin(distribution)) & (res.IndicatorCode==indicator) & (res.NumOfMonths==36)].ResultsValue
    r = d.quantile([0.0,0.25,0.5,0.75,0.9,1.0]).tolist() if indicator != 'UCF  ' \
        else d.quantile([1.0, 0.75, 0.5, 0.25, 0.1, 0.0]).tolist()
    uRes = res[(res.LocId==Id) & (res.IndicatorCode==indicator) & (res.NumOfMonths==36)].ResultsValue.values[0]
    uRes18 = res[(res.LocId == Id) & (res.IndicatorCode == indicator) & (res.NumOfMonths == 18)].ResultsValue.values[0]
    ln = ['X' if uRes >= r[i] and uRes <= r[i+1] else '' for i in range(5)]
    r = ['%.2f'%(i) for i in r[1:4]]
    dict = {'Indicator': indicator.strip(), 'Top Quartile': r[0],  'Median': r[1], 'Bottom Quartile': r[2],
            'Unit': f.name(Id), 'PI-36 Result': uRes.round(3), 'Performance Tendency': tend(uRes18, uRes),
            'Units reporting': len(d), 'Top Quart.': ln[0], '2nd Quart.': ln[1],
            '3rd Quart.': ln[2], 'Bott. Quart.': ln[3], 'Bott. 10 perc.': ln[4]}
    return pd.DataFrame(dict, index=[0])
Exemplo n.º 2
0
async def dump_all_messages(channel):
    df = pd.DataFrame({'group': [], 'name': [], 'username':[],'id':[],'message':[],'date':[]})
    title = channel.title

    messages = await client.get_messages(channel, limit = 3000)
    for m in messages:
        user = m.sender
        if m.message == None:
            t = action_to_text(m.action)
        if m.action == None:
            t = m.message
        if type(user) == telethon.tl.types.User:
            df.loc[df.shape[0]] = [title, name(user.first_name, user.last_name), user.username, str(user.id), t, m.date]
        if type(user) == telethon.tl.types.Channel:
            df.loc[df.shape[0]] = [title, user.title, None, user.id, t, m.date]

    df.to_csv('chat_messages.csv', index=False)
Exemplo n.º 3
0
async def dump_all_participants(channel):
    df = pd.DataFrame({'group': [], 'name': [], 'username':[],'id':[]})
    title = channel.title
    participants_ids = []   

    i = 0
    while True:
        # делаем поиск по 1 букве имени для всех букв, 
        # чтобы избежать ограничения на 10000
        filter_user = ChannelParticipantsSearch(letters[i])
        if i==0:
            participants = await client.get_participants(channel)
        else:
            participants = await client.get_participants(channel, filter = filter_user)
        for user in participants:
            if user.id not in participants_ids:
                participants_ids +=[user.id]
                df.loc[df.shape[0]] = [title, name(user.first_name, user.last_name), user.username, str(user.id)]
        #print(title, letters[i], len(participants_ids))
        if i>len(letters)-2 or (len(participants) < 8500 and i==0):
            break
        i+=1
        
    df.to_csv('chat_users.csv', index=False)
Exemplo n.º 4
0
import requests
import csv
import functions

name = input("If not entering an Applaince ID leave a blank, Appliance ID: ")

if name != "":
    functions.name()

command = input("Command? ")

if command.lower() == "open":
    functions.open1()

elif command.lower() == "change temperature":
    functions.change_temp()

else:
    print("oops")
Exemplo n.º 5
0
#Servo pins in use
panServo = 7
tiltServo = 18

name = sys.argv[1] 
pans = int(sys.argv[2]) 
tilts = int(sys.argv[3]) 

#Servo configs
minPan = 2.5
maxPan = 12.5
minTilt = 5
maxTilt = 12.5

panStep = round((maxPan-minPan)/pans,1)
tiltStep = round((maxTilt-minTilt)/pans, 1)

for p in functions.step_range(minPan, maxPan, panStep):
    servo.move(panServo,p)
    for t in functions.step_range(minTilt, maxTilt, tiltStep):
        servo.move(tiltServo,t)
        console.run(["./photo.sh", functions.name(name,p,t)])


    




Exemplo n.º 6
0
import sys
import functions
import servo
import console

#Servo pins in use
panServo = 7
tiltServo = 18

name = sys.argv[1]
pans = int(sys.argv[2])
tilts = int(sys.argv[3])

#Servo configs
minPan = 2.5
maxPan = 12.5
minTilt = 5
maxTilt = 12.5

panStep = round((maxPan - minPan) / pans, 1)
tiltStep = round((maxTilt - minTilt) / pans, 1)

for p in functions.step_range(minPan, maxPan, panStep):
    servo.move(panServo, p)
    for t in functions.step_range(minTilt, maxTilt, tiltStep):
        servo.move(tiltServo, t)
        console.run(["./photo.sh", functions.name(name, p, t)])