psychrochart
psychrochart copied to clipboard
plotting series of points
Hi trying to build a jupyter notebook and getting things mostly working but not understanding plotting a series of points.
python3
chart = PsychroChart("ashrae") t1 = numpy.array([65.24384, 65.24384]) h1 = numpy.array([50.7857, 51.1154]) points = { 'n': (t1, h1) } chart.plot_points_dbt_rh(points)
Generates an error:
~/.conda/envs/pschrometricenv/lib/python3.8/site-packages/matplotlib/axes/_base.py in _xy_from_xy(self, x, y) 267 y = _check_1d(y) 268 if x.shape[0] != y.shape[0]: --> 269 raise ValueError("x and y must have same first dimension, but " 270 "have shapes {} and {}".format(x.shape, y.shape)) 271 if x.ndim > 2 or y.ndim > 2:
ValueError: x and y must have same first dimension, but have shapes (1, 2) and (2,)
Now I also got a different error with this method but I am not sure if I'm passing in a numpy array. But I think it is. y['temperature'] and y['humidity'] are python lists.
t = numpy.asarray(y['temperature']) h = numpy.asarray(y['humidity']) chart = PsychroChart("ashrae") points = { 'n': (t, h) }
chart.plot_points_dbt_rh(points)
Then the error is:
~/.conda/envs/pschrometricenv/lib/python3.8/site-packages/psychrolib.py in GetSatVapPres(TDryBulb) 1033 - 2.4780681E-09 * math.pow(T, 3) + 6.5459673 * math.log(T) 1034 else: -> 1035 if (TDryBulb < -100 or TDryBulb > 200): 1036 raise ValueError("Dry bulb temperature must be in range [-100, 200]°C") 1037
TypeError: '<' not supported between instances of 'numpy.str_' and 'int'
Thanks for any insight. Again, I'm probably doing something silly.
Cary
I found two issues.
- My temps are in F but I'm not using ashrae_ip but when I do use ashrae_ip I get dry bulb out of range error. (I can fix the temps.). But I get the same errors with C.
- I was not generating the plot before adding the points. Fixed that but I still get the same errors.
Thanks
Cary
Hi,
I'm experiencing the same issue, although I am attempting to plot 8760 points (to view EPW weather data characteristics). I have a dataframe (df) that looks like:
DryBlb_F | DewPnt_F | RelHum_% |
---|---|---|
51.98 | 50.00 | 92.925 |
30.92 | 28.04 | 87.5351 |
... | ... | ... |
44.06 | 44.06 | 100 |
51.98 | 51.08 | 96.7274 |
I was able to force the plot by looping over df:
# Plot points:
for row, index in df.iterrows():
points={'points_series_name': {'style':{'color':[0.855, 0.004, 0.278, 0.8],
'markersize':5},#'marker':'X',
'xy':(df.at[row,'DryBlb_F'],df.at[row,'RelHum_%'])}}
chart.plot_points_dbt_rh(points)
But this is not preferred. The issue is in 'chart.py' beginning at line 386:
for point in points_plot.values():
func_append = self.axes.scatter if use_scatter else self.axes.plot
self._handlers_annotations.append(
func_append(point[0], point[1], **point[2])
)
I haven't taken the time to dig into this, any thoughts/updates?
Hi there :)
any thoughts/updates?
Yes. psychrolib
has been updated with special support for arrays, and I have in my TODO list a very needed update on this repo, to enable better integration with pandas/numpy to plot series of points, as scatter points or line plots (for evolutions), and to fix issues related to the IP units. Also a better system to customize the chart is in order.
I didn't have much time for this, but I expect to have some in the next weeks, so I'll try to solve this asap.
EDIT: I don't receive direct notifications of issues if I'm not cc'ed, like doing @azogue @compostable, @clwhitney, sorry about that
@compostable Yup similar to what I did. Just plot all the points.
@azogue I like the idea of a line to show time, I was trying to either do luminous or shading but neither really works well. RGB does not offer a smooth transition path between colors and converting to HSV solves one problem but still does not really work well.
I also have point count similar to compostable but density a bit more concentrated.
Lastly, I've wrapped this into a wxPython windows to allow the facilities guys to select their own data points and time desired. I'm basically generating it on the fly. Also it would be nice to be able to define a zone with 3 bounds like Zone A which has a humidity cut off.
Thanks for your work.
Cary
Hi @azogue
Same issue when i want to plot series of points. I follow this comment' tip in func "plot_points_dbt_rh" (in chart.py)
* if you are plotting series of points, pass them as numpy arrays:
points={'points_series_name': (temp_array, humid_array)}
temp
Out[14]:
array([19.9, 21.9, 19.4, 23.4, 21.2, 21.1, 23.4, 24.8, 19.2, 24.6, 19.1,
20.5, 23.9, 25.1, 22.6, 22.8, 18.7, 24.5, 25.2, 23.5, 23.3, 19.4,
21.1, 21.1, 20.3])
hum
Out[15]:
array([55.5, 63.9, 45.8, 59.2, 48. , 46.4, 63.6, 56.7, 57.3, 57.7, 56.8,
55.9, 48.4, 58.4, 51. , 51.4, 46.8, 62. , 46.8, 59.6, 47.6, 64.1,
50.6, 51.2, 57.2])
shape(temp) == shape(hum)
Out[16]: True
shape(temp)
Out[17]: (25,)
points = {'august': (temp, hum)}
chart.plot_points_dbt_rh(points)
**Error starting at File "[...]\psychrochart\chart.py", line 389, in plot_points_dbt_rh
func_append(point[0], point[1], **point[2])
ValueError: x and y must have same first dimension, but have shapes (1, 25) and (25,)**