Skip to content

Commit

Permalink
Actualización de documentación pyql-weather
Browse files Browse the repository at this point in the history
  • Loading branch information
alexdzul committed Apr 28, 2015
1 parent bd734c4 commit de0bc28
Show file tree
Hide file tree
Showing 3 changed files with 174 additions and 8 deletions.
159 changes: 157 additions & 2 deletions docs/geo_examples.rst
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,11 @@ y no una lista::
print(continent.lang)
print(continent.woeid)

**Resultado**::

Africa
en-US
24865670

PlaceFinder
###########
Expand All @@ -61,6 +66,11 @@ Realizamos la búsqueda de la siguientea manera::
finder.woeid)
print(place_info)

**Resultado**::

Guadalajara, Mexico ZIP: 44940 | WOEID:24553135


Obtener lugar pasando parte de su nombre
****************************************

Expand Down Expand Up @@ -92,7 +102,7 @@ Obtener todos los océanos e imprimir sus números `woeid`::
info = "{0}, woeid: {1}".format(ocean.name, ocean.woeid)
print(info)

El resultado sería el siguiente::
**Resultado**::

Atlantic Ocean, woeid: 55959709
Southern Ocean, woeid: 55959676
Expand Down Expand Up @@ -133,7 +143,7 @@ Generamos la consulta con el place "Mexico" e imprimimos el resultado en un cicl
for state in states:
print(state.name)

La salida del script anterior sería similar a lo siguiente::
**Resultado**::


Zacatecas
Expand Down Expand Up @@ -177,3 +187,148 @@ y no necesiten recorrerlo en un ciclo::

state = State.get(place="Mexico", name="Yucatan")
print(state.name, state.woeid)


Sea
###

Para poder completar estos ejemplos es necesario importar el objeto tipo `Sea`::

from pyql.geo.seas import Sea

Listado completo de mares
*************************

La forma más sencilla de obtener el listado completo de todos los mares del mundo es utilizando la función **filter** sin pasar ningún parámetro como filtro::

sea_list = Sea.filter()
for sea in sea_list:
print("Nombre: {0} | woeid: {1}".format(sea.name, sea.woeid))

**Resultado**::

Nombre: Mediterranean Sea | woeid: 55959718
Nombre: Gulf of Aqaba | woeid: 55959677
Nombre: Red Sea | woeid: 55959678
Nombre: English Channel | woeid: 55959688
Nombre: Irish Sea | woeid: 28742112
Nombre: Black Sea | woeid: 55959689
Nombre: North Sea | woeid: 55959673
Nombre: Arabian Sea | woeid: 55959681
Nombre: Persian Gulf | woeid: 55959679
Nombre: Baltic Sea | woeid: 55961436
Nombre: Gulf of Oman | woeid: 55959680
Nombre: Norwegian Sea | woeid: 55959691
Nombre: Denmark Strait | woeid: 55959692
Nombre: Greenland Sea | woeid: 55959685
Nombre: Caribbean Sea | woeid: 55959687
Nombre: Labrador Sea | woeid: 55959684
Nombre: Barents Sea | woeid: 55961429
Nombre: Bay of Bengal | woeid: 55959674
Nombre: Davis Strait | woeid: 55959683
Nombre: Gulf of Mexico | woeid: 55959686
Nombre: Andaman Sea | woeid: 55959713
Nombre: Hudson Bay | woeid: 55959682
Nombre: Strait of Malacca | woeid: 55959714
Nombre: Nares Strait | woeid: 55959690
Nombre: Kara Sea | woeid: 55961432
Nombre: Gulf of Thailand | woeid: 55959699
Nombre: Java Sea | woeid: 55959715
Nombre: Gulf of Tonkin | woeid: 55959700
Nombre: South China Sea | woeid: 55959698
Nombre: Bali Sea | woeid: 55960587
Nombre: Flores Sea | woeid: 55960586
Nombre: Savu Sea | woeid: 55960588
Nombre: Laptev Sea | woeid: 55961431
Nombre: Taiwan Strait | woeid: 55959701
Nombre: Bohai Sea | woeid: 55959695
Nombre: Timor Sea | woeid: 55959706
Nombre: Yellow Sea | woeid: 55959696
Nombre: East China Sea | woeid: 55959694
Nombre: Korea Strait | woeid: 55959697
Nombre: Arafura Sea | woeid: 55959716
Nombre: Great Australian Bight | woeid: 55959703
Nombre: Beaufort Sea | woeid: 55959708
Nombre: Gulf of Carpentaria | woeid: 55959705
Nombre: East Sea/Sea of Japan | woeid: 55959693
Nombre: Gulf of Alaska | woeid: 55959710
Nombre: Coral Sea | woeid: 55959704
Nombre: Sea of Okhotsk | woeid: 55961433
Nombre: East Siberian Sea | woeid: 55961430
Nombre: Chukchi Sea | woeid: 55961435
Nombre: Tasman Sea | woeid: 55959702
Nombre: Bering Sea | woeid: 55961434


