Home › Forums › Nazca › Questions and Answers › Structure or loop too big? plus why can't I re-run same script?
- This topic has 2 replies, 3 voices, and was last updated 4 years, 3 months ago by Xaveer.
-
AuthorPosts
-
16 July 2020 at 10:18 #6187CameronMember
Hello,
I have this script for creating ID numbers in the layout:
import nazca as nd import nazca.demofab as demo import nazca.geometries as geom cpitchx = 6000 cpitchy = 5500 offsety = 958 offsetx = 294 row = 24 col = 12 with nd.Cell(name='Cell_C') as cellc: f = nd.Font('cousine') i = 0 for i in range(col): xpos = cpitchx*i + int(i/2)*offsetx for j in range (row): num_r = str(j) #nd.text(text=num_r, height=100, layer=1, align='cc').put(cpitchx*i,cpitchy*j) num_c = 'c'+str(i)+'r'+str(j) ypos = cpitchy * j + int(j/2) * offsety nd.text(text=num_c, height=100, layer=1, align='cc').put(xpos * i + 750, ypos * j) cellc.put(0, 0, 0) print('done') #nd.export_plt() nd.export_gds(filename='chip_numbers_space2.gds')
When I set the col or row values too high (greater than 24), I get the error:
“File “C:\ProgramData\Anaconda3\lib\site-packages\nazca\gds_base.py”, line 100, in pack_int32
return struct.pack(“l”, l)
error: argument out of range”The script works fine for smaller values for the loop index however.
Also, I’m curious why whenever I re-run the script I get the error :
“active_cell = cfg.cells[-1] IndexError: list index out of range”
If I restart spyder it works fine.
Thank you in advance for your help!16 July 2020 at 10:35 #6190RonaldKeymasterDear Cameron.
When placing the text, its xpos and ypos are multiplied by i and j again in your script. This gives coordinates that are indeed out of range for gds, hence the error. Below a clean up that also utilizes the font you initialized.
import nazca as nd cpitchx = 6000 cpitchy = 5500 offsety = 958 offsetx = 294 row = 24 col = 12 font = nd.Font('cousine') # create object to create text in the indicated font. with nd.Cell(name='Cell_C') as cellc: for i in range(col): xpos = cpitchx * i + int(i / 2) * offsetx for j in range (row): num_r = f"{j}" #nd.text(text=num_r, height=100, layer=1, align='cc').put(cpitchx * i, cpitchy * j) num_c = f"c{i}r{j}" ypos = cpitchy * j + int(j / 2) * offsety font.text(text=num_c, height=100, layer=1, align='cc').put(xpos + 750, ypos) cellc.put(0, 0, 0) print('done') nd.export_gds(filename='chip_numbers_space2.gds')
Ronald
16 July 2020 at 10:43 #6191XaveerModeratorDear Cameron,
You should check your program: the area you are trying to write is over 3 meters high, which exceeds the GDS capabilities when using 1 nm precision. So what you see is an integer overflow.
Your for loop multiplies by j twice, e.g. in calculating ypos and in the put() statement ypos is again multiplied by j. Same for i. This is probably not what you want.
For the font, if you want to use “cousine”, you have to use f.text() in stead of nd.text().
And for running multiple times in spyder, you could try to clear some parameters after loading nazca. E.g. this may help:
import nazca as nd nd.clear_layout() nd.clear_layers() nd.clear_xsections()
Xaveer
-
AuthorPosts
- You must be logged in to reply to this topic.