Python Forum
Adding shifted data set to data set
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Adding shifted data set to data set
#1
Hello,

I have a data set that I have shifted by a certain amount.
The unshifted and shifted data set are plotted as you can see in the attached figure.

using
...
plt.plot(t+fwhm, Vs/np.max(Vs), color='r')
plt.plot(t, Vs/np.max(Vs))
how can the sum of the shifted and unshifted data set be plotted?

Both t and Vs datasets are of type <class 'numpy.ndarray'>.

Regards,
xquad

Attached Files

Thumbnail(s)
   
Reply
#2
I tried:

import matplotlib.pyplot as plt
from scipy import interpolate
x = t
y = Vs
f = interpolate.interp1d(x, y, fill_value = 'extrapolate')
xnew = t + fwhm
ynew = f(xnew)
plt.plot(x, y, 'o', xnew, ynew, 'k')
plt.xlim(-0.25e-7, 0.25e-7)
plt.show()
but the interpolated data will not be shifted...
Reply
#3
ah found it:

xnew = t + fwhm
print(np.max(xnew), np.max(t))
ynew = f(xnew)   # use interpolation function returned by `interp1d`
print(np.argmax(ynew), np.argmax(y))
plt.plot(x, y)
plt.plot(x, ynew, 'r')
plt.plot(x, y+ynew)
plt.xlim(-0.25e-7, 0.25e-7)
plt.show()
its visible shifted if plotted on the same axis. (I found it after noticing a difference in np.argmax())
Reply
#4
Thanks for sharing the solution.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Help with to check an Input list data with a data read from an external source sacharyya 3 421 Mar-09-2024, 12:33 PM
Last Post: Pedroski55
  Write sql data or CSV Data into parquet file mg24 2 2,451 Sep-26-2022, 08:21 AM
Last Post: ibreeden
  Load multiple Jason data in one Data Frame vijays3 6 1,565 Aug-12-2022, 05:17 PM
Last Post: vijays3
  Django: Adding Row Data To Existing Model Instance Question/Problem. Steven_Pinkerton 1 1,252 Aug-09-2022, 10:46 AM
Last Post: Addweb
  Issue in changing data format (2 bytes) into a 16 bit data. GiggsB 11 2,678 Jul-25-2022, 03:19 PM
Last Post: deanhystad
  FFT - frequency shifted frohr 0 728 Jul-23-2022, 05:17 PM
Last Post: frohr
  Looking for data/info on a perticular data-proccesing problem. MvGulik 9 3,910 May-01-2021, 07:43 AM
Last Post: MvGulik
  How to filter out Column data From Multiple rows data? firaki12345 10 5,149 Feb-06-2021, 04:54 AM
Last Post: buran
  how to print all data from all data array? korenron 3 2,479 Dec-30-2020, 01:54 PM
Last Post: korenron
  update column in one data frame with value of column from another data frame flexer 0 1,793 Dec-04-2020, 03:29 PM
Last Post: flexer

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020