Búsqueda con filtros.
*********************

Ahora veremos un ejemplo similar al anterior pero aplicando un filtro. Realizaremos la búsqueda de los mares del continente de África::

african_seas = Sea.filter(place="Africa")

for sea in african_seas:
print(sea.name)

**Resultado**::

Red Sea
Gulf of Aqaba
Mediterranean Sea
Arabian Sea

District
########

Devuelve información sobre los lugares que son áreas administrativas de tercer nivel dentro de un país. Tenga en cuenta que el término "**distrito**" se refiere a cualquier área administrativa que subdivide una zona administrativa de segundo nivel, como los distritos, comunas, municipios.

Para poder completar estos ejemplos es necesario importar el objeto tipo `District`::

from pyql.geo.districts import District

Listado de distritos
********************

Para realizar una búsqueda de los distritos de "Greater London" escribimos lo siguiente::

districts = District.filter(place="Greater London")

for element in districts:
print(element.name)

**Resultado**::

City of Westminster
City of London
Royal Borough of Kensington and Chelsea
London Borough of Camden
London Borough of Islington
London Borough of Lambeth
London Borough of Southwark
London Borough of Hammersmith and Fulham
London Borough of Hackney
London Borough of Tower Hamlets
London Borough of Wandsworth
London Borough of Haringey
London Borough of Lewisham
London Borough of Brent
London Borough of Merton
London Borough of Newham
London Borough of Waltham Forest
London Borough of Greenwich
London Borough of Barnet
London Borough of Ealing
London Borough of Richmond upon Thames
London Borough of Enfield
London Borough of Hounslow
London Borough of Redbridge
London Borough of Sutton
London Borough of Croydon
London Borough of Harrow
Royal Borough of Kingston upon Thames
London Borough of Barking and Dagenham
London Borough of Bromley
London Borough of Bexley
London Borough of Hillingdon
London Borough of Havering

14 changes: 13 additions & 1 deletion docs/installation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,18 @@ Instalación Pyql-Weather
Instalación
###########

pyql-weather está escrita 100% en Python puro y por tal motivo no se requiere de ninguna otra dependencia.
``pyql-weather`` está escrita 100% en Python y por tal motivo no se requiere la instalación de ninguna otra dependencia. Nuestra recomendación es que instales la librería en un entorno virtual

1. Creamos nuestro entorno con virtualenv::

$ virtual testenv

2. Activamos el entorno virtual::

$ source testenv/bin/activate


Ya que tenemos activado nuestro entorno virtual, podemos instalar ``pyql-weather`` de la siguiente manera:


Vía PIP
Expand All @@ -27,3 +38,4 @@ y después ejecutar el script de instalación::

$ python setup.py install

Bien! Ya que tienes instalada nuestra librería te invitamos a continuar leyendo la documentación y encontrar ejemplos muy interesantes.
9 changes: 4 additions & 5 deletions docs/weather_examples.rst
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ Posteriormente debemos instanciar un objeto del tipo `Forecast` utilizando la fu
my_woeid = 24553135
forecast = Forecast.get(woeid=my_woeid, u="c")

- Nota: El parámetro woeid es el "Where on Earth Identifiers" del lugar que deseamos obtener y el segundo parámetro "u" nos permite definir si la unidad de medida del clima deseada es en grados **Celsius** (" c ") o **Fahrenheit** (" f ").
.. note:: El parámetro woeid es el "Where on Earth Identifiers" del lugar que deseamos obtener y el segundo parámetro "u" nos permite definir si la unidad de medida del clima deseada es en grados **Celsius** (" c ") o **Fahrenheit** (" f ").

Ya que tenemos este objeto en memoria ahora podemos utilizarlo para conocer todos los detalles del pronóstico del clima:

Expand Down Expand Up @@ -145,7 +145,7 @@ En el siguiente ejemplo uniremos varias partes de la librería para presentar la
Pronóstico 5 días.
******************

Yahoo Weather nos permite conocer el pronóstico del clima de 5 fechas continuas (incluyendo la fecha de consulta).
Yahoo Weather nos permite conocer el pronóstico del clima de 5 fechas continuas (incluyendo la fecha de consulta).

