Python Forum
Cycle through Numpy range within another range(?) - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: Data Science (https://python-forum.io/forum-44.html)
+--- Thread: Cycle through Numpy range within another range(?) (/thread-28714.html)



Cycle through Numpy range within another range(?) - Zero01 - Jul-31-2020

This script needs refining, not really a coder so what I have produced so far is quite something for me...at present this script outputs a text file which I feed into a Windows cmd shell to create and output files, using an image processing framework (GMIC)

i.e.
import numpy as np
 
a = np.linspace(1.15,1.79,1008)
b = np.linspace(11,20,1008,dtype=int)
c = np.linspace(0,180,1008)
d = np.linspace(2,22,1008)
e = np.linspace(0.28,0.998,1008)
 
op = open("aop.txt","w")
for line in range(1008):
    op.write("gmic v -99 div 255 file_.png fx_layer_cake_2 4,145,0,40.8965,70.4155,2,2,50,0,0 fx_blur_bloom_glare 2.12,"+
    str(a[line])+","+str(b[line])+",0,4,0,1,"+str(c[line])+","+str(d[line])+","+str(e[line])+
    ",7,0 mul 255 o lby_%04d.png \n" % line)
op.close()
I'd like to output 1008 image files and in this case the variables (a,b,c,d,e) will obviously extend their ranges throughout all 1008 files.
What I require though is for the variables to cycle through their ranges every 63 files (so the numbers in the np.linspace examples above are wrong atm), and then the variables should return to the starting values and continue again, and on and on throughout the 1008 files. Hope that makes sense.
Thanks a lot.
EDIT: the initial 'file_.png' will be replaced in Notepad++ by ascending file numbers (i.e. file_0001.png - file_1008.png)