Python Forum
Cycle through Numpy range within another range(?)
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Cycle through Numpy range within another range(?)
#1
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)
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  [Numpy] How to store different data type in one numpy array? water 7 600 Mar-26-2024, 02:18 PM
Last Post: snippsat
  Index out of range error standenman 0 1,100 May-22-2023, 10:35 PM
Last Post: standenman
  Numpy returns "TypeError: unsupported operand type(s) for *: 'numpy.ufunc' and 'int'" kalle 2 2,628 Jul-19-2022, 06:31 AM
Last Post: paul18fr
  Better visualisation for wide range data oraib 0 1,312 Oct-16-2021, 10:07 AM
Last Post: oraib
  [split] Getting Index Error - list index out of range krishna 2 2,617 Jan-09-2021, 08:29 AM
Last Post: buran
  Getting Index Error - list index out of range RahulSingh 2 6,159 Feb-03-2020, 07:17 AM
Last Post: RahulSingh
  pandas.read_sas with chunksize: IndexError list index out of range axelle 0 2,590 Jan-28-2020, 09:30 AM
Last Post: axelle
  itertuples, datetime, pandas, groupby, in range karlito 0 2,473 Nov-29-2019, 11:35 AM
Last Post: karlito
  iterate over index and define each range as a day karlito 7 4,417 Nov-19-2019, 06:37 AM
Last Post: karlito
  "erlarge" a numpy-matrix to numpy-array PhysChem 2 2,991 Apr-09-2019, 04:54 PM
Last Post: PhysChem

Forum Jump:

User Panel Messages

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