A user asked:
How can I extract the statistical data from a log? (like the get time series properties)?
I am able to plot (SavePlot1D) the log but I want to add a legend or a title with the overall average and Std Dev…
A user asked:
How can I extract the statistical data from a log? (like the get time series properties)?
I am able to plot (SavePlot1D) the log but I want to add a legend or a title with the overall average and Std Dev…
From a “random” workspace, wksp
, you can get a time series log with
pcharge = wksp.run()['proton_charge']
From there you can get various statistics using pcharge.getStatistics()
. There is a bonus property directly on the property pcharge.timeAverageValue()
. The difference is that pcharge.getStatistics().mean
is the mean of the values, where the time average is an integral of the values divided by the total time of the log.
You can get the raw values with pcharge.value
which returns a ndarray
of doubles. Unfortunately, pcharge.times
doesn’t give something immediately useful in python. Instead, you need to double convert the times to get the compatible type, np.datetime64
.
values = pcharge.values
times = np.array(pcharge.times, dtype=str).astype(np.datetime64)
which you can do anything you want with.