Giter Club home page Giter Club logo

windrose's People

Contributors

15b3 avatar dependabot[bot] avatar fmaussion avatar jkittner avatar jokva avatar jparta avatar kilojoules avatar leouieda avatar mccannjb avatar mwheels avatar ocefpaf avatar petebachant avatar pre-commit-ci[bot] avatar sampr7 avatar scls19fr avatar sspagnol avatar stas-sl avatar weber-s avatar xmnlab avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

windrose's Issues

Allow for specifying `rmax` to plot

When generating lots of windrose plots for timelapses or comparisons, it is useful to have stable polar maximum radius set. Would you consider an addition of allowing the max radius to be specified instead of dynamically computed from the data? thanks

Windrose legend typo

First of all thank you for this useful tool.

I have noticed a typo error in line 170 in windrose.py. There is an open bracket "[" at the end of wind speed range instead of "]".
See attached image for the error:

windrose_893_221

It's just so nice to see this module

No issue reported here, just want to say thank you, since there is no places for discussion.
I'm just wondering what field are you guys in? My field is Civil Engineering, and our main focus is on the wind effect on buildings, so the wind speed is an essential part for us.

Add a release procedure file

We should probably add a release-procedure.md file to this repository

An example

  • Ensure supported Python versions in setup.py and .travis.yml are corrects

  • Ensure windrose version is up to date in version.py

  • Tag commit and push to github

using Github website

Go to https://github.com/python-windrose/windrose/releases/new
tag: vx.x.x

or using cli

    git tag -a x.x.x -m 'Version x.x.x'
    git push windrose master --tags
  • Verify on Zenodo

Go to https://zenodo.org/account/settings/github/repository/python-windrose/windrose

to ensure that new release have a DOI

  • Upload to PyPI

Ensure a ~/.pypirc exists

[distutils] # this tells distutils what package indexes you can push to
index-servers = pypi
    pypi # the live PyPI
    pypitest # test PyPI

[pypi]
repository:http://pypi.python.org/pypi
username:scls
password:**********

Upload

    git clean -xfd
    python setup.py register sdist bdist_wheel --universal
    python setup.py sdist bdist_wheel upload
  • Verify on PyPI

Go to https://pypi.python.org/pypi/windrose/
or https://pypi.python.org/pypi?%3Aaction=pkg_edit&name=windrose

Weibull plot error using pandas dataframe

I am trying to plot a weibull distribution and get the curve fit parameters using numpy arrays extracted from a dataframe (df1), and feeding these into plot_windrose using the following code:

wspd = df1['WS4_1'].values
wbbins = np.arange(0,30+0.5,0.5)
wbbins = wbbins[1:]

fig, ax = plt.subplots(figsize=(8, 8), dpi=80)
ax = WindAxes.from_ax()
ax, params = ax.pdf(wspd, bins=wbbins)
plt.show()

However, I get a really strange plot (see attached). The same occurs when I feed this data and the bins to plot_windrose with kind='pdf'

Can anyone help?

Jan Theron

The wspd data is printed out:

>>> wspd
[  5.032613   5.479693   5.61294    5.507614   6.334925   5.560237
   5.450258   5.943854   5.701277   5.810945   6.147182   6.387178
   5.686224   5.448959   5.754909   5.051301   5.212162   5.230433
   5.299956   6.024059   5.68548    5.376521   5.032531   4.395826
   4.348891   4.727659   4.667429   6.240138   7.357653   6.935119
   7.082482   7.121882   7.258893   6.772759   7.122444   7.758015
   7.129415   5.837385   5.861522   7.59339    7.023991   6.487524
   6.913578   7.226395   7.190455   7.388771   6.865273   7.183555
   7.142313   8.42302    5.09356    6.496036   3.888637   3.25016    2.04789
   2.022803   1.923722   4.120824   5.404851   4.882666   6.915624
   6.025914  10.37906   11.78722   10.95381   10.20427    9.438169
   8.407446   8.495973   6.937519   6.017589   7.129867   6.322631
   4.829598   3.872521   4.839109   9.061943  11.67362   11.48648   13.36514
  11.74871   12.22727   14.09576   16.47237   17.84455   18.09477   16.40567
  15.5479    15.87354   15.60001   15.71991   15.23703   14.33726   13.98059
  14.46785   13.44779   13.66952   14.01294   14.07419   13.12614   13.0113
  12.91716   12.91938   12.87632   11.98887   11.83941   11.43309   11.21472
  11.2115    10.54931    9.864621   9.036641   8.780334   9.267542
   9.251016   9.366816   9.655682  10.79546   11.34777   10.69087   10.11476
  10.07086    7.710583   6.620311   5.36337    4.692961   4.897275
   5.107494   3.901091   3.679365   4.238818   5.503904   6.357628
   6.743927   6.85803    6.398366   5.923348   5.147363   4.875776]

and the bins as well:

>>> wbbins
[  0.5   1.    1.5   2.    2.5   3.    3.5   4.    4.5   5.    5.5   6.
   6.5   7.    7.5   8.    8.5   9.    9.5  10.   10.5  11.   11.5  12.
  12.5  13.   13.5  14.   14.5  15.   15.5  16.   16.5  17.   17.5  18.
  18.5  19.   19.5  20.   20.5  21.   21.5  22.   22.5  23.   23.5  24.
  24.5  25.   25.5  26.   26.5  27.   27.5  28.   28.5  29.   29.5  30. ]

Create a GitHub organization

We should probably create a GitHub organization

What about

py-windrose
or
python-windrose

for this org name?

Looking for naming suggestion

Pinging @lionelr

Seamless Subplotting

Hi! I was trying to use the module to plot a bunch of other weather parameters. The module can only be used for standalone plots. I cannot subplot it within my existing plot setup. I have tried some of the work arounds given but was not successful.

Smooth plot

I have found some real dark magic. Your module plots roses as triangles emerging from center - with straight, blocky edges. However, if you add this code (i.e. any histogram with pyplot)
plt.hist([0, 1]); plt.close()
before executing your function (i.e. WindroseAxes), you get smooth curvy roses like here:
http://climate.ncsu.edu/windrose.php
krdu_windrose
This doesn't make any sense and I couldn't figure out why this works, but it does. Any idea on why this happens and if you can add this "feature" to your module?

ValueError: radial grids must be strictly positive

I am having issues with windrose when receiving this error:

ValueError: radial grids must be strictly positive 

Is there an example of a work around that I can follow as I don't understand what is causing it. My data does not appear to have any negative values (if that is what the error means)?

Any feedback will be greatly appreciated.

WindroseAxes from existing ax

Perhaps I'm missing something, but your example:

ax = WindroseAxes.from_ax()
ax.bar(wd, ws, normed=True, opening=0.8, edgecolor='white')

works perfectly, until I try to create a WindroseAxes from an existing ax. For example:

ax1 = pl.subplot(211)
ax2 = WindroseAxes.from_ax(ax1)
ax2.bar(wd, ws, normed=True, opening=0.8, edgecolor='white')

fails at ax2.bar (Unknown property normed), because ax2 is now no longer a windrose.WindroseAxes but a matplotlib.axes._subplots.AxesSubplot, as from_ax simply returns the given axes if it is not equal to None.

Is it somehow possible to add multiple wind roses to a figure, from existing axes?

change colours?

I have seaborn in the same notebook for other plots and it has switched the axes to white by default which doesn't work with the windrose very well how can I overwrite the axis colours?

Paper submission

Publishing to The Journal of Open Source Software (JOSS) http://joss.theoj.org/ may be consider

We need a paper.md

---
title: 'Windrose: A Python Matplotlib, Numpy library to manage wind data, draw windrose (also known as a polar rose plot), draw probability density function and fit Weibull distribution'
tags:
  - windrose
  - windspeed
  - wind
  - speed
  - plot
  - python
  - matplotlib
  - numpy
  - pandas
authors:
 - name: Lionel Roubeyrie
   orcid: 0000-0001-6017-4385
   affiliation: 1
 - name: Sébastien Celles
   orcid: 0000-0001-9987-4338
   affiliation: 2
affiliations:
 - name: LIMAIR
   index: 1
 - name: Université de Poitiers - Poitiers Institute of Technology (IUT)
   index: 2
date: 13 may 2017
bibliography: paper.bib
---

# Summary

Windrose is Python Matplotlib, Numpy library to manage wind data, draw windrose 
(also known as a polar rose plot), draw probability density function and fit Weibull distribution

-![Windrose (bar) example](screenshots/bar.png)
-![Windrose (contourf-contour) example](screenshots/contourf-contour.png)
-![Windrose subplots](screenshots/subplots.png)

# References

Can you add an argument to add units to the legend

presently, the legend displays just the numbers, e.g. [0.0 : 5.0]

It would be nice if we could specify the units with a simple string argument

ax.set_legend(units="mph")

would set legend label as [0.0 : 5.0] mph

or

ax.set_legend(units="m/s")

would set legend label as [0.0 : 5.0] m/s

i18n and l10n - half-open (exclusive) interval

speed intervals are half-open (exclusive) interval

https://fr.wikipedia.org/wiki/Intervalle_(math%C3%A9matiques)

I'm using "french" notation

