Skip to content

Commit 4928039

Browse files
committed
Merge branch 'develop'
2 parents 5337008 + bff1bf2 commit 4928039

File tree

4 files changed

+72
-13
lines changed

4 files changed

+72
-13
lines changed

sphinx/conf.py

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
import sys
1616
import os
1717
import sphinx_readable_theme
18+
from recommonmark.parser import CommonMarkParser
1819

1920
# If extensions (or modules to document with autodoc) are in another directory,
2021
# add these directories to sys.path here. If the directory is relative to the
@@ -32,6 +33,7 @@
3233
extensions = [
3334
'sphinx.ext.autodoc',
3435
'sphinx.ext.viewcode',
36+
'recommonmark'
3537
]
3638

3739
# Add any paths that contain templates here, relative to this directory.
@@ -48,7 +50,7 @@
4850

4951
# General information about the project.
5052
project = u'pyowm'
51-
copyright = u'2018, Claudio Sparpaglione'
53+
copyright = u'2020, Claudio Sparpaglione'
5254

5355
# The version info for the project you're documenting, acts as replacement for
5456
# |version| and |release|, also used in various other places throughout the
@@ -118,16 +120,16 @@
118120
#html_title = None
119121

120122
# A shorter title for the navigation bar. Default is the same as html_title.
121-
#html_short_title = None
123+
html_short_title = 'PyOWM documentation'
122124

123125
# The name of an image file (relative to this directory) to place at the top
124126
# of the sidebar.
125-
#html_logo = None
127+
html_logo = 'logo.png'
126128

127129
# The name of an image file (within the static path) to use as favicon of the
128130
# docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32
129131
# pixels large.
130-
#html_favicon = None
132+
html_favicon = 'favicon.ico'
131133

132134
# Add any paths that contain custom static files (such as style sheets) here,
133135
# relative to this directory. They are copied after the builtin static files,
@@ -141,7 +143,7 @@
141143

142144
# If not '', a 'Last updated on:' timestamp is inserted at every page bottom,
143145
# using the given strftime format.
144-
#html_last_updated_fmt = '%b %d, %Y'
146+
html_last_updated_fmt = '%b %d, %Y'
145147

146148
# If true, SmartyPants will be used to convert quotes and dashes to
147149
# typographically correct entities.
@@ -170,7 +172,7 @@
170172
#html_show_sphinx = True
171173

172174
# If true, "(C) Copyright ..." is shown in the HTML footer. Default is True.
173-
#html_show_copyright = True
175+
html_show_copyright = True
174176

175177
# If true, an OpenSearch description file will be output, and all pages will
176178
# contain a <link> tag referring to it. The value of this option must be the
@@ -269,7 +271,7 @@
269271
epub_title = u'pyowm'
270272
epub_author = u'Claudio Sparpaglione'
271273
epub_publisher = u'Claudio Sparpaglione'
272-
epub_copyright = u'2018, Claudio Sparpaglione'
274+
epub_copyright = u'2020, Claudio Sparpaglione'
273275

274276
# The basename for the epub file. It defaults to the project name.
275277
#epub_basename = u'pyowm'
@@ -334,5 +336,5 @@
334336

335337

336338
source_parsers = {
337-
'.md': 'recommonmark.parser.CommonMarkParser',
338-
}
339+
'.md': CommonMarkParser,
340+
}

sphinx/favicon.ico

90.9 KB
Binary file not shown.

sphinx/logo.png

8.94 KB
Loading

sphinx/v3/code-recipes.md

Lines changed: 61 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -666,9 +666,15 @@ The `raw_measurements_dict` contains multiple sub-dicts, each one being a a data
666666

667667
With the OneCall Api you can get the current weather, hourly forecast for the next 48 hours and the daily forecast for the next seven days in one call.
668668

669-
Below some examples:
669+
One Call objects can be thought of as datasets that "photograhp" of observed and forecasted weather data for a location: such photos are given for a specific timestamp.
670670

671-
### What is the feels like temperature (°C) tomorrow morning?
671+
It is possible to get:
672+
- current OneCall data: the "photo" given for today)
673+
- historical OneCall data: "photos" given for past days, up to 5
674+
675+
### Current OneCall data
676+
677+
#### What is the feels like temperature (°C) tomorrow morning?
672678
Always in Berlin:
673679

674680
```python
@@ -680,7 +686,7 @@ one_call = mgr.one_call(lat=52.5244, lon=13.4105)
680686
one_call.forecast_daily[0].temperature('celsius').get('feels_like_morn', None) #Ex.: 7.7
681687
```
682688

683-
### What's the wind speed in three hours?
689+
#### What's the wind speed in three hours?
684690

685691
__Attention: The first entry in forecast_hourly is the current hour.__
686692
If you send the request at 18:36 UTC then the first entry in forecast_hourly is from 18:00 UTC.
@@ -696,7 +702,7 @@ one_call = mgr.one_call(lat=52.5244, lon=13.4105)
696702
one_call.forecast_hourly[3].wind().get('speed', 0) # Eg.: 4.42
697703
```
698704

699-
### What's the current humidity?
705+
#### What's the current humidity?
700706

701707
Always in Berlin:
702708

@@ -708,3 +714,54 @@ one_call = mgr.one_call(lat=52.5244, lon=13.4105)
708714

709715
one_call.current.humidity # Eg.: 81
710716
```
717+
718+
### Historical OneCall data
719+
720+
Remember the "photograph" metaphor for OneCall data. You can query for "photos" given for past days: when you do that,
721+
be aware that such a photo carries along weather forecasts (hourly and daily) that *might* refer to the past
722+
723+
This is because - as said above - the One Call API returns hourly forecasts for a streak of 48 hours and daily forecast
724+
for a streak of 7 days, both streaks beginning from the timestamp which the OneCall object refers to
725+
726+
In case of doubt, anyway, you can always _check the reference timestamp_ for the `Weather` objects embedded into the
727+
OneCall object and check if it's in the past or not.
728+
729+
730+
#### What was the observed weather yesterday at this time?
731+
732+
Always in Berlin:
733+
734+
```python
735+
from pyowm.owm import OWM
736+
from pyowm.utils import timestamps, formatting
737+
738+
owm = OWM('your-api-key')
739+
mgr = owm.weather_manager()
740+
741+
# what is the epoch for yesterday at this time?
742+
yesterday_epoch = formatting.to_UNIXtime(timestamps.yesterday())
743+
744+
one_call_yesterday = mgr.one_call_history(lat=52.5244, lon=13.4105, dt=yesterday_epoch)
745+
746+
observed_weather = one_call_yesterday.current
747+
```
748+
749+
#### What was the weather forecasted 3 days ago for the subsequent 48 hours ?
750+
751+
No way we move from Berlin:
752+
753+
```python
754+
from pyowm.owm import OWM
755+
from pyowm.utils import timestamps
756+
from datetime import datetime, timedelta, timezone
757+
758+
owm = OWM('your-api-key')
759+
mgr = owm.weather_manager()
760+
761+
# what is the epoch for 3 days ago at this time?
762+
three_days_ago_epoch = int((datetime.now() - timedelta(days=3)).replace(tzinfo=timezone.utc).timestamp())
763+
764+
one_call_three_days_ago = mgr.one_call_history(lat=52.5244, lon=13.4105, dt=three_days_ago_epoch)
765+
766+
list_of_forecasted_weathers = one_call_three_days_ago.forecast_hourly
767+
```

0 commit comments

Comments
 (0)