how to find periods from time series data in python - python

I have time series data
How do I get period??
The first picture graph and first graph of second picture is same graph.
and ignore the second graph of second picture.
We wanted to get micro current when a person workout.
this chart is that a man push the sensor with his finger.
Because we didn't make a good sensor yet.
and My team tried to find not noisy data so that we made the data to 0 below 400. But we can return it to normal data.
It seems 7 similiar periods.
I have used
https://github.com/gsubramani/SignalRecognition
but this have an error. code did not work well
https://github.com/guillaume-chevalier/seq2seq-signal-prediction
My computer have no gpu.. so I couldn't test it. It had errors
https://github.com/tbnsilveira/STFT_analysis/blob/master/STFT_sinusoidal_signal.ipynb
This don't seem to have how to get periods.
I use python.
Any helps would be helpful!! Thank you in advance.

Related

Edge pruning in graph

Im just starting out with my python - graphs adventure and I have just encountered a conceptional problem. So, my data is some activities which have happend over time - activity, timestamp and some additional data. I want to create graph that shows consecutive steps, so I join data on time condition. My ideal graph whould show that A->B->C->D, but because A is always initial step i get A->B (which is ok) and obsolete A->C, A->D. So my questions is do you know any smart way to prune those edges leaving only important ones? I was thinking about maybe some function in networkx? Please help.

How to automatically reduce the range of a chart?

First of all sorry for my bad english as it is not first language.
I have recently started learning python and I am trying to develop a "simple" program, but I have run into a problem.
I am using xlwings to modify and interact with Excel. What I want to achieve (or to know if its possible) is:
I have excel look into data and plot a graph. However this graph sometimes has for example 20 values for the X-Axis and in other cases let's say 10 values for the X-Axis, thus, leaving 10 #NA empty spaces. Based on this, I want to adjust the graph to show only 10 values by changing the range that shapes the graph .
The function get_prod_hours() looks how many values I want on the X-Axis:
def get_prod_hours():
"""From the input gets the production hours to adapt the graphs"""
dt = wb.sheets['Calculatrice']
return dt.range('E24').value
Based on the value gotten from the function I must modify the range of values on the graph (by reducing it).
Solutions as for example create the graphs from scratch are not OK because I would like to only modify the range of the graph because the Excel file is a "standard" on my company.
I hope for something like:
Column A in Excel with values: 1, 2, 3, 4, 5 and get from get_prod_hours() a value of 5, so my graph will have only 5 points and not for example 6 of which one is #NA.
Thank you very much, and sorry for the wall of text.
The xlwings API doesn't offer a lot of options for charts (see https://docs.xlwings.org/en/stable/api.html?highlight=charts#xlwings.main.Charts).
Try to find the chart in wb.sheets[0].charts.
The range can then be modified with
range = xw.Range((1,1), (get_prod_hours(),1))
set_source_data(wb.sheets[0].range(range))
But from looking at the API and knowing how many options Excel charts have, the API feels too thin.
If this doesn't work, an option is to add a VBA macro which modifies the chart and call that. See How do I call an Excel macro from Python using xlwings?

plotting pandas core series.series/values not showing

I am trying to plot the availability of my network per hour. So,I have a massive dataframe containing multiple variables including the availability and hour. I can clearly visualise everything I want on my plot I want to plot when I do the following:
mond_data= mond_data.groupby('Hour')['Availability'].mean()
The only problem is, if I bracket the whole code and plot it (I mean this (the code above).plot); I do not get any value on my x-axis that says 'Hour'.How can plot this showing the values of my x-axis (Hour). I should have 24 values as the code above bring an aaverage for the whole day for midnight to 11pm.
Here is how I solved it.
plt.plot(mon_data.index,mond_data.groupby('Hour')['Availability'].mean())
for some reason python was not plotting the index, only if called. I have not tested many cases. So additional explanation to this problem is still welcome.

Recognition and recording of digits from external window in real time using python

I want to gather numbers that are being output from a specific window in real time as data points.
I have a piece of equipment with an internal pressure level I would like to monitor. The only output that the software I'm using gives me is a single float from the last ~second in a box within the software. I've asked the manufacturers if there was any way of internal accessing this output and they basically told me there is none.
Individual measurements don't mean much to me, and I'd like to see the change in pressure across time. But watching this single value all day isn't very practical for me. So I want to make something that can read a specific line of text by recognizing the words or by giving exact coordinates on the screen (either works), say 'Output PSI: ##.###' and get the ##.### in python as a data point every time the number changes.
Are there modules that anyone has experience with that might be of use here?

How to set x lim to 99.5 percentile of my data series for matplotlib histogram?

I'm currently pumping out some histograms with matplotlib. The issue is that because of one or two outliers my whole graph is incredibly small and almost impossible to read due to having two separate histograms being plotted. The solution I am having problems with is dropping the outliers at around a 99/99.5 percentile. I have tried using:
plt.xlim([np.percentile(df,0), np.percentile(df,99.5)])
plt.xlim([df.min(),np.percentile(df,99.5)])
Seems like it should be a simple fix, but I'm missing some key information to make it happen. Any input would be much appreciated, thanks in advance.
To restrict focus to just the middle 99% of the values, you could do something like this:
trimmed_data = df[(df.Column > df.Column.quantile(0.005)) & (df.Column < df.Column.quantile(0.995))]
Then you could do your histogram on trimmed_data. Exactly how to exclude outliers is more of a stats question than a Python question, but basically the idea I was suggesting in a comment is to clean up the data set using whatever methods you can defend, and then do everything (plots, stats, etc.) on only the cleaned dataset, rather than trying to tweak each individual plot to make it look right while still having the outlier data in there.

Categories

Resources