HelgeGehring / gdshelpers

GDSHelpers is an open-source package for automatized pattern generation for nano-structuring.
https://www.uni-muenster.de/Physik.PI/Pernice/
GNU Lesser General Public License v3.0
110 stars 33 forks source link

Rounding & Spacing Issue when writing Cell Array to gdsii #62

Closed nicholasnobile closed 2 years ago

nicholasnobile commented 2 years ago

https://github.com/HelgeGehring/gdshelpers/blob/96cfe541c18360dc8a8902fa723b7b5edfabbe72/gdshelpers/export/gdsii_export.py#L82-L84

So I am trying to implement 2 cells within a cell as an array. I am using the standard micron as the unit, but I am trying to have increased precision to 0.1nm [10000 grid steps per micron]. When I make the spacing equal micron steps apart, it works. When they are not, there is a spacing issue. I am pretty sure the problem is here in the code referenced above as internally the spacing kept in the gdspy_cell->references->spacing is correct. The code shown seems to round before the points are scaled by the grid_steps_per_unit rather than after, which I think is causing my problem.

nicholasnobile commented 2 years ago

The following code seemed to solve my issue. But this needs to be reimplemented into the master and a new revision released.

b.write((np.round((np.array((ref['spacing'][0] * ref['columns'], 0)) + np.array(ref['origin'])) * grid_steps_per_unit)).astype( '>i4').tobytes()) # XY INTEGER_8 edge_x b.write((np.round((np.array((0, ref['spacing'][1] * ref['rows'])) + np.array(ref['origin'])) * grid_steps_per_unit)).astype( '>i4').tobytes()) # XY INTEGER_8 edge_y

HelgeGehring commented 2 years ago

Thanks! I've added the change to the master branch :)

HelgeGehring commented 2 years ago

And a new version containing the fix is on pypi :)

nicholasnobile commented 2 years ago

Thank you so much!