Python Forum
Scaling of mapped vectors?
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Scaling of mapped vectors?
#1
I'm sure this question has been asked many times but I couldn't find previous references to it.

I'm very much a Python newbie, but learning quickly. I'm building a program that will accept spectrum data in the form of a mapped list (Python calls this a dictionary), such as [[f1,a1],[f2,a2],...], where "fn" refers to frequency n, and "an" refers to amplitude n. I then need to scale that spectrum data using another mapped list [[fs1,s1],[fs2,s2],...], where "fsn" and "sn" refer to frequencies and scaling factors of the equipment (antenna factors, cable losses, amplifier gains, etc.) The problem is that the indices within the two lists will essentially never match up, so in order to correct the measured data with the correction factors, it is necessary to perform linear interpolation between points.
In BASIC, I would write a for/next routine to step through each element of the spectrum data, find the nearest pair in the correction data, and perform the interpolation. But, I suspect that Python or one of its modules has something to do that automatically.

Does anyone know if Python or one of its modules has a function or method to take two mapped lists that do NOT have corresponding indices and adjust one using the other using linear interpolation between the unaligned points?
Reply
#2
numpy.interp() will work perfectly for what I’m trying to do.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Feature Scaling with Partitions rocketfish 3 2,099 Aug-13-2020, 01:39 PM
Last Post: rocketfish
  Slicing using vectors paul18fr 4 2,844 Nov-16-2019, 10:43 AM
Last Post: paul18fr
  Statistics: Two histograms based on word frequency vectors fancy_panther 2 4,710 Mar-27-2017, 01:18 AM
Last Post: zivoni

Forum Jump:

User Panel Messages

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