0

I have a given point list in a text file, that I am reading and store it in an array. I want to calculate the derivative for this array, because I want to figure out where the local maxima and minima are located.

Here is the code, which gives an error like: numpy.linalg.linalg.LinAlgError: 1-dimensional array given. Array must be at least two-dimensional

Could you help me where is my mistake? Here is a picture how the points look like on a graph enter image description here

import numpy as np
filename = 'N:\SAJAT_MAPPAK\IGYULAVICS\egy\ico228\PYTHONNAL\ico228_127.txt'
x = np.loadtxt(filename, delimiter=',', usecols=(0,4))
#np.linalg.det(x)
part127 = []
part127 = np.concatenate(x)
print part127
solution = np.linalg.det(szakasz127)

Here is some sample data:

x,y
2109,116.107
2110,116.11
2111,116.114
2112,116.118
2113,116.12
2114,116.125
2115,116.136
miracle173
  • 1,852
  • 16
  • 33
krszt
  • 63
  • 1
  • 7
  • What do you understand as "determinant of a 1-d array"? – mkrieger1 Feb 17 '20 at 12:42
  • Why do you not simply use `np.max(...)`? – mkrieger1 Feb 17 '20 at 12:43
  • Did you mean "derivative"? – mkrieger1 Feb 17 '20 at 12:44
  • What is szakasz127? Looks like a 1darray from the error. Can you provide sample data of what is in szakasz127? – Ethan Feb 17 '20 at 12:49
  • Yes, I mean derivative as if it changes sign (- to +) there is local min/max. I attached sample datas. np.max just gives back the maximum of a list, but I need LOCAL maximum... – krszt Feb 17 '20 at 13:07
  • 1
    Check this post https://stackoverflow.com/questions/4624970/finding-local-maxima-minima-with-numpy-in-a-1d-numpy-array you can also use np.diff and find the points where the difference sign changes – Aly Hosny Feb 17 '20 at 14:16
  • Well then obviously you can’t use the `np.linalg.det` function, which calculates the determinant of a matrix, which is something entirely different than the derivative of 1-dimensional data. – mkrieger1 Feb 17 '20 at 22:17

0 Answers0