Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Numpy slicing problem
#1
   

Code:
import numpy as np

a  = np.concatenate((np.linspace(10,200,25),np.geomspace(200,360,25)))
b  = np.concatenate((np.linspace(20,-180,25),np.linspace(-180,230,25)))

c = a[0]+(b[0])/np.pi
if c >= 360:
   c = 360
d= a[3]+(b[3])/np.pi
if d >= 360:
   d = 360
e = np.linspace(c,d,50)

f = open("new.txt","w")
for i in range(50):
   f.write("gmic someFilter params: "+str(a[i])+","+str(b[i])+","+str(e[i])+" -o somefiles%04d.file \n" % i)
f.close()


Tryin to get it so that in all 50 outputs to the text file, the value of 'e' is: a + b / pi (or 360 if e >= 360).
First output seems ok i.e.: gmic someFilter params: 10.0,20.0,16.366197723675814 -o somefiles0000.file
but subsequent values are messed up, i.e. the last one: gmic someFilter params: 360.0,230.0,32.15845056908105 -o somefiles0049.file
.. the value of 'e' in this case should be about 82, not 32..
My slicing is probably the issue as I've no experience doing this, any help gratefully received.
cheers!
Reply


Messages In This Thread
Numpy slicing problem - by Zero01 - 07-18-2021, 04:21 PM
RE: Numpy slicing problem - by Zero01 - 07-18-2021, 06:38 PM
RE: Numpy slicing problem - by Ofnuts - 07-18-2021, 08:02 PM
RE: Numpy slicing problem - by Zero01 - 07-19-2021, 07:31 AM

Forum Jump: