Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
aire región Concón-Quintero-Puchuncaví
import openaq
import pandas as pd
api = openaq.OpenAQ() # fuente:
cdf = api.cities(country='CL', df=True)
cdf = cdf[['Quintero','Concón','Puchuncaví'])]
xdf = pd.concat([api.measurements(city=city, df=True, limit=1000)
for city in])'fecha'
xdf = xdf.rename(columns={'coordinates.latitude': 'lat',
'coordinates.longitude': 'lon'})
import seaborn as sns
import matplotlib.pyplot as plt
fig, ax = plt.subplots(1, figsize=(30,10))
con['location'] = con.location+':'
con = con[con['fecha']>'2022-06-03']
md = con['fecha'].median();
tag='%s:%.1f ' %(maxima['location'].values[0],maxima['value'].values)
sns.lineplot(data=con, x='fecha', y='value', hue='location');
plt.axhline(y=150, color='r', linestyle='-', linewidth=5); #24h
plt.axhline(y=350, color='orange', linestyle='-', linewidth=5); # 1h
plt.text(md, 150+10, 'norma 24h (Chile)', color='blue', size=18, weight='bold');
plt.text(md, 350+10, 'norma 1h (Chile)', color='purple', size=18, weight='bold');
plt.text(maxima['fecha'], maxima['value'], f"{tag}", size=18, color='r', weight='bold')
plt.title('Evolución reciente SO2 Concon-Quintero-Puchuncaví [µg/m3] (Fuente: OpenAQ +', size=24);
plt.legend(loc=1,prop={'size': 18});
Copy link

sergiolucero commented Jun 9, 2022


Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment