1

enter image description here

I plotted a curve of Area[x-axis] and Elevation[y-axis] by using original data (red curve). now i have new series of elevation against this elevation I want to get new series of area values. For this I fitted 3rd order polynomial ( green curve) by using polyfit function in python.

import numpy as np
from matplotlib import pyplot as plt


p= np.polyfit(area, Elv, 3)
plt.plot(area, Elv, 'r-')
plt.plot(area,np.polyval(p, area),'g----')
plt.xlabel('Area')
plt.ylabel('Elevation')

How can I get value of x[Area] in polynomial f ( x ) = 3ax + 2ax + cx + d against new series of Elevation i.e f(x) ?

Martin Gergov
  • 1,556
  • 4
  • 20
  • 29
Sam
  • 45
  • 1
  • 8
  • 2
    Probably https://stackoverflow.com/questions/42179087/get-the-inverse-function-of-a-polyfit-in-numpy? – ALollz Jan 22 '20 at 22:37
  • 2
    What exactly are you looking for? Do you want to apply your polynomial to a different sequence of areas, or do you want to invert your true elevations values assuming they were generated by the polynomial instead of the true function? – Mark Snyder Jan 22 '20 at 22:41
  • @MarkSnyder I actually want to invert polynomial function to calculate the x values ['area'] with new series of y_values['Elevations'] – Sam Jan 23 '20 at 09:11
  • @ALollz Thank yo for sharing this link but I couldn't understand clearly how they have two values of x against one value of yo = 4 – Sam Jan 23 '20 at 09:13
  • On that example they fit a quadratic function so it has 2 possible values where it is 4. In this case you fit a third order polynomial so you may get 3 values. You would need to choose the correct one if there are multiple. If F(x) = x^2 then both 2 and -2 lead to a value of 4, for instance – ALollz Jan 23 '20 at 13:53

0 Answers0