- Por ejemplo: Si consultamos el clima el día de hoy **28-04-2015 (día 1)**, Yahoo nos ofrecerá el pronóstico para los días **29-04-2015 (día 2)**, **30-04-2015 (día 3)**, **01-05-2015 (día 4)** y **02-05-2015 (día 5)**.

Expand Down Expand Up @@ -221,7 +221,7 @@ La librería pyql-weather nos permite acceder a los datos de cada propiedad en f
print(forecast.wind.as_json())

- **Resultado**::

{u'direction': u'260', u'speed': u'14.48', u'chill': u'40'}

2. Astronomía en JSON::
Expand All @@ -245,6 +245,5 @@ La librería pyql-weather nos permite acceder a los datos de cada propiedad en f
print(forecast.as_json())

- Resultado::

{u'lastBuildDate': u'Tue, 28 Apr 2015 2:46 pm CDT', u'atmosphere': {u'pressure': u'982.05', u'rising': u'2', u'visibility': u'6.44', u'humidity': u'31'}, u'description': u'Yahoo! Weather for Merida, MX', u'language': u'en-us', u'title': u'Yahoo! Weather - Merida, MX', u'image': {u'url': u'http://l.yimg.com/a/i/brand/purplelogo//uh/us/news-wea.gif', u'width': u'142', u'height': u'18', u'link': u'http://weather.yahoo.com', u'title': u'Yahoo! Weather'}, u'item': {u'description': u'\n<img src="http://l.yimg.com/a/i/us/we/52/30.gif"/><br />\n<b>Current Conditions:</b><br />\nPartly Cloudy, 40 C<BR />\n<BR /><b>Forecast:</b><BR />\nTue - Partly Cloudy. High: 41 Low: 26<br />\nWed - AM Thunderstorms. High: 31 Low: 23<br />\nThu - AM Showers. High: 28 Low: 21<br />\nFri - Partly Cloudy. High: 32 Low: 19<br />\nSat - Mostly Sunny. High: 33 Low: 19<br />\n<br />\n<a href="http://us.rd.yahoo.com/dailynews/rss/weather/Merida__MX/*http://weather.yahoo.com/forecast/MXYN0117_c.html">Full Forecast at Yahoo! Weather</a><BR/><BR/>\n(provided by <a href="http://www.weather.com" >The Weather Channel</a>)<br/>\n', u'pubDate': u'Tue, 28 Apr 2015 2:46 pm CDT', u'title': u'Conditions for Merida, MX at 2:46 pm CDT', u'long': u'-89.63', u'forecast': [{u'code': u'30', u'text': u'Partly Cloudy', u'high': u'41', u'low': u'26', u'date': u'28 Apr 2015', u'day': u'Tue'}, {u'code': u'38', u'text': u'AM Thunderstorms', u'high': u'31', u'low': u'23', u'date': u'29 Apr 2015', u'day': u'Wed'}, {u'code': u'39', u'text': u'AM Showers', u'high': u'28', u'low': u'21', u'date': u'30 Apr 2015', u'day': u'Thu'}, {u'code': u'30', u'text': u'Partly Cloudy', u'high': u'32', u'low': u'19', u'date': u'1 May 2015', u'day': u'Fri'}, {u'code': u'34', u'text': u'Mostly Sunny', u'high': u'33', u'low': u'19', u'date': u'2 May 2015', u'day': u'Sat'}], u'link': u'http://us.rd.yahoo.com/dailynews/rss/weather/Merida__MX/*http://weather.yahoo.com/forecast/MXYN0117_c.html', u'lat': u'20.97', u'guid': {u'isPermaLink': u'false', u'content': u'MXYN0117_2015_05_02_7_00_CDT'}, u'condition': {u'date': u'Tue, 28 Apr 2015 2:46 pm CDT', u'text': u'Partly Cloudy', u'code': u'30', u'temp': u'40'}}, u'link': u'http://us.rd.yahoo.com/dailynews/rss/weather/Merida__MX/*http://weather.yahoo.com/forecast/MXYN0117_c.html', u'location': {u'city': u'Merida', u'region': u'YU', u'country': u'Mexico'}, u'ttl': u'60', u'units': {u'distance': u'km', u'speed': u'km/h', u'temperature': u'C', u'pressure': u'mb'}, u'astronomy': {u'sunset': u'7:21 pm', u'sunrise': u'6:29 am'}, u'wind': {u'direction': u'260', u'speed': u'14.48', u'chill': u'40'}}

0 comments on commit de0bc28

Please sign in to comment.