Skip to content
Snippets Groups Projects

Cambios para nueva versión del API

Merged Alexander Martínez Méndez requested to merge mxrtinez-main-patch-30439 into main
2 files
+ 30
26
Compare changes
  • Side-by-side
  • Inline
Files
2
+ 28
24
%% Cell type:markdown id: tags:
%% Cell type:markdown id: tags:
# Uso del API MakeSens
# Uso del API MakeSens
%% Cell type:markdown id: tags:
%% Cell type:markdown id: tags:
Instalar Librerias
Instalar Librerias
%% Cell type:code id: tags:
%% Cell type:code id: tags:
```
``` python
#!pip install APIMakeSens
#!pip install APIMakeSens
#!pip install tk
#!pip install tk
%% Cell type:markdown id: tags:
%% Cell type:markdown id: tags:
Cargar librería *MakeSens*
Cargar librería *MakeSens*
%% Cell type:code id: tags:
%% Cell type:code id: tags:
```
``` python
# Makesens
# Makesens
from MakeSens import MakeSens
from MakeSens import MakeSens
# Pandas
# Pandas
import pandas as pd
import pandas as pd
# datetime para manejo de fechas
# datetime para manejo de fechas
import datetime
import datetime
# pytz para manejo de zonas horarias
# pytz para manejo de zonas horarias
import pytz
import pytz
%% Cell type:markdown id: tags:
%% Cell type:markdown id: tags:
Definir token y cargar listado de estaciones
Definir token y cargar listado de estaciones
%% Cell type:code id: tags:
%% Cell type:code id: tags:
```
``` python
token = 'tokenUsr'
estaciones = pd.read_csv("evasLA-CoNGA.csv").set_index("id")
estaciones = pd.read_csv("evasLA-CoNGA.csv")
%% Cell type:markdown id: tags:
%% Cell type:markdown id: tags:
Definir rango de fechas para descarga
Definir rango de fechas para descarga
%% Cell type:code id: tags:
%% Cell type:code id: tags:
```
``` python
fechaFin = datetime.datetime.now(pytz.timezone('America/Bogota')).strftime('%Y-%m-%d %H:%M:%S')
fechaFin = datetime.datetime.now(pytz.timezone('America/Bogota')).strftime('%Y-%m-%d %H:%M:%S')
fechaInicio = (datetime.datetime.now(pytz.timezone('America/Bogota'))-datetime.timedelta(hours=1)).strftime('%Y-%m-%d %H:%M:%S')
fechaInicio = (datetime.datetime.now(pytz.timezone('America/Bogota'))-datetime.timedelta(hours=240)).strftime('%Y-%m-%d %H:%M:%S')
%% Cell type:code id: tags:
%% Cell type:code id: tags:
```
``` python
for eva in estaciones["id"]:
for eva in estaciones.index:
data = MakeSens.download_data(eva, fechaInicio, fechaFin, 'h', token, None)
data = MakeSens.download_data(eva, fechaInicio, fechaFin, 'h')
if data.empty:
if data.empty:
print(eva, 'Offline')
print(eva, estaciones.loc[eva]['institucion'], 'Offline')
else:
else:
print(eva, data['temperatura'][0])
print(eva, estaciones.loc[eva]['institucion'], data['temperatura'][0])
%% Output
%% Output
DE2_00010 Offline
E2_00010 Yachay Offline
DE2_00011 Offline
E2_00011 UAN Offline
DE2_00012 22.36809542857143
E2_00012 UIS 26.740791766666668
DE2_00013 Offline
E2_00013 UIS Offline
DE2_00014 Offline
E2_00014 UCV Offline
DE2_00015 Offline
E2_00015 UAN Offline
DE2_00016 23.72797557142857
E2_00016 USFQ Offline
DE2_00017 16.2979185
E2_00017 UNMSM Offline
DE2_00018 27.151353375
E2_00018 USB 26.138263899999995
DE2_00019 Offline
E2_00019 UNI Offline
 
%% Cell type:code id: tags:
 
``` python
Loading