Untitled

mail@pastecode.io avatar
unknown
plain_text
a year ago
1.9 kB
1
Indexable
Never
import pandas as pd
# import matplotlib.pyplot as plt
import io
import sharepy
import base64

# --------- GET FILE FROM SHAREPOINT ---------------------

# Set Log in for Sharepoint
sharepoint_user = 'ee20kg@leeds.ac.uk'  # email adress
encoded_password = 'TTNpbmVTY2gwMGwmIQ=='  # password, but encoded for privacy

# Set Files name for Sharepoint
url = 'https://leeds365.sharepoint.com'  # base sharepoint url
file_url = '/sites/TEAM-SEEAQProjects-UKRI-GLASGOW/Shared%20Documents/UKRI%20-%20GLASGOW/Jims_office_data/'
days = ['20221104', '20221105', '20221106', '20221107']
sensors = ['SL061', 'SL062', 'SL064', 'SL068']
datas = []

s = sharepy.connect(url, username=sharepoint_user, password=base64.b64decode(encoded_password).decode('ascii'))  # connect to url with login details

# Access each of the files and turn to csvs
for sensor in sensors:
    for day in days:
        r = s.get(url+file_url+sensor+"/"+day+".csv")
        f = io.BytesIO(r.content)
        x = (pd.read_csv(f))
        datas.append(x)


# --------- PLOT DATA ---------------------
"""
for data in datas:
    data.plot("UTCDateTime", "pm2_5_atm", xlabel="Time", ylabel="PM 2.5", color="pink", title="PM 2.5 over time")
"""
# --------- NEW STUFF ---------------------

sensor61data = datas[0:3]
sensor62data = datas[4:7]
sensor64data = datas[8:11]
sensor68data = datas[12:15]

S61 = pd.concat(sensor61data)
S62 = pd.concat(sensor62data)
S64 = pd.concat(sensor64data)
S68 = pd.concat(sensor68data)

ax = S61.plot(x='UTCDateTime', y='pm2_5_atm', ylabel="pm2_5_atm", color='DarkBlue', label='Sensor 61')
S62.plot(x='UTCDateTime', y='pm2_5_atm', color='DarkGreen', label='Sensor 62', ax=ax)
S64.plot(x='UTCDateTime', y='pm2_5_atm', color='Grey', label='Sensor 64', ax=ax)
S68.plot(x='UTCDateTime', y='pm2_5_atm', color='Orange', label='Sensor 68', ax=ax)