How to use decimate_mean #226
-
Hi, I don't understand what are the 'a' and **kwargs arguments of decimate_mean. Cheers, |
Beta Was this translation helpful? Give feedback.
Replies: 8 comments
-
Did you have a look at http://gromacswrapper.readthedocs.io/en/latest/gromacs/core/fileformats/xvg.html#plotting ? See also decimate(). If the docs are still unclear just ping me again. |
Beta Was this translation helpful? Give feedback.
-
For decimate():
Under the hood it uses numkit.timeseries - Coarse graining time series. |
Beta Was this translation helpful? Give feedback.
-
From orbeckst: a is the array that you are coarsening In my case I want to obtain a simple average curve of my pressure along the time (mean or smooth), so should 'a' be the pressure column from the xvg file, i.e columns[1] ? Have you an example of decimate_mean or smooth method with an 'a' argument ? |
Beta Was this translation helpful? Give feedback.
-
If you just want to plot, use xvg.plot(columns=[0,1], method="mean", maxpoints=100) # bin-averaged data (100 bins)
xvg.plot(columns=[0,1], maxpoints=None, alpha=0.1) # all data, light gray The time_pressure = xvg.array[[0, 1]] # select column 0 as time and column 1 as P
time_pressure_coarse = xvg.decimate("mean", time_pressure, maxpoints=1000)
It can be just the data but if this was a time series you probably want to include the independent variable (time) as well as the 0-th column as in my example, i.e. columns [0, 1]. |
Beta Was this translation helpful? Give feedback.
-
Thanks a lot Oliver, |
Beta Was this translation helpful? Give feedback.
-
decimate is ok for me, I can produce arrays that I can manipulate then plot with xvg.plot. Usefull. |
Beta Was this translation helpful? Give feedback.
-
Can someone show me how to add a label or a legend to a xvg plot object ? I can't find how to pass **kwargs to xvg.plot() method. |
Beta Was this translation helpful? Give feedback.
-
It works now for example to add a label: pressure.plot(label="Pressure") I close until ... |
Beta Was this translation helpful? Give feedback.
If you just want to plot, use
xvg.plot()
withmethod
andmaxpoints
(using the example):The
xvg.decimate()
method itself takes a 1D or 2D array as input. A 1D array is turned into a 2D array where the first column is just the index. If you want to use it with the data in the xvg you could do something like: