Git Product home page Git Product logo

python-gdsii's Introduction

python-gdsii --- a GDSII manipulation libaray

python-gdsii is a library that can be used to read, create, modify and save GDSII files. It supports both low-level record I/O and high level interface to GDSII libraries (databases), structures, and elements.

This package also includes scripts that can be used to convert binary GDS file to a simple text format (gds2txt), YAML (gds2yaml), and from text fromat back to GDSII (txt2gds).

Usage

For most cases interface provided by Library class from gdsii.library should be enough. Here is a small example:

from gdsii.library import Library
from gdsii.elements import *

# read a library from a file
with open('file.gds', 'rb') as stream:
    lib = Library.load(stream)

# let's move the first structure to a new library
new_lib = Library(5, b'NEWLIB.DB', 1e-9, 0.001)
struc = lib.pop(0) # libraries and structures are derived from list class
new_lib.append(struc)

# let's also add some elements...
# Note: first and last points in the boundary should be the same
#       this is required by GDSII spec.
struc.append(Boundary(45, 0, [(-100000, -100000), (-100000, 0), (0,0), (0, -100000), (-100000, -100000)]))

# Save both files with different names...
with open('newfile1.gds', 'wb') as stream:
    lib.save(stream)

with open('newfile2.gds', 'wb') as stream:
    new_lib.save(stream)

python-gdsii's People

Contributors

eugmes avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

python-gdsii's Issues

Time stamp issue

Hello Eugeniy,
I've been using your GDSII library to parse some GDSII files and I've been having some issues reading files because of poorly formatted time stamps in those GDSII files.
Clearly, it is not your code but poor quality of the input files.

Anyway, I modified this method to fix the issue.

def times(self):

Posting it here just in case you find it useful.

    if len(self.data) != 12:
        raise exceptions.DataSizeError(self.tag)

    try:
        mod_time = datetime(self.data[0] + 1900, *self.data[1:6])
        acc_time = datetime(self.data[0] + 1900, *self.data[7:12])
    except:
        mod_time = datetime.utcnow()
        acc_time = datetime.utcnow()

    return (mod_time, acc_time)

Thanks for writing this package and all the best!!!
Cheers,
Kirill

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.