PhfStream
PhfStream(filename, mode='r', set_config=True)Create a PhfStream object for writing or loading phf files.
Args
- filename (str): Phf file name.
- mode (Literal[“r”, “w”]): Either
"r"or"w"to open the file for reading or writing, respectively. - set_config (bool): If
Trueandmode == 'r', set the configuration with values loaded from the file.
Methods
Section titled “Methods”| Method | Description |
|---|---|
close | Close the stream. |
contents | Index of the stream contents. |
data | List of all objects stored in the phf stream file. |
load_component | Load components from this stream. |
load_technology | Load technologies from this stream. |
write | Write objects to this phf stream file. |
close(self)Close the stream.
contents
Section titled “contents”contents(self, only_explicit=True)Index of the stream contents.
Args
- only_explicit (bool): If set, only explicitly written component and technology entries are returned (excludes automatically included dependencies).
Returns
dict[Literal[“components”, “technologies”], set[str] | set[tuple[str, str]]]
Dictionary with keys "components" and "technologies". The
former holds a set of Component names, and the latter a set
of tuples with Technology names and versions.
data(self)List of all objects stored in the phf stream file.
Returns
list[object]: Objects stored in the phf stream, in the order they were originally stored.
load_component
Section titled “load_component”load_component(self, name=None, only_explicit=True)Load components from this stream.
Args
- name (str | None): If given, only the named component is returned, otherwise all components in the stream.
- only_explicit (bool): If set, only explicitly stored components are returned. This argument is ignored if name is given.
Returns
list[Component]: Loaded components.
load_technology
Section titled “load_technology”load_technology(self, name=None, version=None, only_explicit=True)Load technologies from this stream.
Args
- name (str | None): If given, only technologies with this name are returned, otherwise all technologies in the stream.
- version (str | None): If given, only technologies with this version are returned, otherwise all technologies in the stream.
- only_explicit (bool): If set, only explicitly stored technologies are returned. This argument is ignored if both name and version are given.
Returns
list[Technology]: Loaded technologies.
write(self, *args)Write objects to this phf stream file.
Args
- *args (object): All photonforge objects are supported. Serializable Tidy3D objects and many native python and numpy types are also supported.
Returns
PhfStream: This object.
Attributes
Section titled “Attributes”| Attribute | Description |
|---|---|
config | dict[str, object] | None: Configuration present in phf files (read only). |
properties | Properties: Object properties. |
config
Section titled “config”dict[str, object] | None: Configuration present in phf files (read only).
properties
Section titled “properties”Properties: Object properties.