[1.0;2.0[
[2.0;3.0[

but english notations are differents
https://en.wikipedia.org/wiki/Interval_(mathematics)

[1.0;2.0)
[2.0;3.0)

we need to detect system language and we need to display half-open (exclusive) interval accordlingly.

See https://github.com/scls19fr/windrose/pull/16

Thanks @MarcoForte for pointing this to my attention and feel free to submit PR

Ticks on the r axes

I recently discovered your very nice little package, and I really appreciate it.
I am using it for pollution roses in an air quality study, and it works quite well.

I did figure out how to move the legend out of the rose through a direct call to the matplotlib functions underneath:

ax.legend(title="Ozone (ppbv)", loc=(1.2,0))

and how to put titles through the same method: plt.title('Pollution rose at a receptor site', y=1.08)

yet, I am having a very hard time with ticks on the r-axis. no matter what I try to do, I can't force them to be on rounded values.

I tried through : ax.set_yticks(np.arange(0,25,5)), but it keeps putting some kind of offset (typically .2, see attached example)

so I worked around the problem with a formatting solution:

import matplotlib.ticker as tkr
ax.yaxis.set_major_formatter(tkr.FormatStrFormatter('%2.0f'))

but I think there should be a better way to do that.
did I miss something ?

thanks for your help

windrose_ex

plot_windrose should provide a "by" parameter

When feeding plot_windrose with a DataFrame with columns: speed, direction, year_month, passing a parameter like by='year_month' should plot several plots on same figure (subplots).

by = 'year_month'  # same as 'month' or 'year'
df[by] = df.index.map(lambda dt: (dt.year, dt.month))

similar to http://pandas.pydata.org/pandas-docs/dev/generated/pandas.DataFrame.hist.html
https://github.com/pydata/pandas/blob/39d567ec0fcbcaa75d531657412e61f3f274931a/pandas/tools/plotting.py

So it will help to show if major direction of wind (for example) changed over the time.

An other interesting feature could be to animate plot.
see https://github.com/scls19fr/windrose/issues/11

http://nbviewer.ipython.org/github/scls19fr/windrose/blob/master/windrose_sample_poitiers_csv.ipynb

Run unit test using

$ nosetests tests.test_windrose:test_plot_by -s -v

Handling "Calms"

Is there a way to treat 'calms' differently within datasets? For example, in the dataset I'm attempting to create windroses for, calms are denoted as Wd=0.0 and Ws=0.0 (whereas North winds are denoted as Wd=360.0). It seems like in this case they are currently lumped in with North winds.

stacked colorbar goes to infinity

It seems that when the edges of the var bins are specified, the final color should go between the -2 and -1 indexed values, not between -1 and infinity. In the example below, I would expect the last color bin to be between 15 and 20.

ax = WindroseAxes.from_ax()
ax.bar(bearings, dists, bins=[0,5,10,15,20], normed=True, opening=0.8, edgecolor='white')
ax.set_legend()

example

I would be happy to submit a pull request if you can point me in the right direction.

Matplotlib 2.0

C:\Users\u0553130\AppData\Local\Continuum\Anaconda2\lib\site-packages\matplotlib\cbook.py:136: MatplotlibDeprecationWarning: **The axisbg attribute was deprecated in version 2.0. Use facecolor instead.
  warnings.warn(message, mplDeprecation, stacklevel=1)**
C:\Users\u0553130\AppData\Local\Continuum\Anaconda2\lib\site-packages\numpy\lib\function_base.py:804: RuntimeWarning: invalid value encountered in greater_equal
  not_smaller_than_edge = (sample[:, i] >= edges[i][-1])
C:\Users\u0553130\AppData\Local\Continuum\Anaconda2\lib\site-packages\numpy\core\fromnumeric.py:2822: RuntimeWarning: invalid value encountered in rint
  return round(decimals, out)

Pip package, unit test, continuous integration

A pip package should be made
Unit tests should be added (Nose or Pytest)
Continuous Integration (Travis) should be made. We might use miniconda and not use pip to install requirements (at least matplotlib and Numpy, maybe Pandas)

ImportError: cannot import name 'WindroseAxes'

I use Python 3.5, i have used pip3 install windrose, but when I try to run my script I get a error message:

dhcp712-stud2:~ JDMac$ python3 windrose.py
Traceback (most recent call last):
  File "windrose.py", line 8, in <module>
    from windrose import WindroseAxes
  File "/Users/JDMac/windrose.py", line 8, in <module>
    from windrose import WindroseAxes
ImportError: cannot import name 'WindroseAxes'

My code windrose.py that I try to run:

import pandas as pd
import numpy as np
from matplotlib import pyplot as plt
import matplotlib.cm as cm
import numpy as np
from math import pi

from windrose import WindroseAxes

df = pd.read_csv("WIND10M_7081N_1975E.txt", names=['YEAR','M','D','H','WSP','WDIR'], header=None, delim_whitespace=True)

ax = windrose.WindroseAxes.from_ax()
ax.bar(df.WDIR, df.WSP, normed=True, opening=0.8, edgecolor='white')
ax.set_legend()

I have installed all dependencies:

dhcp712-stud2:~ JDMac$ pip3 install windrose
Requirement already satisfied (use --upgrade to upgrade): windrose in /usr/local/lib/python3.5/site-packages
Requirement already satisfied (use --upgrade to upgrade): numpy in /usr/local/lib/python3.5/site-packages (from windrose)
Requirement already satisfied (use --upgrade to upgrade): matplotlib in /usr/local/lib/python3.5/site-packages (from windrose)
Requirement already satisfied (use --upgrade to upgrade): cycler in /usr/local/lib/python3.5/site-packages (from matplotlib->windrose)
Requirement already satisfied (use --upgrade to upgrade): pytz in /usr/local/lib/python3.5/site-packages (from matplotlib->windrose)
Requirement already satisfied (use --upgrade to upgrade): python-dateutil in /usr/local/lib/python3.5/site-packages (from matplotlib->windrose)
Requirement already satisfied (use --upgrade to upgrade): pyparsing!=2.0.0,!=2.0.4,>=1.5.6 in /usr/local/lib/python3.5/site-packages (from matplotlib->windrose)
Requirement already satisfied (use --upgrade to upgrade): six in /usr/local/lib/python3.5/site-packages (from cycler->matplotlib->windrose)

Cannot Import Name poly_between

error 2
error 3
So I am using python 3.5. When I tried to import windrose, it says that it cannot import name 'poly_between'. Then I tried upgrading matplotlib but then it says that lapack isn't found.
Then I came back to check and saw that windrose is only built for up to python 3.4. Would a windrose package from python 3.5 be coming out soon?
Thank you.

matplotlib 2.0 warning : axisbg -> facecolor

I was getting

/Users/cqcn1991/anaconda/lib/python3.6/site-packages/matplotlib/cbook.py:136: MatplotlibDeprecationWarning: The axisbg attribute was deprecated in version 2.0. Use facecolor instead.
  warnings.warn(message, mplDeprecation, stacklevel=1)

when using windrose to make simple plots. I think it might the lib's problem, is there anything I can help?

set common radial scale

I am creating multiple wind roses and I would like them all to be comparable. Is there a way to set a common radial scale?
Any feedback will be greatly appreciated.
Thank you

I am currently using the following:

def new_axes():
    fig = plt.figure(figsize=(8, 8), dpi=80, facecolor='w', edgecolor='k')
    rect = [0.1, 0.1, 0.8, 0.8]
    ax = WindroseAxes(fig, rect, axisbg='w')
    fig.add_axes(ax)
    return ax

def set_legend(ax):
    l = ax.legend(borderaxespad=-0.10, title='knots')
    plt.setp(l.get_texts(), fontsize=8)

ax = new_axes()
ax.contourf(wd, ws, normed=True, bins=np.arange(0,30,5), opening=0.8, edgecolor='white', cmap=cm.hot)

set_legend(ax)

CI is broken

Currently continous integration is broken.
We should fix it.

Request: Register axes to matplotlib, then we can use as "projection="

First, I would like to thank you for this amazing tool. I am using it to plot geological faults in rose diagrams.
I would like to give you an an idea to register the axes as projection automatically after we import WindroseAxes.

You just have to do this:

  1. First, import register_projection:
    from matplotlib.projections import register_projection
  2. Then add a name variable :
class WindroseAxes(PolarAxes):
    name = 'windrose'
    ...
  1. Finally, at the end of windrose.py, you add:

register_projection(WindroseAxes)

I think this is going to work. If it doesn't, please take a look at these two examples:
Example 1
Example 2

Use it as:

ax1 = fig.add_subplot(131, projection='polar')
ax2 = fig.add_subplot(132, projection='rectilinear')
ax3 = fig.add_subplot(133, projection='windrose')

ax3.bar(dir, vals)

Add Python 3.6

We should add Python 3.6 to .travis.yml and to setup.py

where is API?

Can you provide an API for windrose?I need help with the API.Thanks.

projection="windrose" not working

I just cloned and installed the most recent github version that should have the projection="windrose" option.

But trying the example code below I get an ValueError: Unknown projection 'windrose' error.

Any suggestions on what I may be doing wrong?

from matplotlib import pyplot as plt
import windrose
import matplotlib.cm as cm
import numpy as np

ws = np.random.random(500) * 6
wd = np.random.random(500) * 360

fig = plt.figure()
ax = fig.add_subplot(221, projection="windrose")

ax.contourf(wd, ws, bins=np.arange(0, 8, 1), cmap=cm.hot)

ax.legend(bbox_to_anchor=(1.02, 0))
plt.show()

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.