Skip to content

Commit fa43e33

Browse files
authored
Merge branch 'master' into remove_setuptools-markdown
2 parents 10118c0 + 48b45e3 commit fa43e33

29 files changed

+1706
-1077
lines changed

LICENCE

Lines changed: 3 additions & 514 deletions
Large diffs are not rendered by default.

LICENCE_BSD-3-Clause.TXT

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
Copyright 2017 Lionel Roubeyrie / Sébastien Celles
2+
3+
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
4+
5+
1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
6+
7+
2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
8+
9+
3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
10+
11+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

LICENCE_CECILL-B.TXT

Lines changed: 515 additions & 0 deletions
Large diffs are not rendered by default.

README.md

Lines changed: 3 additions & 285 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
[![Documentation Status](https://readthedocs.org/projects/windrose/badge/?version=latest)](http://windrose.readthedocs.io/en/latest/?badge=latest)
12
[![Latest Version](https://img.shields.io/pypi/v/windrose.svg)](https://pypi.python.org/pypi/windrose/)
23
[![Supported Python versions](https://img.shields.io/pypi/pyversions/windrose.svg)](https://pypi.python.org/pypi/windrose/)
34
[![Wheel format](https://img.shields.io/pypi/wheel/windrose.svg)](https://pypi.python.org/pypi/windrose/)
@@ -20,288 +21,5 @@ Original code forked from:
2021
- windrose 1.4 by [Lionel Roubeyrie](https://github.com/LionelR) <[email protected]> http://youarealegend.blogspot.fr/search/label/windrose
2122

2223

23-
## Requirements:
24-
25-
- matplotlib http://matplotlib.org/
26-
- numpy http://www.numpy.org/
27-
- and naturally python https://www.python.org/ :-P
28-
29-
Option libraries:
30-
31-
- Pandas http://pandas.pydata.org/ (to feed plot functions easily)
32-
- Scipy http://www.scipy.org/ (to fit data with Weibull distribution)
33-
- ffmpeg https://www.ffmpeg.org/ (to output video)
34-
- click http://click.pocoo.org/ (for command line interface tools)
35-
36-
## Install
37-
38-
### Install latest release version via pip
39-
40-
A package is available and can be downloaded from PyPi and installed using:
41-
42-
```bash
43-
$ pip install windrose
44-
```
45-
### Install latest development version
46-
47-
```bash
48-
$ pip install git+https://github.com/python-windrose/windrose
49-
```
50-
51-
or
52-
53-
```bash
54-
$ git clone https://github.com/python-windrose/windrose
55-
$ python setup.py install
56-
```
57-
58-
## Notebook example :
59-
60-
An [IPython (Jupyter)](http://ipython.org/) notebook showing this package usage is available at:
61-
62-
- http://nbviewer.ipython.org/github/python-windrose/windrose/blob/master/windrose_sample_random.ipynb
63-
64-
## Script example :
65-
66-
This example use randoms values for wind speed and direction(ws and wd variables). In situation, these variables are loaded with reals values (1-D array), from a database or directly from a text file (see the "load" facility from the matplotlib.pylab interface for that).
67-
68-
```python
69-
from windrose import WindroseAxes
70-
from matplotlib import pyplot as plt
71-
import matplotlib.cm as cm
72-
import numpy as np
73-
74-
# Create wind speed and direction variables
75-
76-
ws = np.random.random(500) * 6
77-
wd = np.random.random(500) * 360
78-
```
79-
80-
### A stacked histogram with normed (displayed in percent) results :
81-
82-
```python
83-
ax = WindroseAxes.from_ax()
84-
ax.bar(wd, ws, normed=True, opening=0.8, edgecolor='white')
85-
ax.set_legend()
86-
```
87-
88-
![bar](screenshots/bar.png)
89-
90-
### Another stacked histogram representation, not normed, with bins limits
91-
92-
```python
93-
ax = WindroseAxes.from_ax()
94-
ax.box(wd, ws, bins=np.arange(0, 8, 1))
95-
ax.set_legend()
96-
```
97-
98-
![box](screenshots/box.png)
99-
100-
### A windrose in filled representation, with a controled colormap
101-
102-
```python
103-
ax = WindroseAxes.from_ax()
104-
ax.contourf(wd, ws, bins=np.arange(0, 8, 1), cmap=cm.hot)
105-
ax.set_legend()
106-
```
107-
108-
![contourf](screenshots/contourf.png)
109-
110-
### Same as above, but with contours over each filled region...
111-
112-
```python
113-
ax = WindroseAxes.from_ax()
114-
ax.contourf(wd, ws, bins=np.arange(0, 8, 1), cmap=cm.hot)
115-
ax.contour(wd, ws, bins=np.arange(0, 8, 1), colors='black')
116-
ax.set_legend()
117-
```
118-
119-
![contourf-contour](screenshots/contourf-contour.png)
120-
121-
### ...or without filled regions
122-
123-
```python
124-
ax = WindroseAxes.from_ax()
125-
ax.contour(wd, ws, bins=np.arange(0, 8, 1), cmap=cm.hot, lw=3)
126-
ax.set_legend()
127-
```
128-
129-
![contour](screenshots/contour.png)
130-
131-
After that, you can have a look at the computed values used to plot the windrose with the `ax._info` dictionnary :
132-
- `ax._info['bins']` : list of bins (limits) used for wind speeds. If not set in the call, bins will be set to 6 parts between wind speed min and max.
133-
- `ax._info['dir']` : list of directions "bundaries" used to compute the distribution by wind direction sector. This can be set by the nsector parameter (see below).
134-
- `ax._info['table']` : the resulting table of the computation. It's a 2D histogram, where each line represents a wind speed class, and each column represents a wind direction class.
135-
136-
137-
So, to know the frequency of each wind direction, for all wind speeds, do:
138-
139-
```python
140-
ax.bar(wd, ws, normed=True, nsector=16)
141-
table = ax._info['table']
142-
wd_freq = np.sum(table, axis=0)
143-
```
144-
145-
and to have a graphical representation of this result :
146-
147-
```python
148-
direction = ax._info['dir']
149-
wd_freq = np.sum(table, axis=0)
150-
plt.bar(np.arange(16), wd_freq, align='center')
151-
xlabels = ('N','','N-E','','E','','S-E','','S','','S-O','','O','','N-O','')
152-
xticks=arange(16)
153-
gca().set_xticks(xticks)
154-
draw()
155-
gca().set_xticklabels(xlabels)
156-
draw()
157-
```
158-
159-
![histo_WD](screenshots/histo_WD.png)
160-
161-
In addition of all the standard pyplot parameters, you can pass special parameters to control the windrose production. For the stacked histogram windrose, calling help(ax.bar) will give :
162-
`bar(self, direction, var, **kwargs)` method of `windrose.WindroseAxes` instance Plot a windrose in bar mode. For each var bins and for each sector, a colored bar will be draw on the axes.
163-
164-
165-
Mandatory:
166-
- `direction` : 1D array - directions the wind blows from, North centred
167-
- `var` : 1D array - values of the variable to compute. Typically the wind speeds
168-
169-
Optional:
170-
- `nsector` : integer - number of sectors used to compute the windrose table. If not set, nsectors=16, then each sector will be 360/16=22.5°, and the resulting computed table will be aligned with the cardinals points.
171-
- `bins` : 1D array or integer- number of bins, or a sequence of bins variable. If not set, bins=6 between min(var) and max(var).
172-
- `blowto` : bool. If True, the windrose will be pi rotated, to show where the wind blow to (usefull for pollutant rose).
173-
- `colors` : string or tuple - one string color (`'k'` or `'black'`), in this case all bins will be plotted in this color; a tuple of matplotlib color args (string, float, rgb, etc), different levels will be plotted in different colors in the order specified.
174-
- `cmap` : a cm Colormap instance from `matplotlib.cm`.
175-
- if `cmap == None` and `colors == None`, a default Colormap is used.
176-
- `edgecolor` : string - The string color each edge bar will be plotted.
177-
Default : no edgecolor
178-
- `opening` : float - between 0.0 and 1.0, to control the space between each sector (1.0 for no space)
179-
- `mean_values` : Bool - specify wind speed statistics with direction=specific mean wind speeds. If this flag is specified, var is expected to be an array of mean wind speeds corresponding to each entry in `direction`. These are used to generate a distribution of wind speeds assuming the distribution is Weibull with shape factor = 2.
180-
- `weibull_factors` : Bool - specify wind speed statistics with direction=specific weibull scale and shape factors. If this flag is specified, var is expected to be of the form [[7,2], ...., [7.5,1.9]] where var[i][0] is the weibull scale factor and var[i][1] is the shape factor
181-
182-
### probability density function (pdf) and fitting Weibull distribution
183-
184-
A probability density function can be plot using:
185-
186-
```python
187-
from windrose import WindAxes
188-
ax = WindAxes.from_ax()
189-
bins = np.arange(0, 6 + 1, 0.5)
190-
bins = bins[1:]
191-
ax, params = ax.pdf(ws, bins=bins)
192-
```
193-
194-
![pdf](screenshots/pdf.png)
195-
196-
Optimal parameters of Weibull distribution can be displayed using
197-
198-
```python
199-
print(params)
200-
(1, 1.7042156870194352, 0, 7.0907180300605459)
201-
```
202-
203-
204-
## Functional API
205-
206-
Instead of using object oriented approach like previously shown, some "shortcut" functions have been defined: `wrbox`, `wrbar`, `wrcontour`, `wrcontourf`, `wrpdf`.
207-
See [unit tests](tests/test_windrose.py).
208-
209-
## Pandas support
210-
211-
windrose not only supports Numpy arrays. It also supports also Pandas DataFrame. `plot_windrose` function provides most of plotting features previously shown.
212-
213-
214-
```python
215-
from windrose import plot_windrose
216-
N = 500
217-
ws = np.random.random(N) * 6
218-
wd = np.random.random(N) * 360
219-
df = pd.DataFrame({'speed': ws, 'direction': wd})
220-
plot_windrose(df, kind='contour', bins=np.arange(0.01,8,1), cmap=cm.hot, lw=3)
221-
```
222-
223-
Mandatory:
224-
- `df`: Pandas DataFrame with `DateTimeIndex` as index and at least 2 columns (`'speed'` and `'direction'`).
225-
226-
Optional:
227-
- `kind` : kind of plot (might be either, `'contour'`, `'contourf'`, `'bar'`, `'box'`, `'pdf'`)
228-
- `var_name` : name of var column name ; default value is `VAR_DEFAULT='speed'`
229-
- `direction_name` : name of direction column name ; default value is `DIR_DEFAULT='direction'`
230-
- `clean_flag` : cleanup data flag (remove data points with `NaN`, `var=0`) before plotting ; default value is `True`.
231-
232-
## Subplots
233-
234-
![subplots](screenshots/subplots.png)
235-
236-
237-
## Video export
238-
A video of plots can be exported.
239-
A playlist of videos is available at https://www.youtube.com/playlist?list=PLE9hIvV5BUzsQ4EPBDnJucgmmZ85D_b-W
240-
241-
See:
242-
243-
[![Video1](http://img.youtube.com/vi/0u2RxtGgEFo/0.jpg)](https://www.youtube.com/watch?v=0u2RxtGgEFo)
244-
[![Video2](http://img.youtube.com/vi/3CWpjSEt0so/0.jpg)](https://www.youtube.com/watch?v=3CWpjSEt0so)
245-
[![Video3](http://img.youtube.com/vi/UiGC-3aw9TM/0.jpg)](https://www.youtube.com/watch?v=UiGC-3aw9TM)
246-
247-
[Source code](samples/example_animate.py)
248-
249-
This is just a sample for now. API for video need to be created.
250-
251-
Use:
252-
253-
```bash
254-
$ python samples/example_animate.py --help
255-
```
256-
257-
to display command line interface usage.
258-
259-
## Development
260-
261-
You can help to develop this library.
262-
263-
### Issues
264-
265-
You can submit issues using <https://github.com/python-windrose/windrose/issues>
266-
267-
### Clone
268-
269-
You can clone repository to try to fix issues yourself using:
270-
271-
```bash
272-
$ git clone https://github.com/python-windrose/windrose.git
273-
```
274-
275-
### Run unit tests
276-
277-
Run all unit tests
278-
279-
```bash
280-
$ nosetests -s -v
281-
```
282-
283-
Run a given test
284-
285-
```bash
286-
$ nosetests tests.test_windrose:test_plot_by -s -v
287-
```
288-
289-
### Install development version
290-
291-
```bash
292-
$ python setup.py install
293-
```
294-
295-
or
296-
297-
```bash
298-
$ sudo pip install git+https://github.com/python-windrose/windrose.git
299-
```
300-
301-
### Collaborating
302-
303-
- Fork repository
304-
- Create a branch which fix a given issue
305-
- Submit pull requests
306-
307-
<https://help.github.com/categories/collaborating/>
24+
## Documentation
25+
[![Documentation Status](https://readthedocs.org/projects/windrose/badge/?version=latest)](http://windrose.readthedocs.io/en/latest/?badge=latest)

docs/Makefile

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# Minimal makefile for Sphinx documentation
2+
#
3+
4+
# You can set these variables from the command line.
5+
SPHINXOPTS =
6+
SPHINXBUILD = python -msphinx
7+
SPHINXPROJ = windrose
8+
SOURCEDIR = .
9+
BUILDDIR = _build
10+
11+
# Put it first so that "make" without argument is like "make help".
12+
help:
13+
@$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
14+
15+
.PHONY: help Makefile
16+
17+
# Catch-all target: route all unknown targets to Sphinx using the new
18+
# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
19+
%: Makefile
20+
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)

docs/api.rst

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
API
2+
===
3+
4+
.. automodule:: windrose
5+
:members:
6+
:undoc-members:

0 commit comments

Comments
 (0)