-
Notifications
You must be signed in to change notification settings - Fork 19
Documenta el caso de uso de la predicción de temperaturas por municipio y añade fuzzy search #28
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 7 commits
93fbe5b
1485e67
d886da6
feea8c9
4eee411
2c81cfa
c84b4ea
3d01bcf
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,14 +1,21 @@ | ||
| from aemet.models import * # noqa | ||
| import click | ||
|
|
||
|
|
||
| @click.command() | ||
| @click.option('-p', '--prediccion', help='Muestra la predicción meteorológica dado un nombre de municipio') | ||
| def main(prediccion): | ||
| client = Aemet() | ||
| @click.option( | ||
| "-p", | ||
| "--prediccion", | ||
| help="Muestra la predicción meteorológica dado un nombre de municipio", | ||
| ) | ||
| @click.option("-k", "--key", help="API key AEMET") | ||
| @click.option("-f", "--keyfile", help="Fichero con la clave de la AEMET.") | ||
| def main(prediccion, key, keyfile): | ||
| client = Aemet(api_key=key, api_key_file=keyfile) | ||
| municipio = Municipio.buscar(prediccion) | ||
| p = client.get_prediccion(municipio.get_codigo()) | ||
| print(f"Predicción de temperaturas para {municipio.nombre}:\n") | ||
| for dia in p.prediccion: | ||
| print(dia.fecha) | ||
| print('Máxima: {}'.format(dia.temperatura['maxima'])) | ||
| print('Mínima: {}'.format(dia.temperatura['minima'])) | ||
| print() | ||
| print("Máxima: {}".format(dia.temperatura["maxima"])) | ||
| print("Mínima: {}\n".format(dia.temperatura["minima"])) |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,80 @@ | ||
| # Casos de uso de `python-aemet` | ||
|
|
||
| ## Requisitos previos | ||
|
|
||
| ### Instalar la librería `python-aemet` | ||
|
|
||
| - Tener `python3` instalado en el sistema: `which python` | ||
|
|
||
| - Instalar la librería en el local. Recomendamos el uso de un `virtualenv`. | ||
|
|
||
| E.g. Instala `virtualenv`: | ||
|
|
||
| ```bash | ||
| pip install virtualenv | ||
| ``` | ||
|
|
||
| Clona el repo `git clone git@github.com:pablo-moreno/python-aemet.git && cd python-aemet` | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Aquí sería mejor hablar de instalar la librería desde pypi, que es como está en el README.md pip install python-aemet
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Cierto, ida de olla. Entonces quito todo lo del virtualenv que eso es gestión de entorno. Que cada usuario se apañe digamos. |
||
|
|
||
| Activa el `virtualenv`: | ||
|
|
||
| ```bash | ||
| virtualenv .venv | ||
| source .venv/bin/activate | ||
| ``` | ||
|
|
||
| Instala la librería | ||
|
|
||
| ```bash | ||
| pip install . | ||
| ``` | ||
|
|
||
| ### Obtener la clave API | ||
|
|
||
| Obtén tu clave de API en la siguiente URL: | ||
|
|
||
| <https://opendata.aemet.es/centrodedescargas/obtencionAPIKey> | ||
|
|
||
| Y ponla en un fichero `aemet.key` | ||
|
|
||
| ## Casos de uso | ||
|
|
||
| ### Predicción de la temperatura máxima y mínima en un municipio concreto en los próximos días | ||
|
|
||
| ```bash | ||
| aemet -p Madrid -f /path/a/la/clave/aemet.key | ||
| ``` | ||
|
|
||
| La salida: | ||
|
|
||
| ```sh | ||
| Predicción de temperaturas para Madrid: | ||
|
|
||
| 2021-04-03T00:00:00 | ||
| Máxima: 20 | ||
| Mínima: 10 | ||
|
|
||
| 2021-04-04T00:00:00 | ||
| Máxima: 20 | ||
| Mínima: 7 | ||
|
|
||
| 2021-04-05T00:00:00 | ||
| Máxima: 22 | ||
| Mínima: 7 | ||
|
|
||
| 2021-04-06T00:00:00 | ||
| Máxima: 22 | ||
| Mínima: 7 | ||
|
|
||
| 2021-04-07T00:00:00 | ||
| Máxima: 19 | ||
| Mínima: 4 | ||
|
|
||
| 2021-04-08T00:00:00 | ||
| Máxima: 18 | ||
| Mínima: 9 | ||
|
|
||
| 2021-04-09T00:00:00 | ||
| Máxima: 20 | ||
| Mínima: 10 | ||
| ``` | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,5 @@ | ||
| urllib3 | ||
| requests | ||
| click | ||
| fuzzywuzzy | ||
| python-Levenshtein |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Entiendo la funcionalidad y me parece bien mejorar la búsqueda de municipios en general, pero quiero evitar añadir más dependencias de las necesarias y creo que no es el objetivo principal de lo que nos ocupa.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sí tienes razón. Te parece que cree un issue para mejorar la búsqueda? Es que tal cual estaba en el init no funcionaba, devuelve una lista de todos los municipios con la palabra que metes en el argumento en la línea de comandos.